From 85c9713dacf27b413741d5f85eea96c1f28dd9a2 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Sat, 23 Nov 2024 11:32:09 +0100 Subject: [PATCH 1/2] fix linting --- .../components/embedders/amazon_bedrock/__init__.py | 2 +- .../components/embedders/amazon_bedrock/document_embedder.py | 2 +- .../components/generators/amazon_bedrock/__init__.py | 2 +- .../components/generators/anthropic/__init__.py | 2 +- .../document_stores/azure_ai_search/__init__.py | 2 +- .../components/retrievers/chroma/__init__.py | 2 +- .../components/embedders/cohere/document_embedder.py | 2 +- .../components/generators/cohere/__init__.py | 2 +- .../components/embedders/fastembed/__init__.py | 2 +- .../embedders/fastembed/fastembed_document_embedder.py | 2 +- .../embedders/fastembed/fastembed_sparse_document_embedder.py | 2 +- .../components/rankers/fastembed/ranker.py | 2 +- .../components/generators/google_ai/__init__.py | 2 +- .../components/generators/google_vertex/__init__.py | 2 +- .../instructor_embedders/instructor_document_embedder.py | 2 +- .../components/embedders/jina/document_embedder.py | 2 +- .../components/generators/llama_cpp/__init__.py | 2 +- .../components/embedders/nvidia/__init__.py | 2 +- .../components/embedders/nvidia/document_embedder.py | 2 +- .../nvidia/src/haystack_integrations/utils/nvidia/__init__.py | 2 +- .../components/embedders/optimum/__init__.py | 4 ++-- .../components/embedders/optimum/optimum_document_embedder.py | 2 +- .../components/retrievers/qdrant/__init__.py | 2 +- .../document_stores/weaviate/__init__.py | 2 +- 24 files changed, 25 insertions(+), 25 deletions(-) diff --git a/integrations/amazon_bedrock/src/haystack_integrations/components/embedders/amazon_bedrock/__init__.py b/integrations/amazon_bedrock/src/haystack_integrations/components/embedders/amazon_bedrock/__init__.py index b2efefdc8..2ebd35979 100644 --- a/integrations/amazon_bedrock/src/haystack_integrations/components/embedders/amazon_bedrock/__init__.py +++ b/integrations/amazon_bedrock/src/haystack_integrations/components/embedders/amazon_bedrock/__init__.py @@ -4,4 +4,4 @@ from .document_embedder import AmazonBedrockDocumentEmbedder from .text_embedder import AmazonBedrockTextEmbedder -__all__ = ["AmazonBedrockTextEmbedder", "AmazonBedrockDocumentEmbedder"] +__all__ = ["AmazonBedrockDocumentEmbedder", "AmazonBedrockTextEmbedder"] diff --git a/integrations/amazon_bedrock/src/haystack_integrations/components/embedders/amazon_bedrock/document_embedder.py b/integrations/amazon_bedrock/src/haystack_integrations/components/embedders/amazon_bedrock/document_embedder.py index 1b8fde124..f2906c00d 100755 --- a/integrations/amazon_bedrock/src/haystack_integrations/components/embedders/amazon_bedrock/document_embedder.py +++ b/integrations/amazon_bedrock/src/haystack_integrations/components/embedders/amazon_bedrock/document_embedder.py @@ -236,7 +236,7 @@ def run(self, documents: List[Document]): - `documents`: The `Document`s with the `embedding` field populated. :raises AmazonBedrockInferenceError: If the inference fails. """ - if not isinstance(documents, list) or documents and not isinstance(documents[0], Document): + if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)): msg = ( "AmazonBedrockDocumentEmbedder expects a list of Documents as input." "In case you want to embed a string, please use the AmazonBedrockTextEmbedder." diff --git a/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/__init__.py b/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/__init__.py index 2d33beb42..ab3f0dfd5 100644 --- a/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/__init__.py +++ b/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/__init__.py @@ -4,4 +4,4 @@ from .chat.chat_generator import AmazonBedrockChatGenerator from .generator import AmazonBedrockGenerator -__all__ = ["AmazonBedrockGenerator", "AmazonBedrockChatGenerator"] +__all__ = ["AmazonBedrockChatGenerator", "AmazonBedrockGenerator"] diff --git a/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/__init__.py b/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/__init__.py index 0bd29898e..12c588dc4 100644 --- a/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/__init__.py +++ b/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/__init__.py @@ -5,4 +5,4 @@ from .chat.vertex_chat_generator import AnthropicVertexChatGenerator from .generator import AnthropicGenerator -__all__ = ["AnthropicGenerator", "AnthropicChatGenerator", "AnthropicVertexChatGenerator"] +__all__ = ["AnthropicChatGenerator", "AnthropicGenerator", "AnthropicVertexChatGenerator"] diff --git a/integrations/azure_ai_search/src/haystack_integrations/document_stores/azure_ai_search/__init__.py b/integrations/azure_ai_search/src/haystack_integrations/document_stores/azure_ai_search/__init__.py index ca0ea7554..dcee0e622 100644 --- a/integrations/azure_ai_search/src/haystack_integrations/document_stores/azure_ai_search/__init__.py +++ b/integrations/azure_ai_search/src/haystack_integrations/document_stores/azure_ai_search/__init__.py @@ -4,4 +4,4 @@ from .document_store import DEFAULT_VECTOR_SEARCH, AzureAISearchDocumentStore from .filters import _normalize_filters -__all__ = ["AzureAISearchDocumentStore", "DEFAULT_VECTOR_SEARCH", "_normalize_filters"] +__all__ = ["DEFAULT_VECTOR_SEARCH", "AzureAISearchDocumentStore", "_normalize_filters"] diff --git a/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/__init__.py b/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/__init__.py index 53120c97c..e240ba136 100644 --- a/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/__init__.py +++ b/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/__init__.py @@ -1,3 +1,3 @@ from .retriever import ChromaEmbeddingRetriever, ChromaQueryTextRetriever -__all__ = ["ChromaQueryTextRetriever", "ChromaEmbeddingRetriever"] +__all__ = ["ChromaEmbeddingRetriever", "ChromaQueryTextRetriever"] diff --git a/integrations/cohere/src/haystack_integrations/components/embedders/cohere/document_embedder.py b/integrations/cohere/src/haystack_integrations/components/embedders/cohere/document_embedder.py index 3201168a8..d311662fe 100644 --- a/integrations/cohere/src/haystack_integrations/components/embedders/cohere/document_embedder.py +++ b/integrations/cohere/src/haystack_integrations/components/embedders/cohere/document_embedder.py @@ -146,7 +146,7 @@ def run(self, documents: List[Document]): - `meta`: metadata about the embedding process. :raises TypeError: if the input is not a list of `Documents`. """ - if not isinstance(documents, list) or documents and not isinstance(documents[0], Document): + if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)): msg = ( "CohereDocumentEmbedder expects a list of Documents as input." "In case you want to embed a string, please use the CohereTextEmbedder." diff --git a/integrations/cohere/src/haystack_integrations/components/generators/cohere/__init__.py b/integrations/cohere/src/haystack_integrations/components/generators/cohere/__init__.py index 93c0947e4..7d50682e8 100644 --- a/integrations/cohere/src/haystack_integrations/components/generators/cohere/__init__.py +++ b/integrations/cohere/src/haystack_integrations/components/generators/cohere/__init__.py @@ -4,4 +4,4 @@ from .chat.chat_generator import CohereChatGenerator from .generator import CohereGenerator -__all__ = ["CohereGenerator", "CohereChatGenerator"] +__all__ = ["CohereChatGenerator", "CohereGenerator"] diff --git a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/__init__.py b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/__init__.py index e943a8ca1..d73c29766 100644 --- a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/__init__.py +++ b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/__init__.py @@ -8,7 +8,7 @@ __all__ = [ "FastembedDocumentEmbedder", - "FastembedTextEmbedder", "FastembedSparseDocumentEmbedder", "FastembedSparseTextEmbedder", + "FastembedTextEmbedder", ] diff --git a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py index 8b63582c5..b064173fe 100644 --- a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py +++ b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py @@ -158,7 +158,7 @@ def run(self, documents: List[Document]): :returns: A dictionary with the following keys: - `documents`: List of Documents with each Document's `embedding` field set to the computed embeddings. """ - if not isinstance(documents, list) or documents and not isinstance(documents[0], Document): + if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)): msg = ( "FastembedDocumentEmbedder expects a list of Documents as input. " "In case you want to embed a list of strings, please use the FastembedTextEmbedder." diff --git a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_sparse_document_embedder.py b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_sparse_document_embedder.py index a30d43cf4..fb3df9162 100644 --- a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_sparse_document_embedder.py +++ b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_sparse_document_embedder.py @@ -150,7 +150,7 @@ def run(self, documents: List[Document]): - `documents`: List of Documents with each Document's `sparse_embedding` field set to the computed embeddings. """ - if not isinstance(documents, list) or documents and not isinstance(documents[0], Document): + if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)): msg = ( "FastembedSparseDocumentEmbedder expects a list of Documents as input. " "In case you want to embed a list of strings, please use the FastembedTextEmbedder." 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 8f077a30c..370344df5 100644 --- a/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py +++ b/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py @@ -157,7 +157,7 @@ def run(self, query: str, documents: List[Document], top_k: Optional[int] = None :raises ValueError: If `top_k` is not > 0. """ - if not isinstance(documents, list) or documents and not isinstance(documents[0], Document): + if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)): msg = "FastembedRanker expects a list of Documents as input. " raise TypeError(msg) if query == "": diff --git a/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/__init__.py b/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/__init__.py index 2b77c813f..c62129f9d 100644 --- a/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/__init__.py +++ b/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/__init__.py @@ -4,4 +4,4 @@ from .chat.gemini import GoogleAIGeminiChatGenerator from .gemini import GoogleAIGeminiGenerator -__all__ = ["GoogleAIGeminiGenerator", "GoogleAIGeminiChatGenerator"] +__all__ = ["GoogleAIGeminiChatGenerator", "GoogleAIGeminiGenerator"] diff --git a/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/__init__.py b/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/__init__.py index 07c2a5260..e5f556637 100644 --- a/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/__init__.py +++ b/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/__init__.py @@ -11,8 +11,8 @@ __all__ = [ "VertexAICodeGenerator", - "VertexAIGeminiGenerator", "VertexAIGeminiChatGenerator", + "VertexAIGeminiGenerator", "VertexAIImageCaptioner", "VertexAIImageGenerator", "VertexAIImageQA", diff --git a/integrations/instructor_embedders/src/haystack_integrations/components/embedders/instructor_embedders/instructor_document_embedder.py b/integrations/instructor_embedders/src/haystack_integrations/components/embedders/instructor_embedders/instructor_document_embedder.py index 734798f46..c05c37733 100644 --- a/integrations/instructor_embedders/src/haystack_integrations/components/embedders/instructor_embedders/instructor_document_embedder.py +++ b/integrations/instructor_embedders/src/haystack_integrations/components/embedders/instructor_embedders/instructor_document_embedder.py @@ -158,7 +158,7 @@ def run(self, documents: List[Document]): param documents: A list of Documents to embed. """ - if not isinstance(documents, list) or documents and not isinstance(documents[0], Document): + if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)): msg = ( "InstructorDocumentEmbedder expects a list of Documents as input. " "In case you want to embed a list of strings, please use the InstructorTextEmbedder." diff --git a/integrations/jina/src/haystack_integrations/components/embedders/jina/document_embedder.py b/integrations/jina/src/haystack_integrations/components/embedders/jina/document_embedder.py index 715092b8a..103132faf 100644 --- a/integrations/jina/src/haystack_integrations/components/embedders/jina/document_embedder.py +++ b/integrations/jina/src/haystack_integrations/components/embedders/jina/document_embedder.py @@ -200,7 +200,7 @@ def run(self, documents: List[Document]): - `meta`: A dictionary with metadata including the model name and usage statistics. :raises TypeError: If the input is not a list of Documents. """ - if not isinstance(documents, list) or documents and not isinstance(documents[0], Document): + if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)): msg = ( "JinaDocumentEmbedder expects a list of Documents as input." "In case you want to embed a string, please use the JinaTextEmbedder." diff --git a/integrations/llama_cpp/src/haystack_integrations/components/generators/llama_cpp/__init__.py b/integrations/llama_cpp/src/haystack_integrations/components/generators/llama_cpp/__init__.py index 10b20d363..a85dbfd88 100644 --- a/integrations/llama_cpp/src/haystack_integrations/components/generators/llama_cpp/__init__.py +++ b/integrations/llama_cpp/src/haystack_integrations/components/generators/llama_cpp/__init__.py @@ -5,4 +5,4 @@ from .chat.chat_generator import LlamaCppChatGenerator from .generator import LlamaCppGenerator -__all__ = ["LlamaCppGenerator", "LlamaCppChatGenerator"] +__all__ = ["LlamaCppChatGenerator", "LlamaCppGenerator"] diff --git a/integrations/nvidia/src/haystack_integrations/components/embedders/nvidia/__init__.py b/integrations/nvidia/src/haystack_integrations/components/embedders/nvidia/__init__.py index 827ad7dc6..c6ecea7b1 100644 --- a/integrations/nvidia/src/haystack_integrations/components/embedders/nvidia/__init__.py +++ b/integrations/nvidia/src/haystack_integrations/components/embedders/nvidia/__init__.py @@ -6,4 +6,4 @@ from .text_embedder import NvidiaTextEmbedder from .truncate import EmbeddingTruncateMode -__all__ = ["NvidiaDocumentEmbedder", "NvidiaTextEmbedder", "EmbeddingTruncateMode"] +__all__ = ["EmbeddingTruncateMode", "NvidiaDocumentEmbedder", "NvidiaTextEmbedder"] diff --git a/integrations/nvidia/src/haystack_integrations/components/embedders/nvidia/document_embedder.py b/integrations/nvidia/src/haystack_integrations/components/embedders/nvidia/document_embedder.py index 6519efbab..b417fa737 100644 --- a/integrations/nvidia/src/haystack_integrations/components/embedders/nvidia/document_embedder.py +++ b/integrations/nvidia/src/haystack_integrations/components/embedders/nvidia/document_embedder.py @@ -242,7 +242,7 @@ def run(self, documents: List[Document]): if not self._initialized: msg = "The embedding model has not been loaded. Please call warm_up() before running." raise RuntimeError(msg) - elif not isinstance(documents, list) or documents and not isinstance(documents[0], Document): + elif not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)): msg = ( "NvidiaDocumentEmbedder expects a list of Documents as input." "In case you want to embed a string, please use the NvidiaTextEmbedder." diff --git a/integrations/nvidia/src/haystack_integrations/utils/nvidia/__init__.py b/integrations/nvidia/src/haystack_integrations/utils/nvidia/__init__.py index f08cda6cd..0b69c8d24 100644 --- a/integrations/nvidia/src/haystack_integrations/utils/nvidia/__init__.py +++ b/integrations/nvidia/src/haystack_integrations/utils/nvidia/__init__.py @@ -5,4 +5,4 @@ from .nim_backend import Model, NimBackend from .utils import is_hosted, url_validation -__all__ = ["NimBackend", "Model", "is_hosted", "url_validation"] +__all__ = ["Model", "NimBackend", "is_hosted", "url_validation"] diff --git a/integrations/optimum/src/haystack_integrations/components/embedders/optimum/__init__.py b/integrations/optimum/src/haystack_integrations/components/embedders/optimum/__init__.py index 02e56b34c..ec0ecdef1 100644 --- a/integrations/optimum/src/haystack_integrations/components/embedders/optimum/__init__.py +++ b/integrations/optimum/src/haystack_integrations/components/embedders/optimum/__init__.py @@ -10,10 +10,10 @@ __all__ = [ "OptimumDocumentEmbedder", - "OptimumEmbedderOptimizationMode", "OptimumEmbedderOptimizationConfig", + "OptimumEmbedderOptimizationMode", "OptimumEmbedderPooling", - "OptimumEmbedderQuantizationMode", "OptimumEmbedderQuantizationConfig", + "OptimumEmbedderQuantizationMode", "OptimumTextEmbedder", ] diff --git a/integrations/optimum/src/haystack_integrations/components/embedders/optimum/optimum_document_embedder.py b/integrations/optimum/src/haystack_integrations/components/embedders/optimum/optimum_document_embedder.py index 27f533430..2016f3ffe 100644 --- a/integrations/optimum/src/haystack_integrations/components/embedders/optimum/optimum_document_embedder.py +++ b/integrations/optimum/src/haystack_integrations/components/embedders/optimum/optimum_document_embedder.py @@ -208,7 +208,7 @@ def run(self, documents: List[Document]): if not self._initialized: msg = "The embedding model has not been loaded. Please call warm_up() before running." raise RuntimeError(msg) - if not isinstance(documents, list) or documents and not isinstance(documents[0], Document): + if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)): msg = ( "OptimumDocumentEmbedder expects a list of Documents as input." " In case you want to embed a string, please use the OptimumTextEmbedder." diff --git a/integrations/qdrant/src/haystack_integrations/components/retrievers/qdrant/__init__.py b/integrations/qdrant/src/haystack_integrations/components/retrievers/qdrant/__init__.py index ed6422bfe..bbb7251d0 100644 --- a/integrations/qdrant/src/haystack_integrations/components/retrievers/qdrant/__init__.py +++ b/integrations/qdrant/src/haystack_integrations/components/retrievers/qdrant/__init__.py @@ -4,4 +4,4 @@ from .retriever import QdrantEmbeddingRetriever, QdrantHybridRetriever, QdrantSparseEmbeddingRetriever -__all__ = ("QdrantEmbeddingRetriever", "QdrantSparseEmbeddingRetriever", "QdrantHybridRetriever") +__all__ = ("QdrantEmbeddingRetriever", "QdrantHybridRetriever", "QdrantSparseEmbeddingRetriever") diff --git a/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/__init__.py b/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/__init__.py index 87c7b6b01..db084502b 100644 --- a/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/__init__.py +++ b/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/__init__.py @@ -5,10 +5,10 @@ from .document_store import WeaviateDocumentStore __all__ = [ - "WeaviateDocumentStore", "AuthApiKey", "AuthBearerToken", "AuthClientCredentials", "AuthClientPassword", "AuthCredentials", + "WeaviateDocumentStore", ] From 60ae68782beac55b929f7efdc81b4c680eb13f94 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Sat, 23 Nov 2024 11:38:00 +0100 Subject: [PATCH 2/2] vertex fix --- integrations/google_vertex/tests/chat/test_gemini.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integrations/google_vertex/tests/chat/test_gemini.py b/integrations/google_vertex/tests/chat/test_gemini.py index 73c99fe2f..614b83909 100644 --- a/integrations/google_vertex/tests/chat/test_gemini.py +++ b/integrations/google_vertex/tests/chat/test_gemini.py @@ -161,13 +161,13 @@ def test_to_dict_with_params(_mock_vertexai_init, _mock_generative_model): "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { - "type_": "OBJECT", + "type": "OBJECT", "properties": { "location": { - "type_": "STRING", + "type": "STRING", "description": "The city and state, e.g. San Francisco, CA", }, - "unit": {"type_": "STRING", "enum": ["celsius", "fahrenheit"]}, + "unit": {"type": "STRING", "enum": ["celsius", "fahrenheit"]}, }, "required": ["location"], "property_ordering": ["location", "unit"],