Skip to content

Commit

Permalink
Merge pull request #10 from turboflo/8-add-documentation
Browse files Browse the repository at this point in the history
chore: Update project name from horizon-match to horizon-scope
  • Loading branch information
turboflo committed Sep 1, 2024
2 parents 05b91a4 + 7d327d8 commit f32dd8a
Show file tree
Hide file tree
Showing 33 changed files with 202 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# horizon-match custom
# horizon-scope custom
horizon_projects_embeddings.pkl
.DS_Store
.vscode
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

# Horizon Match ✨📑
# Horizon Scope ✨📑

[![CI](https://github.com/turboflo/horizon-match/actions/workflows/ci.yml/badge.svg?branch=development)](https://github.com/turboflo/horizon-match/actions/workflows/ci.yml)
![GitHub Release](https://img.shields.io/github/v/release/turboflo/horizon-match)
![GitHub contributors](https://img.shields.io/github/contributors/turboflo/horizon-match)
[![CI](https://github.com/turboflo/horizon-scope/actions/workflows/ci.yml/badge.svg?branch=development)](https://github.com/turboflo/horizon-scope/actions/workflows/ci.yml)
![GitHub Release](https://img.shields.io/github/v/release/turboflo/horizon-scope)
![GitHub contributors](https://img.shields.io/github/contributors/turboflo/horizon-scope)



**Horizon Match** is a project comparison and analysis tool that leverages vector search and AI-powered comparisons to help users discover similar projects and gain valuable insights.
**Horizon Scope** is a project comparison and analysis tool that leverages vector search and AI-powered comparisons to help users discover similar projects and gain valuable insights.

## Key Features 🌟

Expand All @@ -20,7 +20,7 @@

## Components 🧩

- **`HorizonMatchClient`**: Main client class interfacing with core functionalities.
- **`HorizonScopeClient`**: Main client class interfacing with core functionalities.
- **`VectorSearchService`**: Manages vector-based similarity searches using Pinecone.
- **`ComparisonService`**: Handles AI-powered project comparisons using OpenAI.
- **Streamlit Web Application**: Interactive interface for project comparisons.
Expand Down
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.horizon_match.presentation.streamlit_app import main
from src.horizon_scope.presentation.streamlit_app import main

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
horizon-match:
horizon-scope:
comparison-service:
type: openai
api_key: "{OPENAI_API_KEY}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
"outputs": [],
"source": [
"import pandas as pd\n",
"from horizon_match.presentation.horizon_match_client import HorizonMatchClient\n",
"from horizon_scope.presentation.horizon_scope_client import HorizonScopeClient\n",
"\n",
"\n",
"# Initialize the Horizon Match client\n",
"client = HorizonMatchClient.from_config(\"../config.yml\")\n",
"client = HorizonScopeClient.from_config(\"../config.yml\")\n",
"\n",
"print(\"Client initialized successfully.\")"
]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tool.poetry]
name = "horizon-match"
name = "horizon-scope"
version = "0.0.1"
description = ""
authors = ["Florian Hegenbarth <[email protected]>"]
readme = "README.md"
packages = [{ include = "horizon_match", from = "src" }]
packages = [{ include = "horizon_scope", from = "src" }]

[tool.poetry.dependencies]
python = "^3.11"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from horizon_match.domain.entities.comparison import Comparison
from horizon_scope.domain.entities.comparison import Comparison


class ComparisonService(ABC):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC, abstractmethod
from typing import List
from horizon_match.domain.entities.project import Project
from horizon_scope.domain.entities.project import Project


class VectorSearchService(ABC):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import List
from horizon_match.application.interfaces.vector_search_service import (
from horizon_scope.application.interfaces.vector_search_service import (
VectorSearchService,
)
from horizon_match.application.interfaces.comparison_service import ComparisonService
from horizon_match.domain.entities.horizon_match_result import HorizonMatchResult
from horizon_scope.application.interfaces.comparison_service import ComparisonService
from horizon_scope.domain.entities.horizon_scope_result import HorizonScopeResult


class CompareProjects:
Expand Down Expand Up @@ -32,25 +32,25 @@ def __init__(
self.vector_search_service = vector_search_service
self.comparison_service = comparison_service

def execute(self, query: str, k: int) -> List[HorizonMatchResult]:
def execute(self, query: str, k: int) -> List[HorizonScopeResult]:
"""Perform the comparison of the query project with similar projects.
Args:
query (str): The description of the query project to compare.
k (int): The number of similar projects to retrieve and compare.
Returns:
List[HorizonMatchResult]: A list of HorizonMatchResult objects, sorted by similarity score in descending order.
List[HorizonScopeResult]: A list of HorizonScopeResult objects, sorted by similarity score in descending order.
"""
# Perform vector search to find similar projects
similar_projects = self.vector_search_service.search(query, k)

# Compare the query with each similar project
results: List[HorizonMatchResult] = []
results: List[HorizonScopeResult] = []
for project in similar_projects:
# Compare the query description with the project description
comparison = self.comparison_service.compare(query, project.description)
result = HorizonMatchResult(project=project, comparison=comparison)
result = HorizonScopeResult(project=project, comparison=comparison)
results.append(result)

# Sort results by AI similarity score in descending order
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from dataclasses import dataclass
from horizon_match.domain.entities.comparison import Comparison
from horizon_match.domain.entities.project import Project
from horizon_scope.domain.entities.comparison import Comparison
from horizon_scope.domain.entities.project import Project


@dataclass
class HorizonMatchResult:
class HorizonScopeResult:
"""Represents the result of a comparison between a project and another entity.
Attributes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations
from openai import OpenAI
from typing import List, Dict
from horizon_match.application.interfaces.comparison_service import ComparisonService
from horizon_match.domain.entities.comparison import Comparison
from horizon_match.infrastructure.config.config_manager import ConfigManager
from horizon_scope.application.interfaces.comparison_service import ComparisonService
from horizon_scope.domain.entities.comparison import Comparison
from horizon_scope.infrastructure.config.config_manager import ConfigManager

MAX_PROJECT_LENGTH = 10000

Expand All @@ -28,10 +28,10 @@ def __init__(self, config: ConfigManager) -> None:
"""
self.config = config
openai_api_key = self.config.get(
"horizon-match", "comparison-service", "api_key"
"horizon-scope", "comparison-service", "api_key"
)
self.client = OpenAI(api_key=openai_api_key)
self.model = self.config.get("horizon-match", "comparison-service", "model")
self.model = self.config.get("horizon-scope", "comparison-service", "model")

def compare(self, my_project: str, existing_project: str) -> Comparison:
"""Compare two project descriptions using OpenAI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from openai import OpenAI
from typing import List
from datetime import datetime
from horizon_match.application.interfaces.vector_search_service import (
from horizon_scope.application.interfaces.vector_search_service import (
VectorSearchService,
)
from horizon_match.domain.entities.project import Project
from horizon_match.infrastructure.config.config_manager import ConfigManager
from horizon_scope.domain.entities.project import Project
from horizon_scope.infrastructure.config.config_manager import ConfigManager


class PineconeSearchService(VectorSearchService):
Expand All @@ -31,20 +31,20 @@ def __init__(self, config: ConfigManager) -> None:
self.config = config
# Initialize Pinecone
pinecone_api_key = self.config.get(
"horizon-match", "vector-search-service", "store", "api_key"
"horizon-scope", "vector-search-service", "store", "api_key"
)
pc = Pinecone(api_key=pinecone_api_key)
index_name = self.config.get(
"horizon-match", "vector-search-service", "store", "index"
"horizon-scope", "vector-search-service", "store", "index"
)
self.index = pc.Index(index_name)
# Initialize OpenAI client for embeddings
openai_api_key = self.config.get(
"horizon-match", "vector-search-service", "embeddings", "api_key"
"horizon-scope", "vector-search-service", "embeddings", "api_key"
)
self.openai_client = OpenAI(api_key=openai_api_key)
self.embedding_model = self.config.get(
"horizon-match", "vector-search-service", "embeddings", "model"
"horizon-scope", "vector-search-service", "embeddings", "model"
)

def search(self, query: str, k: int) -> List[Project]:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from __future__ import annotations
from typing import Any
from horizon_match.application.use_cases.compare_projects import CompareProjects
from horizon_match.domain.entities.horizon_match_result import HorizonMatchResult
from horizon_match.infrastructure.services.pinecone_search_service import (
from horizon_scope.application.use_cases.compare_projects import CompareProjects
from horizon_scope.domain.entities.horizon_scope_result import HorizonScopeResult
from horizon_scope.infrastructure.services.pinecone_search_service import (
PineconeSearchService,
)
from horizon_match.infrastructure.services.openai_comparison_service import (
from horizon_scope.infrastructure.services.openai_comparison_service import (
OpenAIComparisonService,
)
from horizon_match.infrastructure.config.config_manager import ConfigManager
from horizon_match.domain.entities.project import Project
from horizon_scope.infrastructure.config.config_manager import ConfigManager
from horizon_scope.domain.entities.project import Project


class HorizonMatchClient:
"""Client for handling horizon match operations.
class HorizonScopeClient:
"""Client for handling horizon scope operations.
Attributes:
config_manager (ConfigManager): Configuration manager for the client.
Expand All @@ -23,7 +23,7 @@ class HorizonMatchClient:
"""

def __init__(self, config_manager: ConfigManager) -> None:
"""Initialize the HorizonMatchClient with a configuration manager.
"""Initialize the HorizonScopeClient with a configuration manager.
Args:
config_manager (ConfigManager): The configuration manager to use for setting up services.
Expand All @@ -36,27 +36,27 @@ def __init__(self, config_manager: ConfigManager) -> None:
)

@classmethod
def from_config(cls, config_path: str = "config.yml") -> HorizonMatchClient:
"""Create a HorizonMatchClient instance from a configuration file.
def from_config(cls, config_path: str = "config.yml") -> HorizonScopeClient:
"""Create a HorizonScopeClient instance from a configuration file.
Args:
config_path (str, optional): Path to the configuration file. Defaults to "config.yml".
Returns:
HorizonMatchClient: An instance of HorizonMatchClient initialized with the given configuration.
HorizonScopeClient: An instance of HorizonScopeClient initialized with the given configuration.
"""
config = ConfigManager(config_path)
return cls(config)

def match(self, query: str, k: int) -> list[HorizonMatchResult]:
def match(self, query: str, k: int) -> list[HorizonScopeResult]:
"""Perform a match operation using the provided query.
Args:
query (str): The query string to match against.
k (int): The number of results to return.
Returns:
list[HorizonMatchResult]: A list of HorizonMatchResult objects matching the query.
list[HorizonScopeResult]: A list of HorizonScopeResult objects matching the query.
"""
return self.compare_projects_use_case.execute(query, k)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import streamlit as st
from horizon_match.presentation.horizon_match_client import HorizonMatchClient
from horizon_scope.presentation.horizon_scope_client import HorizonScopeClient
import os


Expand Down Expand Up @@ -34,7 +34,7 @@ def main():
# Sidebar
with st.sidebar:
st.markdown("### ℹ️ About")
st.markdown("🌐 [GitHub Repository](https://github.com/turboflo/horizon-match)")
st.markdown("🌐 [GitHub Repository](https://github.com/turboflo/horizon-scope)")
st.markdown(
"📧 Contact: [[email protected]](mailto:[email protected])"
)
Expand All @@ -47,7 +47,7 @@ def main():
config_path = os.path.join(
os.path.dirname(__file__), "..", "..", "..", "config.yml"
)
client = HorizonMatchClient.from_config(config_path)
client = HorizonScopeClient.from_config(config_path)

# User input form
with st.form(key="input_form"):
Expand Down
87 changes: 87 additions & 0 deletions structure.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"horizon_match/\n",
" __init__.py\n",
" application/\n",
" __init__.py\n",
" use_cases/\n",
" __init__.py\n",
" compare_projects.py\n",
" interfaces/\n",
" comparison_service.py\n",
" vector_search_service.py\n",
" __init__.py\n",
" infrastructure/\n",
" __init__.py\n",
" config/\n",
" config_manager.py\n",
" __init__.py\n",
" services/\n",
" pinecone_search_service.py\n",
" openai_comparison_service.py\n",
" __init__.py\n",
" domain/\n",
" __init__.py\n",
" entities/\n",
" __init__.py\n",
" horizon_match_result.py\n",
" comparison.py\n",
" project.py\n",
" presentation/\n",
" __init__.py\n",
" streamlit_app.py\n",
" horizon_match_client.py\n"
]
}
],
"source": [
"import os\n",
"\n",
"package_path = \"src/horizon_scope\"\n",
"\n",
"# Display the project structure with .py files\n",
"\n",
"for root, dirs, files in os.walk(package_path):\n",
" level = root.replace(package_path, '').count(os.sep)\n",
" indent = ' ' * 4 * (level)\n",
" if '__pycache__' not in root:\n",
" print('{}{}/'.format(indent, os.path.basename(root)))\n",
" subindent = ' ' * 4 * (level + 1)\n",
" for f in files:\n",
" if not f.endswith('.pyc'):\n",
" print('{}{}'.format(subindent, f))\n",
" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit f32dd8a

Please sign in to comment.