From d00a77cf5659399f77e4f41f65a968b3cac769f5 Mon Sep 17 00:00:00 2001 From: niklas Date: Mon, 30 Oct 2023 10:15:17 +0100 Subject: [PATCH] FilterSearch -> QdrantSearch, Readme fixes --- README.md | 4 ++-- .../use_cases/classify/embedding_based_classify.py | 7 +++---- src/intelligence_layer/use_cases/search/qdrant_search.py | 8 ++++---- tests/use_cases/search/test_qdrant_search.py | 4 +++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4dbc483ab..8a77950df 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ cd src/examples && poetry run jupyter lab ## How to use this in your project -To install this as a dependency in your project, you will need to get a [Github access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). +To install this as a dependency in your project, you need a [Github access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). Set your access token: @@ -66,7 +66,7 @@ Let's install the package: pip install git+https://$GITHUB_TOKEN@github.com/aleph-alpha-intelligence-layer/intelligence-layer.git ``` -Now, the intelligence layer should be available and ready to use as a Python package. +Now the Intelligence Layer should be available as a Python package and ready to use. ```py from intelligence_layer.core.task import Task diff --git a/src/intelligence_layer/use_cases/classify/embedding_based_classify.py b/src/intelligence_layer/use_cases/classify/embedding_based_classify.py index 2d56bc8f9..dce341477 100644 --- a/src/intelligence_layer/use_cases/classify/embedding_based_classify.py +++ b/src/intelligence_layer/use_cases/classify/embedding_based_classify.py @@ -53,8 +53,7 @@ class EmbeddingBasedClassify(Task[ClassifyInput, ClassifyOutput]): scoring: Configure how to calculate the final score. Attributes: - METADATA_LABEL_NAME: The metadata field for label name for the `InMemoryRetriever` - instance. + METADATA_LABEL_NAME: The metadata field name for 'label' in the retriever. Example: >>> labels_with_examples = [ @@ -101,7 +100,7 @@ def __init__( k=top_k_per_label, retriever_type=RetrieverType.SYMMETRIC, ) - self._filter_search = QdrantSearch(retriever) + self._qdrant_search = QdrantSearch(retriever) def run(self, input: ClassifyInput, logger: DebugLogger) -> ClassifyOutput: self._validate_input_labels(input) @@ -147,7 +146,7 @@ def _label_search( ] ), ) - return self._filter_search.run(search_input, logger) + return self._qdrant_search.run(search_input, logger) def _calculate_scores( self, results_per_label: Sequence[SearchOutput] diff --git a/src/intelligence_layer/use_cases/search/qdrant_search.py b/src/intelligence_layer/use_cases/search/qdrant_search.py index ce78f6a25..5ea492cf7 100644 --- a/src/intelligence_layer/use_cases/search/qdrant_search.py +++ b/src/intelligence_layer/use_cases/search/qdrant_search.py @@ -10,7 +10,7 @@ class QdrantSearchInput(BaseModel): - """The input for a `FilterSearch` task. + """The input for a `QdrantSearch` task. Attributes: query: The text to be searched with. @@ -39,8 +39,8 @@ class QdrantSearch(Task[QdrantSearchInput, SearchOutput]): >>> ) >>> ] >>> retriever = InMemoryRetriever(client, documents) - >>> task = FilterSearch(retriever) - >>> input = FilterSearchInput( + >>> task = QdrantSearch(retriever) + >>> input = QdrantSearchInput( >>> query="When did East and West Germany reunite?" >>> filter=models.Filter( >>> must=[ @@ -51,7 +51,7 @@ class QdrantSearch(Task[QdrantSearchInput, SearchOutput]): >>> ] >>> ) >>> ) - >>> logger = InMemoryLogger(name="Filter Search") + >>> logger = InMemoryLogger(name="Qdrant Search") >>> output = task.run(input, logger) """ diff --git a/tests/use_cases/search/test_qdrant_search.py b/tests/use_cases/search/test_qdrant_search.py index 95784026f..bcc2045d3 100644 --- a/tests/use_cases/search/test_qdrant_search.py +++ b/tests/use_cases/search/test_qdrant_search.py @@ -33,7 +33,9 @@ def in_memory_retriever_documents() -> Sequence[Document]: @fixture -def filter_search(asymmetric_in_memory_retriever: QdrantInMemoryRetriever) -> QdrantSearch: +def filter_search( + asymmetric_in_memory_retriever: QdrantInMemoryRetriever, +) -> QdrantSearch: return QdrantSearch(asymmetric_in_memory_retriever)