From 2256d7f4c5a1e893b63dac962fc9e46b65513e9a Mon Sep 17 00:00:00 2001 From: MARTRENCHAR Date: Wed, 13 Nov 2024 11:47:24 +0100 Subject: [PATCH] Fix lint errors --- .../components/rankers/fastembed/ranker.py | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py b/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py index 2835e2ca1..2031f7ed9 100644 --- a/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py +++ b/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py @@ -10,24 +10,24 @@ @component class FastembedRanker: """ - Ranks Documents based on their similarity to the query using [Fastembed models](https://qdrant.github.io/fastembed/examples/Supported_Models/). + Ranks Documents based on their similarity to the query using [Fastembed models](https://qdrant.github.io/fastembed/examples/Supported_Models/). - Documents are indexed from most to least semantically relevant to the query. + Documents are indexed from most to least semantically relevant to the query. - Usage example: - ```python - from haystack import Document - from haystack_integrations.components.rankers.fastembed import FastembedRanker + Usage example: + ```python + from haystack import Document + from haystack_integrations.components.rankers.fastembed import FastembedRanker - ranker = FastembedRanker(model_name="Xenova/ms-marco-MiniLM-L-6-v2", top_k=2) + ranker = FastembedRanker(model_name="Xenova/ms-marco-MiniLM-L-6-v2", top_k=2) - docs = [Document(content="Paris"), Document(content="Berlin")] - query = "What is the capital of germany?" - output = ranker.run(query=query, documents=docs) - print(output["documents"][0].content) - - # Berlin - ``` + docs = [Document(content="Paris"), Document(content="Berlin")] + query = "What is the capital of germany?" + output = ranker.run(query=query, documents=docs) + print(output["documents"][0].content) + + # Berlin + ``` """ def __init__( @@ -63,8 +63,9 @@ def __init__( to the Document content. """ if top_k <= 0: - raise ValueError(f"top_k must be > 0, but got {top_k}") - + msg = f"top_k must be > 0, but got {top_k}" + raise ValueError(msg) + self.model_name = model_name self.top_k = top_k self.cache_dir = cache_dir