diff --git a/integrations/cohere/tests/test_cohere_chat_generator.py b/integrations/cohere/tests/test_cohere_chat_generator.py index f1d15db08..622797f5e 100644 --- a/integrations/cohere/tests/test_cohere_chat_generator.py +++ b/integrations/cohere/tests/test_cohere_chat_generator.py @@ -169,6 +169,7 @@ def test_from_dict(self, monkeypatch): @pytest.mark.unit def test_from_dict_fail_wo_env_var(self, monkeypatch): monkeypatch.delenv("COHERE_API_KEY", raising=False) + monkeypatch.delenv("CO_API_KEY", raising=False) data = { "type": "haystack_integrations.components.generators.cohere.chat.chat_generator.CohereChatGenerator", "init_parameters": { diff --git a/integrations/deepeval/pydoc/config.yml b/integrations/deepeval/pydoc/config.yml index 9ffaa7b80..1c69c9f8c 100644 --- a/integrations/deepeval/pydoc/config.yml +++ b/integrations/deepeval/pydoc/config.yml @@ -19,9 +19,9 @@ renderer: type: haystack_pydoc_tools.renderers.ReadmePreviewRenderer excerpt: DeepEval integration for Haystack category_slug: haystack-integrations - title: Chroma + title: DeepEval slug: integrations-deepeval - order: 1 + order: 45 markdown: descriptive_class_title: false descriptive_module_title: true diff --git a/integrations/fastembed/pydoc/config.yml b/integrations/fastembed/pydoc/config.yml index 3e491eac2..10b30e507 100644 --- a/integrations/fastembed/pydoc/config.yml +++ b/integrations/fastembed/pydoc/config.yml @@ -3,8 +3,8 @@ loaders: search_path: [../src] modules: [ - "haystack_integrations.components.embedders.fastembed", - "haystack_integrations.components.embedders.fastembed.embedding_backend", + "haystack_integrations.components.embedders.fastembed.fastembed_document_embedder", + "haystack_integrations.components.embedders.fastembed.fastembed_text_embedder", ] ignore_when_discovered: ["__init__"] processors: @@ -17,11 +17,11 @@ processors: - type: crossref renderer: type: haystack_pydoc_tools.renderers.ReadmePreviewRenderer - excerpt: Embedders integration for Haystack + excerpt: FastEmbed integration for Haystack category_slug: haystack-integrations - title: Embedders + title: FastEmbed slug: fastembed-embedders - order: 300 + order: 55 markdown: descriptive_class_title: false descriptive_module_title: true diff --git a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py index 392f9d32d..ee51283e6 100644 --- a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py +++ b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py @@ -38,5 +38,6 @@ def __init__( self.model = TextEmbedding(model_name=model_name) def embed(self, data: List[List[str]], **kwargs) -> List[List[float]]: - embeddings = list(self.model.embed(data, **kwargs)) + # the embed method returns a Iterable[np.ndarray], so we convert it to a list of lists + embeddings = [np_array.tolist() for np_array in self.model.embed(data, **kwargs)] return embeddings 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 03dc301b9..b913b0de4 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 @@ -142,6 +142,6 @@ def run(self, documents: List[Document]): ) for doc, emb in zip(documents, embeddings): - doc.embedding = list(emb) + doc.embedding = emb return {"documents": documents} diff --git a/integrations/fastembed/tests/test_fastembed_document_embedder.py b/integrations/fastembed/tests/test_fastembed_document_embedder.py index 6dd1b6e52..597999354 100644 --- a/integrations/fastembed/tests/test_fastembed_document_embedder.py +++ b/integrations/fastembed/tests/test_fastembed_document_embedder.py @@ -248,4 +248,4 @@ def test_run(self): assert isinstance(embedding, list) assert len(embedding) == 384 - assert all(isinstance(emb.item(), float) for emb in embedding) + assert all(isinstance(emb, float) for emb in embedding) diff --git a/integrations/fastembed/tests/test_fastembed_text_embedder.py b/integrations/fastembed/tests/test_fastembed_text_embedder.py index 465f17976..3a7588263 100644 --- a/integrations/fastembed/tests/test_fastembed_text_embedder.py +++ b/integrations/fastembed/tests/test_fastembed_text_embedder.py @@ -186,4 +186,4 @@ def test_run(self): assert isinstance(embedding, list) assert len(embedding) == 384 - assert all(isinstance(emb.item(), float) for emb in embedding) + assert all(isinstance(emb, float) for emb in embedding) diff --git a/integrations/instructor_embedders/pydoc/config.yml b/integrations/instructor_embedders/pydoc/config.yml index cc16a72f7..b9c6bc76b 100644 --- a/integrations/instructor_embedders/pydoc/config.yml +++ b/integrations/instructor_embedders/pydoc/config.yml @@ -3,8 +3,8 @@ loaders: search_path: [../src] modules: [ - "haystack_integrations.components.embedders.instructor_embedders", - "haystack_integrations.components.embedders.instructor_embedders.embedding_backend", + "haystack_integrations.components.embedders.instructor_embedders.instructor_document_embedder", + "haystack_integrations.components.embedders.instructor_embedders.instructor_text_embedder", ] ignore_when_discovered: ["__init__"] processors: @@ -17,9 +17,9 @@ processors: - type: crossref renderer: type: haystack_pydoc_tools.renderers.ReadmePreviewRenderer - excerpt: Embedders integration for Haystack + excerpt: Instructor embedders integration for Haystack category_slug: haystack-integrations - title: Embedders + title: Instructor Embedders slug: integrations-instructor-embedders order: 90 markdown: diff --git a/integrations/jina/pydoc/config.yml b/integrations/jina/pydoc/config.yml index 8d4943d5f..5c641c6dc 100644 --- a/integrations/jina/pydoc/config.yml +++ b/integrations/jina/pydoc/config.yml @@ -1,7 +1,11 @@ loaders: - type: haystack_pydoc_tools.loaders.CustomPythonLoader search_path: [../src] - modules: ["haystack_integrations.components.embedders.jina"] + modules: + [ + "haystack_integrations.components.embedders.jina.document_embedder", + "haystack_integrations.components.embedders.jina.text_embedder", + ] ignore_when_discovered: ["__init__"] processors: - type: filter diff --git a/integrations/ollama/src/haystack_integrations/components/generators/ollama/generator.py b/integrations/ollama/src/haystack_integrations/components/generators/ollama/generator.py index 55bd65d8a..321eab9f3 100644 --- a/integrations/ollama/src/haystack_integrations/components/generators/ollama/generator.py +++ b/integrations/ollama/src/haystack_integrations/components/generators/ollama/generator.py @@ -1,7 +1,10 @@ -from typing import Any, Dict, List, Optional +import json +from typing import Any, Callable, Dict, List, Optional import requests -from haystack import component +from haystack import component, default_from_dict, default_to_dict +from haystack.components.generators.utils import deserialize_callback_handler, serialize_callback_handler +from haystack.dataclasses import StreamingChunk from requests import Response @@ -21,6 +24,7 @@ def __init__( template: Optional[str] = None, raw: bool = False, timeout: int = 120, + streaming_callback: Optional[Callable[[StreamingChunk], None]] = None, ): """ :param model: The name of the model to use. The model should be available in the running Ollama instance. @@ -36,6 +40,8 @@ def __init__( if you are specifying a full templated prompt in your API request. :param timeout: The number of seconds before throwing a timeout error from the Ollama API. Default is 120 seconds. + :param streaming_callback: A callback function that is called when a new token is received from the stream. + The callback function accepts StreamingChunk as an argument. """ self.timeout = timeout self.raw = raw @@ -44,8 +50,40 @@ def __init__( self.model = model self.url = url self.generation_kwargs = generation_kwargs or {} + self.streaming_callback = streaming_callback - def _create_json_payload(self, prompt: str, generation_kwargs=None) -> Dict[str, Any]: + def to_dict(self) -> Dict[str, Any]: + """ + Serialize this component to a dictionary. + :return: The serialized component as a dictionary. + """ + callback_name = serialize_callback_handler(self.streaming_callback) if self.streaming_callback else None + return default_to_dict( + self, + timeout=self.timeout, + raw=self.raw, + template=self.template, + system_prompt=self.system_prompt, + model=self.model, + url=self.url, + generation_kwargs=self.generation_kwargs, + streaming_callback=callback_name, + ) + + @classmethod + def from_dict(cls, data: Dict[str, Any]) -> "OllamaGenerator": + """ + Deserialize this component from a dictionary. + :param data: The dictionary representation of this component. + :return: The deserialized component instance. + """ + init_params = data.get("init_parameters", {}) + serialized_callback_handler = init_params.get("streaming_callback") + if serialized_callback_handler: + data["init_parameters"]["streaming_callback"] = deserialize_callback_handler(serialized_callback_handler) + return default_from_dict(cls, data) + + def _create_json_payload(self, prompt: str, stream: bool, generation_kwargs=None) -> Dict[str, Any]: """ Returns a dictionary of JSON arguments for a POST request to an Ollama service. :param prompt: The prompt to generate a response for. @@ -58,19 +96,20 @@ def _create_json_payload(self, prompt: str, generation_kwargs=None) -> Dict[str, return { "prompt": prompt, "model": self.model, - "stream": False, + "stream": stream, "raw": self.raw, "template": self.template, "system": self.system_prompt, "options": generation_kwargs, } - def _convert_to_haystack_response(self, ollama_response: Response) -> Dict[str, List[Any]]: + def _convert_to_response(self, ollama_response: Response) -> Dict[str, List[Any]]: """ Convert a response from the Ollama API to the required Haystack format. :param ollama_response: A response (requests library) from the Ollama API. :return: A dictionary of the returned responses and metadata. """ + resp_dict = ollama_response.json() replies = [resp_dict["response"]] @@ -78,6 +117,46 @@ def _convert_to_haystack_response(self, ollama_response: Response) -> Dict[str, return {"replies": replies, "meta": [meta]} + def _convert_to_streaming_response(self, chunks: List[StreamingChunk]) -> Dict[str, List[Any]]: + """ + Convert a list of chunks response required Haystack format. + :param chunks: List of StreamingChunks + :return: A dictionary of the returned responses and metadata. + """ + + replies = ["".join([c.content for c in chunks])] + meta = {key: value for key, value in chunks[0].meta.items() if key != "response"} + + return {"replies": replies, "meta": [meta]} + + def _handle_streaming_response(self, response) -> List[StreamingChunk]: + """Handles Streaming response case + + :param response: streaming response from ollama api. + :return: The List[StreamingChunk]. + """ + chunks: List[StreamingChunk] = [] + for chunk in response.iter_lines(): + chunk_delta: StreamingChunk = self._build_chunk(chunk) + chunks.append(chunk_delta) + if self.streaming_callback is not None: + self.streaming_callback(chunk_delta) + return chunks + + def _build_chunk(self, chunk_response: Any) -> StreamingChunk: + """ + Converts the response from the Ollama API to a StreamingChunk. + :param chunk: The chunk returned by the Ollama API. + :return: The StreamingChunk. + """ + decoded_chunk = json.loads(chunk_response.decode("utf-8")) + + content = decoded_chunk["response"] + meta = {key: value for key, value in decoded_chunk.items() if key != "response"} + + chunk_message = StreamingChunk(content, meta) + return chunk_message + @component.output_types(replies=List[str], metadata=List[Dict[str, Any]]) def run( self, @@ -94,11 +173,17 @@ def run( """ generation_kwargs = {**self.generation_kwargs, **(generation_kwargs or {})} - json_payload = self._create_json_payload(prompt, generation_kwargs) + stream = self.streaming_callback is not None + + json_payload = self._create_json_payload(prompt, stream, generation_kwargs) - response = requests.post(url=self.url, json=json_payload, timeout=self.timeout) + response = requests.post(url=self.url, json=json_payload, timeout=self.timeout, stream=stream) # throw error on unsuccessful response response.raise_for_status() - return self._convert_to_haystack_response(response) + if stream: + chunks: List[StreamingChunk] = self._handle_streaming_response(response) + return self._convert_to_streaming_response(chunks) + + return self._convert_to_response(response) diff --git a/integrations/ollama/tests/test_generator.py b/integrations/ollama/tests/test_generator.py index 0403516ce..4af2bdb82 100644 --- a/integrations/ollama/tests/test_generator.py +++ b/integrations/ollama/tests/test_generator.py @@ -2,7 +2,11 @@ # # SPDX-License-Identifier: Apache-2.0 +from typing import Any + import pytest +from haystack.components.generators.utils import print_streaming_chunk +from haystack.dataclasses import StreamingChunk from haystack_integrations.components.generators.ollama import OllamaGenerator from requests import HTTPError @@ -42,16 +46,20 @@ def test_init_default(self): assert component.template is None assert component.raw is False assert component.timeout == 120 + assert component.streaming_callback is None def test_init(self): + def callback(x: StreamingChunk): + x.content = "" + component = OllamaGenerator( model="llama2", url="http://my-custom-endpoint:11434/api/generate", generation_kwargs={"temperature": 0.5}, system_prompt="You are Luigi from Super Mario Bros.", timeout=5, + streaming_callback=callback, ) - assert component.model == "llama2" assert component.url == "http://my-custom-endpoint:11434/api/generate" assert component.generation_kwargs == {"temperature": 0.5} @@ -59,6 +67,65 @@ def test_init(self): assert component.template is None assert component.raw is False assert component.timeout == 5 + assert component.streaming_callback == callback + + component = OllamaGenerator() + data = component.to_dict() + assert data == { + "type": "haystack_integrations.components.generators.ollama.generator.OllamaGenerator", + "init_parameters": { + "timeout": 120, + "raw": False, + "template": None, + "system_prompt": None, + "model": "orca-mini", + "url": "http://localhost:11434/api/generate", + "streaming_callback": None, + "generation_kwargs": {}, + }, + } + + def test_to_dict_with_parameters(self): + component = OllamaGenerator( + model="llama2", + streaming_callback=print_streaming_chunk, + url="going_to_51_pegasi_b_for_weekend", + generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"}, + ) + data = component.to_dict() + assert data == { + "type": "haystack_integrations.components.generators.ollama.generator.OllamaGenerator", + "init_parameters": { + "timeout": 120, + "raw": False, + "template": None, + "system_prompt": None, + "model": "llama2", + "url": "going_to_51_pegasi_b_for_weekend", + "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk", + "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"}, + }, + } + + def test_from_dict(self): + data = { + "type": "haystack_integrations.components.generators.ollama.generator.OllamaGenerator", + "init_parameters": { + "timeout": 120, + "raw": False, + "template": None, + "system_prompt": None, + "model": "llama2", + "url": "going_to_51_pegasi_b_for_weekend", + "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk", + "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"}, + }, + } + component = OllamaGenerator.from_dict(data) + assert component.model == "llama2" + assert component.streaming_callback is print_streaming_chunk + assert component.url == "going_to_51_pegasi_b_for_weekend" + assert component.generation_kwargs == {"max_tokens": 10, "some_test_param": "test-params"} @pytest.mark.parametrize( "configuration", @@ -79,16 +146,17 @@ def test_init(self): }, ], ) - def test_create_json_payload(self, configuration): + @pytest.mark.parametrize("stream", [True, False]) + def test_create_json_payload(self, configuration: dict[str, Any], stream: bool): prompt = "hello" component = OllamaGenerator(**configuration) - observed = component._create_json_payload(prompt=prompt) + observed = component._create_json_payload(prompt=prompt, stream=stream) expected = { "prompt": prompt, "model": configuration["model"], - "stream": False, + "stream": stream, "system": configuration["system_prompt"], "raw": configuration["raw"], "template": configuration["template"], @@ -96,3 +164,25 @@ def test_create_json_payload(self, configuration): } assert observed == expected + + @pytest.mark.integration + def test_ollama_generator_run_streaming(self): + class Callback: + def __init__(self): + self.responses = "" + self.count_calls = 0 + + def __call__(self, chunk): + self.responses += chunk.content + self.count_calls += 1 + return chunk + + callback = Callback() + component = OllamaGenerator(streaming_callback=callback) + results = component.run(prompt="What's the capital of Netherlands?") + + assert len(results["replies"]) == 1 + assert "Amsterdam" in results["replies"][0] + assert len(results["meta"]) == 1 + assert callback.responses == results["replies"][0] + assert callback.count_calls > 1 diff --git a/integrations/pinecone/examples/example.py b/integrations/pinecone/examples/example.py new file mode 100644 index 000000000..b2a534452 --- /dev/null +++ b/integrations/pinecone/examples/example.py @@ -0,0 +1,50 @@ +# Install the Pinecone integration, Haystack will come as a dependency +# Install also some optional dependencies needed for Markdown conversion and text embedding +# pip install -U pinecone-haystack markdown-it-py mdit_plain "sentence-transformers>=2.2.0" + +# Download some markdown files to index +# git clone https://github.com/anakin87/neural-search-pills + + +# Create the indexing Pipeline and index some documents + +import glob + +from haystack import Pipeline +from haystack.components.converters import MarkdownToDocument +from haystack.components.embedders import SentenceTransformersDocumentEmbedder, SentenceTransformersTextEmbedder +from haystack.components.preprocessors import DocumentSplitter +from haystack.components.writers import DocumentWriter +from pinecone_haystack import PineconeDocumentStore +from pinecone_haystack.dense_retriever import PineconeEmbeddingRetriever + +file_paths = glob.glob("neural-search-pills/pills/*.md") + +document_store = PineconeDocumentStore( + api_key="YOUR-PINECONE-API-KEY", environment="gcp-starter", index="default", namespace="default", dimension=768 +) + +indexing = Pipeline() +indexing.add_component("converter", MarkdownToDocument()) +indexing.add_component("splitter", DocumentSplitter(split_by="sentence", split_length=2)) +indexing.add_component("embedder", SentenceTransformersDocumentEmbedder()) +indexing.add_component("writer", DocumentWriter(document_store)) +indexing.connect("converter", "splitter") +indexing.connect("splitter", "embedder") +indexing.connect("embedder", "writer") + +indexing.run({"converter": {"sources": file_paths}}) + + +# Create the querying Pipeline and try a query + +querying = Pipeline() +querying.add_component("embedder", SentenceTransformersTextEmbedder()) +querying.add_component("retriever", PineconeEmbeddingRetriever(document_store=document_store, top_k=3)) +querying.connect("embedder", "retriever") + +results = querying.run({"embedder": {"text": "What is Question Answering?"}}) + +for doc in results["retriever"]["documents"]: + print(doc) + print("-" * 10) diff --git a/integrations/pinecone/examples/pinecone_documentstore_example.ipynb b/integrations/pinecone/examples/pinecone_documentstore_example.ipynb deleted file mode 100644 index 70849836b..000000000 --- a/integrations/pinecone/examples/pinecone_documentstore_example.ipynb +++ /dev/null @@ -1,1298 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \"Open\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "TFIFYm41SS8C" - }, - "outputs": [], - "source": [ - "# Install the Pinecone integration, Haystack will come as a dependency\n", - "# Install also some optional dependencies needed for Markdown conversion and text embedding\n", - "!pip install -U pinecone-haystack markdown-it-py mdit_plain \"sentence-transformers>=2.2.0\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "4sTKYa3qbRAi", - "outputId": "7e8dcbb9-b330-4dab-8516-0caf0520b315" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Cloning into 'neural-search-pills'...\n", - "remote: Enumerating objects: 190, done.\u001b[K\n", - "remote: Counting objects: 100% (190/190), done.\u001b[K\n", - "remote: Compressing objects: 100% (136/136), done.\u001b[K\n", - "remote: Total 190 (delta 97), reused 130 (delta 51), pack-reused 0\u001b[K\n", - "Receiving objects: 100% (190/190), 1.38 MiB | 21.77 MiB/s, done.\n", - "Resolving deltas: 100% (97/97), done.\n" - ] - } - ], - "source": [ - "# Download some markdown files to index\n", - "!git clone https://github.com/anakin87/neural-search-pills" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 153, - "referenced_widgets": [ - "c46e6d0699ff4fbcb8012b7076f5017d", - "5d94db6d00fb4d1abfbaa02f79bdeb78", - "98fce152d7cd45408bd5151574908310", - "3589c7ca39324b359c2378b944974669", - "b7d283c62ebc4199bc2cd6e3bfcb94bc", - "e706a6825bfe4735a0b83eb0dba20286", - "653f00da627740c39b740cd1bdb9e5ff", - "4fbcba61b6724cfc9c174a4b5c4fdf01", - "ed89a5c30ca24d45af85a8a5a61fae04", - "1a423d196704471481ed04a31e22e428", - "c641f6f19bd24af7874805097002dace", - "da90aa6e98de4e80a38a205d40695dcc", - "522ddaca7d26497d8e84a9be785f2222", - "a4c7565d2e5a4ac0aaa9bef88d8cc25f", - "efbd19a1674f4a6b8322ecf1a2e11591", - "fef14c506fef4ba5bc0c65e541e918b6", - "e2fe8960681b4c918eaedc6952e2534f", - "4d37fc2fea964cd590422097ab9a44bd", - "b2f99035deec45b187fe85813fb5bef4", - "e2238770d45047e998719cfb0ced7f2b", - "444ae4a1444b4f74ab45ca56aa8da8dc", - "9f22449bf9ba4ca0be6ad93656fed1d7" - ] - }, - "id": "CacG5dsTTT8B", - "outputId": "afac15af-7b51-4d7c-a301-004cbf333e9a" - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Converting markdown files to Documents: 100%|██████████| 14/14 [00:00<00:00, 163.72it/s]\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "c46e6d0699ff4fbcb8012b7076f5017d", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Batches: 0%| | 0/5 [00:00 Dict[str, Any]: ) @classmethod - def from_dict(cls, data: Dict[str, Any]) -> "PineconeDenseRetriever": + def from_dict(cls, data: Dict[str, Any]) -> "PineconeEmbeddingRetriever": data["init_parameters"]["document_store"] = default_from_dict( PineconeDocumentStore, data["init_parameters"]["document_store"] ) diff --git a/integrations/pinecone/tests/test_dense_retriever.py b/integrations/pinecone/tests/test_emebedding_retriever.py similarity index 89% rename from integrations/pinecone/tests/test_dense_retriever.py rename to integrations/pinecone/tests/test_emebedding_retriever.py index e0f6dc375..d2d3c8546 100644 --- a/integrations/pinecone/tests/test_dense_retriever.py +++ b/integrations/pinecone/tests/test_emebedding_retriever.py @@ -5,13 +5,13 @@ from haystack.dataclasses import Document -from haystack_integrations.components.retrievers.pinecone import PineconeDenseRetriever +from haystack_integrations.components.retrievers.pinecone import PineconeEmbeddingRetriever from haystack_integrations.document_stores.pinecone import PineconeDocumentStore def test_init_default(): mock_store = Mock(spec=PineconeDocumentStore) - retriever = PineconeDenseRetriever(document_store=mock_store) + retriever = PineconeEmbeddingRetriever(document_store=mock_store) assert retriever.document_store == mock_store assert retriever.filters == {} assert retriever.top_k == 10 @@ -28,10 +28,10 @@ def test_to_dict(mock_pinecone): batch_size=50, dimension=512, ) - retriever = PineconeDenseRetriever(document_store=document_store) + retriever = PineconeEmbeddingRetriever(document_store=document_store) res = retriever.to_dict() assert res == { - "type": "haystack_integrations.components.retrievers.pinecone.dense_retriever.PineconeDenseRetriever", + "type": "haystack_integrations.components.retrievers.pinecone.embedding_retriever.PineconeEmbeddingRetriever", "init_parameters": { "document_store": { "init_parameters": { @@ -52,7 +52,7 @@ def test_to_dict(mock_pinecone): @patch("haystack_integrations.document_stores.pinecone.document_store.pinecone") def test_from_dict(mock_pinecone, monkeypatch): data = { - "type": "haystack_integrations.components.retrievers.pinecone.dense_retriever.PineconeDenseRetriever", + "type": "haystack_integrations.components.retrievers.pinecone.embedding_retriever.PineconeEmbeddingRetriever", "init_parameters": { "document_store": { "init_parameters": { @@ -71,7 +71,7 @@ def test_from_dict(mock_pinecone, monkeypatch): mock_pinecone.Index.return_value.describe_index_stats.return_value = {"dimension": 512} monkeypatch.setenv("PINECONE_API_KEY", "test-key") - retriever = PineconeDenseRetriever.from_dict(data) + retriever = PineconeEmbeddingRetriever.from_dict(data) document_store = retriever.document_store assert document_store.environment == "gcp-starter" @@ -87,7 +87,7 @@ def test_from_dict(mock_pinecone, monkeypatch): def test_run(): mock_store = Mock(spec=PineconeDocumentStore) mock_store._embedding_retrieval.return_value = [Document(content="Test doc", embedding=[0.1, 0.2])] - retriever = PineconeDenseRetriever(document_store=mock_store) + retriever = PineconeEmbeddingRetriever(document_store=mock_store) res = retriever.run(query_embedding=[0.5, 0.7]) mock_store._embedding_retrieval.assert_called_once_with( query_embedding=[0.5, 0.7], diff --git a/integrations/uptrain/pydoc/config.yml b/integrations/uptrain/pydoc/config.yml index c2e7f8da0..0da9ecd16 100644 --- a/integrations/uptrain/pydoc/config.yml +++ b/integrations/uptrain/pydoc/config.yml @@ -21,7 +21,7 @@ renderer: category_slug: haystack-integrations title: UpTrain slug: integrations-uptrain - order: 1 + order: 175 markdown: descriptive_class_title: false descriptive_module_title: true