diff --git a/.gitignore b/.gitignore index d321b15..9312109 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# horizon-match custom +# horizon-scope custom horizon_projects_embeddings.pkl .DS_Store .vscode diff --git a/README.md b/README.md index 92d20ef..74b5f59 100644 --- a/README.md +++ b/README.md @@ -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 🌟 @@ -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. diff --git a/app.py b/app.py index cb29ec1..b0c31e9 100644 --- a/app.py +++ b/app.py @@ -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() diff --git a/config.yml b/config.yml index 27c3913..fadab81 100644 --- a/config.yml +++ b/config.yml @@ -1,4 +1,4 @@ -horizon-match: +horizon-scope: comparison-service: type: openai api_key: "{OPENAI_API_KEY}" diff --git a/notebooks/05_horizon-match-client-usage.ipynb b/notebooks/05_horizon_scope_client_usage.ipynb similarity index 93% rename from notebooks/05_horizon-match-client-usage.ipynb rename to notebooks/05_horizon_scope_client_usage.ipynb index 2761e8c..8767420 100644 --- a/notebooks/05_horizon-match-client-usage.ipynb +++ b/notebooks/05_horizon_scope_client_usage.ipynb @@ -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.\")" ] diff --git a/pyproject.toml b/pyproject.toml index ec97789..7113a06 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [tool.poetry] -name = "horizon-match" +name = "horizon-scope" version = "0.0.1" description = "" authors = ["Florian Hegenbarth "] readme = "README.md" -packages = [{ include = "horizon_match", from = "src" }] +packages = [{ include = "horizon_scope", from = "src" }] [tool.poetry.dependencies] python = "^3.11" diff --git a/src/horizon_match/__init__.py b/src/horizon_scope/__init__.py similarity index 100% rename from src/horizon_match/__init__.py rename to src/horizon_scope/__init__.py diff --git a/src/horizon_match/application/__init__.py b/src/horizon_scope/application/__init__.py similarity index 100% rename from src/horizon_match/application/__init__.py rename to src/horizon_scope/application/__init__.py diff --git a/src/horizon_match/application/interfaces/__init__.py b/src/horizon_scope/application/interfaces/__init__.py similarity index 100% rename from src/horizon_match/application/interfaces/__init__.py rename to src/horizon_scope/application/interfaces/__init__.py diff --git a/src/horizon_match/application/interfaces/comparison_service.py b/src/horizon_scope/application/interfaces/comparison_service.py similarity index 93% rename from src/horizon_match/application/interfaces/comparison_service.py rename to src/horizon_scope/application/interfaces/comparison_service.py index 85b557d..b08ce13 100644 --- a/src/horizon_match/application/interfaces/comparison_service.py +++ b/src/horizon_scope/application/interfaces/comparison_service.py @@ -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): diff --git a/src/horizon_match/application/interfaces/vector_search_service.py b/src/horizon_scope/application/interfaces/vector_search_service.py similarity index 94% rename from src/horizon_match/application/interfaces/vector_search_service.py rename to src/horizon_scope/application/interfaces/vector_search_service.py index f6d5802..b94d9d1 100644 --- a/src/horizon_match/application/interfaces/vector_search_service.py +++ b/src/horizon_scope/application/interfaces/vector_search_service.py @@ -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): diff --git a/src/horizon_match/application/use_cases/__init__.py b/src/horizon_scope/application/use_cases/__init__.py similarity index 100% rename from src/horizon_match/application/use_cases/__init__.py rename to src/horizon_scope/application/use_cases/__init__.py diff --git a/src/horizon_match/application/use_cases/compare_projects.py b/src/horizon_scope/application/use_cases/compare_projects.py similarity index 82% rename from src/horizon_match/application/use_cases/compare_projects.py rename to src/horizon_scope/application/use_cases/compare_projects.py index 69a592e..321d8cc 100644 --- a/src/horizon_match/application/use_cases/compare_projects.py +++ b/src/horizon_scope/application/use_cases/compare_projects.py @@ -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: @@ -32,7 +32,7 @@ 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: @@ -40,17 +40,17 @@ def execute(self, query: str, k: int) -> List[HorizonMatchResult]: 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 diff --git a/src/horizon_match/domain/__init__.py b/src/horizon_scope/domain/__init__.py similarity index 100% rename from src/horizon_match/domain/__init__.py rename to src/horizon_scope/domain/__init__.py diff --git a/src/horizon_match/domain/entities/__init__.py b/src/horizon_scope/domain/entities/__init__.py similarity index 100% rename from src/horizon_match/domain/entities/__init__.py rename to src/horizon_scope/domain/entities/__init__.py diff --git a/src/horizon_match/domain/entities/comparison.py b/src/horizon_scope/domain/entities/comparison.py similarity index 100% rename from src/horizon_match/domain/entities/comparison.py rename to src/horizon_scope/domain/entities/comparison.py diff --git a/src/horizon_match/domain/entities/horizon_match_result.py b/src/horizon_scope/domain/entities/horizon_scope_result.py similarity index 71% rename from src/horizon_match/domain/entities/horizon_match_result.py rename to src/horizon_scope/domain/entities/horizon_scope_result.py index 26c493f..cb2cfac 100644 --- a/src/horizon_match/domain/entities/horizon_match_result.py +++ b/src/horizon_scope/domain/entities/horizon_scope_result.py @@ -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: diff --git a/src/horizon_match/domain/entities/project.py b/src/horizon_scope/domain/entities/project.py similarity index 100% rename from src/horizon_match/domain/entities/project.py rename to src/horizon_scope/domain/entities/project.py diff --git a/src/horizon_match/infrastructure/__init__.py b/src/horizon_scope/infrastructure/__init__.py similarity index 100% rename from src/horizon_match/infrastructure/__init__.py rename to src/horizon_scope/infrastructure/__init__.py diff --git a/src/horizon_match/infrastructure/config/__init__.py b/src/horizon_scope/infrastructure/config/__init__.py similarity index 100% rename from src/horizon_match/infrastructure/config/__init__.py rename to src/horizon_scope/infrastructure/config/__init__.py diff --git a/src/horizon_match/infrastructure/config/config_manager.py b/src/horizon_scope/infrastructure/config/config_manager.py similarity index 100% rename from src/horizon_match/infrastructure/config/config_manager.py rename to src/horizon_scope/infrastructure/config/config_manager.py diff --git a/src/horizon_match/infrastructure/services/__init__.py b/src/horizon_scope/infrastructure/services/__init__.py similarity index 100% rename from src/horizon_match/infrastructure/services/__init__.py rename to src/horizon_scope/infrastructure/services/__init__.py diff --git a/src/horizon_match/infrastructure/services/openai_comparison_service.py b/src/horizon_scope/infrastructure/services/openai_comparison_service.py similarity index 95% rename from src/horizon_match/infrastructure/services/openai_comparison_service.py rename to src/horizon_scope/infrastructure/services/openai_comparison_service.py index b54c7f5..4fe6886 100644 --- a/src/horizon_match/infrastructure/services/openai_comparison_service.py +++ b/src/horizon_scope/infrastructure/services/openai_comparison_service.py @@ -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 @@ -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. diff --git a/src/horizon_match/infrastructure/services/pinecone_search_service.py b/src/horizon_scope/infrastructure/services/pinecone_search_service.py similarity index 89% rename from src/horizon_match/infrastructure/services/pinecone_search_service.py rename to src/horizon_scope/infrastructure/services/pinecone_search_service.py index 9e95ce3..16c5a9e 100644 --- a/src/horizon_match/infrastructure/services/pinecone_search_service.py +++ b/src/horizon_scope/infrastructure/services/pinecone_search_service.py @@ -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): @@ -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]: diff --git a/src/horizon_match/presentation/__init__.py b/src/horizon_scope/presentation/__init__.py similarity index 100% rename from src/horizon_match/presentation/__init__.py rename to src/horizon_scope/presentation/__init__.py diff --git a/src/horizon_match/presentation/horizon_match_client.py b/src/horizon_scope/presentation/horizon_scope_client.py similarity index 78% rename from src/horizon_match/presentation/horizon_match_client.py rename to src/horizon_scope/presentation/horizon_scope_client.py index 01f5422..df3e29a 100644 --- a/src/horizon_match/presentation/horizon_match_client.py +++ b/src/horizon_scope/presentation/horizon_scope_client.py @@ -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. @@ -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. @@ -36,19 +36,19 @@ 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: @@ -56,7 +56,7 @@ def match(self, query: str, k: int) -> list[HorizonMatchResult]: 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) diff --git a/src/horizon_match/presentation/streamlit_app.py b/src/horizon_scope/presentation/streamlit_app.py similarity index 96% rename from src/horizon_match/presentation/streamlit_app.py rename to src/horizon_scope/presentation/streamlit_app.py index f35aca0..90c05d6 100644 --- a/src/horizon_match/presentation/streamlit_app.py +++ b/src/horizon_scope/presentation/streamlit_app.py @@ -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 @@ -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: [florian@hegenbarth.dev](mailto:florian@hegenbarth.dev)" ) @@ -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"): diff --git a/structure.ipynb b/structure.ipynb new file mode 100644 index 0000000..45a72d2 --- /dev/null +++ b/structure.ipynb @@ -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 +} diff --git a/tests/test_compare_projects.py b/tests/test_compare_projects.py index 30f99ee..ad88777 100644 --- a/tests/test_compare_projects.py +++ b/tests/test_compare_projects.py @@ -2,12 +2,12 @@ from unittest.mock import Mock, MagicMock 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_match.application.use_cases.compare_projects import CompareProjects +from horizon_scope.application.interfaces.comparison_service import ComparisonService +from horizon_scope.domain.entities.horizon_scope_result import HorizonScopeResult +from horizon_scope.application.use_cases.compare_projects import CompareProjects class MockProject: @@ -92,7 +92,7 @@ def test_execute_returns_horizon_match_results( results = compare_projects.execute(query, k) # Assert - assert isinstance(results[0], HorizonMatchResult) + assert isinstance(results[0], HorizonScopeResult) assert results[0].project == mock_project assert results[0].comparison.score == 0.5 diff --git a/tests/test_config_manager.py b/tests/test_config_manager.py index 9e0f225..f8ac774 100644 --- a/tests/test_config_manager.py +++ b/tests/test_config_manager.py @@ -1,6 +1,6 @@ import pytest import yaml -from horizon_match.infrastructure.config.config_manager import ConfigManager +from horizon_scope.infrastructure.config.config_manager import ConfigManager @pytest.fixture diff --git a/tests/test_horizon_match_client.py b/tests/test_horizon_match_client.py index a7f56fd..eeffb6f 100644 --- a/tests/test_horizon_match_client.py +++ b/tests/test_horizon_match_client.py @@ -1,17 +1,17 @@ import pytest from unittest.mock import Mock, patch -from horizon_match.presentation.horizon_match_client import HorizonMatchClient -from horizon_match.domain.entities.project import Project -from horizon_match.domain.entities.comparison import Comparison -from horizon_match.domain.entities.horizon_match_result import HorizonMatchResult -from horizon_match.infrastructure.config.config_manager import ConfigManager -from horizon_match.infrastructure.services.pinecone_search_service import ( +from horizon_scope.presentation.horizon_scope_client import HorizonScopeClient +from horizon_scope.domain.entities.project import Project +from horizon_scope.domain.entities.comparison import Comparison +from horizon_scope.domain.entities.horizon_scope_result import HorizonScopeResult +from horizon_scope.infrastructure.config.config_manager import ConfigManager +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.application.use_cases.compare_projects import CompareProjects +from horizon_scope.application.use_cases.compare_projects import CompareProjects @pytest.fixture @@ -35,35 +35,35 @@ def mock_compare_projects(): @pytest.fixture -def horizon_match_client( +def horizon_scope_client( mock_config_manager, mock_vector_search_service, mock_comparison_service, mock_compare_projects, ): with patch( - "horizon_match.presentation.horizon_match_client.PineconeSearchService", + "horizon_scope.presentation.horizon_scope_client.PineconeSearchService", return_value=mock_vector_search_service, ), patch( - "horizon_match.presentation.horizon_match_client.OpenAIComparisonService", + "horizon_scope.presentation.horizon_scope_client.OpenAIComparisonService", return_value=mock_comparison_service, ), patch( - "horizon_match.presentation.horizon_match_client.CompareProjects", + "horizon_scope.presentation.horizon_scope_client.CompareProjects", return_value=mock_compare_projects, ): - return HorizonMatchClient(mock_config_manager) + return HorizonScopeClient(mock_config_manager) def test_initialization(mock_config_manager): with patch( - "horizon_match.presentation.horizon_match_client.PineconeSearchService" + "horizon_scope.presentation.horizon_scope_client.PineconeSearchService" ) as mock_pinecone, patch( - "horizon_match.presentation.horizon_match_client.OpenAIComparisonService" + "horizon_scope.presentation.horizon_scope_client.OpenAIComparisonService" ) as mock_openai, patch( - "horizon_match.presentation.horizon_match_client.CompareProjects" + "horizon_scope.presentation.horizon_scope_client.CompareProjects" ) as mock_compare_projects: - client = HorizonMatchClient(mock_config_manager) + client = HorizonScopeClient(mock_config_manager) mock_pinecone.assert_called_once_with(mock_config_manager) mock_openai.assert_called_once_with(mock_config_manager) @@ -72,57 +72,57 @@ def test_initialization(mock_config_manager): def test_from_config(): with patch( - "horizon_match.presentation.horizon_match_client.ConfigManager" + "horizon_scope.presentation.horizon_scope_client.ConfigManager" ) as mock_config_manager, patch( - "horizon_match.presentation.horizon_match_client.HorizonMatchClient.__init__", + "horizon_scope.presentation.horizon_scope_client.HorizonScopeClient.__init__", return_value=None, ) as mock_init: - HorizonMatchClient.from_config("test_config.yml") + HorizonScopeClient.from_config("test_config.yml") mock_config_manager.assert_called_once_with("test_config.yml") mock_init.assert_called_once() -def test_match(horizon_match_client, mock_compare_projects): +def test_match(horizon_scope_client, mock_compare_projects): query = "test query" k = 5 - mock_results = [Mock(spec=HorizonMatchResult) for _ in range(k)] + mock_results = [Mock(spec=HorizonScopeResult) for _ in range(k)] mock_compare_projects.execute.return_value = mock_results - results = horizon_match_client.match(query, k) + results = horizon_scope_client.match(query, k) mock_compare_projects.execute.assert_called_once_with(query, k) assert results == mock_results -def test_index_project(horizon_match_client, mock_vector_search_service): +def test_index_project(horizon_scope_client, mock_vector_search_service): project = Mock(spec=Project) - horizon_match_client.index_project(project) + horizon_scope_client.index_project(project) mock_vector_search_service.index_project.assert_called_once_with(project) -def test_search_projects(horizon_match_client, mock_vector_search_service): +def test_search_projects(horizon_scope_client, mock_vector_search_service): query = "test query" k = 5 mock_projects = [Mock(spec=Project) for _ in range(k)] mock_vector_search_service.search.return_value = mock_projects - results = horizon_match_client.search_projects(query, k) + results = horizon_scope_client.search_projects(query, k) mock_vector_search_service.search.assert_called_once_with(query, k) assert results == mock_projects -def test_get_config(horizon_match_client, mock_config_manager): +def test_get_config(horizon_scope_client, mock_config_manager): keys = ["test", "key"] default_value = "default" expected_value = "config_value" mock_config_manager.get.return_value = expected_value - result = horizon_match_client.get_config(*keys, default=default_value) + result = horizon_scope_client.get_config(*keys, default=default_value) mock_config_manager.get.assert_called_once_with(*keys, default=default_value) assert result == expected_value @@ -130,19 +130,19 @@ def test_get_config(horizon_match_client, mock_config_manager): def test_integration(mock_config_manager): with patch( - "horizon_match.presentation.horizon_match_client.PineconeSearchService" + "horizon_scope.presentation.horizon_scope_client.PineconeSearchService" ) as mock_pinecone, patch( - "horizon_match.presentation.horizon_match_client.OpenAIComparisonService" + "horizon_scope.presentation.horizon_scope_client.OpenAIComparisonService" ) as mock_openai, patch( - "horizon_match.presentation.horizon_match_client.CompareProjects" + "horizon_scope.presentation.horizon_scope_client.CompareProjects" ) as mock_compare_projects: - client = HorizonMatchClient(mock_config_manager) + client = HorizonScopeClient(mock_config_manager) # Test match query = "test query" k = 3 - mock_results = [Mock(spec=HorizonMatchResult) for _ in range(k)] + mock_results = [Mock(spec=HorizonScopeResult) for _ in range(k)] mock_compare_projects.return_value.execute.return_value = mock_results results = client.match(query, k) diff --git a/tests/test_openai_comparison_service.py b/tests/test_openai_comparison_service.py index 020790b..9209cbc 100644 --- a/tests/test_openai_comparison_service.py +++ b/tests/test_openai_comparison_service.py @@ -1,20 +1,20 @@ import pytest from unittest.mock import Mock, patch import json -from horizon_match.infrastructure.services.openai_comparison_service import ( +from horizon_scope.infrastructure.services.openai_comparison_service import ( OpenAIComparisonService, MAX_PROJECT_LENGTH, ) -from horizon_match.domain.entities.comparison import Comparison -from horizon_match.infrastructure.config.config_manager import ConfigManager +from horizon_scope.domain.entities.comparison import Comparison +from horizon_scope.infrastructure.config.config_manager import ConfigManager @pytest.fixture def mock_config(): config = Mock(spec=ConfigManager) config.get.side_effect = lambda *args: { - ("horizon-match", "comparison-service", "api_key"): "test_openai_api_key", - ("horizon-match", "comparison-service", "model"): "gpt-4", + ("horizon-scope", "comparison-service", "api_key"): "test_openai_api_key", + ("horizon-scope", "comparison-service", "model"): "gpt-4", }[args] return config @@ -27,7 +27,7 @@ def mock_openai_client(): @pytest.fixture def comparison_service(mock_config, mock_openai_client): with patch( - "horizon_match.infrastructure.services.openai_comparison_service.OpenAI" + "horizon_scope.infrastructure.services.openai_comparison_service.OpenAI" ) as mock_openai: mock_openai.return_value = mock_openai_client return OpenAIComparisonService(mock_config) @@ -35,12 +35,12 @@ def comparison_service(mock_config, mock_openai_client): def test_initialization(mock_config): with patch( - "horizon_match.infrastructure.services.openai_comparison_service.OpenAI" + "horizon_scope.infrastructure.services.openai_comparison_service.OpenAI" ) as mock_openai: service = OpenAIComparisonService(mock_config) - mock_config.get.assert_any_call("horizon-match", "comparison-service", "api_key") - mock_config.get.assert_any_call("horizon-match", "comparison-service", "model") + mock_config.get.assert_any_call("horizon-scope", "comparison-service", "api_key") + mock_config.get.assert_any_call("horizon-scope", "comparison-service", "model") mock_openai.assert_called_once_with(api_key="test_openai_api_key") assert service.model == "gpt-4" diff --git a/tests/test_pinecone_search_service.py b/tests/test_pinecone_search_service.py index c31c069..3b5ca2d 100644 --- a/tests/test_pinecone_search_service.py +++ b/tests/test_pinecone_search_service.py @@ -1,11 +1,11 @@ import pytest from unittest.mock import Mock, patch from datetime import datetime -from horizon_match.infrastructure.services.pinecone_search_service import ( +from horizon_scope.infrastructure.services.pinecone_search_service import ( PineconeSearchService, ) -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 @pytest.fixture @@ -13,20 +13,20 @@ def mock_config(): config = Mock(spec=ConfigManager) config.get.side_effect = lambda *args: { ( - "horizon-match", + "horizon-scope", "vector-search-service", "store", "api_key", ): "test_pinecone_api_key", - ("horizon-match", "vector-search-service", "store", "index"): "test_index", + ("horizon-scope", "vector-search-service", "store", "index"): "test_index", ( - "horizon-match", + "horizon-scope", "vector-search-service", "embeddings", "api_key", ): "test_openai_api_key", ( - "horizon-match", + "horizon-scope", "vector-search-service", "embeddings", "model", @@ -48,11 +48,11 @@ def mock_openai_client(): @pytest.fixture def pinecone_search_service(mock_config, mock_pinecone_index, mock_openai_client): with patch( - "horizon_match.infrastructure.services.pinecone_search_service.Pinecone" + "horizon_scope.infrastructure.services.pinecone_search_service.Pinecone" ) as mock_pinecone: mock_pinecone.return_value.Index.return_value = mock_pinecone_index with patch( - "horizon_match.infrastructure.services.pinecone_search_service.OpenAI" + "horizon_scope.infrastructure.services.pinecone_search_service.OpenAI" ) as mock_openai: mock_openai.return_value = mock_openai_client return PineconeSearchService(mock_config) @@ -165,7 +165,7 @@ def test_index_project_without_content_update_date( # Act with patch( - "horizon_match.infrastructure.services.pinecone_search_service.datetime" + "horizon_scope.infrastructure.services.pinecone_search_service.datetime" ) as mock_datetime: mock_now = datetime(2023, 1, 1, 12, 0, 0) mock_datetime.now.return_value = mock_now @@ -180,10 +180,10 @@ def test_index_project_without_content_update_date( def test_initialization(mock_config): # Act with patch( - "horizon_match.infrastructure.services.pinecone_search_service.Pinecone" + "horizon_scope.infrastructure.services.pinecone_search_service.Pinecone" ) as mock_pinecone: with patch( - "horizon_match.infrastructure.services.pinecone_search_service.OpenAI" + "horizon_scope.infrastructure.services.pinecone_search_service.OpenAI" ) as mock_openai: PineconeSearchService(mock_config)