From e349a7f2fcbcdfbfda14d4bdd19530c5251110cc Mon Sep 17 00:00:00 2001 From: "David S. Batista" Date: Thu, 5 Dec 2024 15:04:34 +0100 Subject: [PATCH] docs: complete docstring for DocumentJoiner code example (#8593) * initial import * changing a method to static * reverting staticmethod --- haystack/components/joiners/document_joiner.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/haystack/components/joiners/document_joiner.py b/haystack/components/joiners/document_joiner.py index b81af3cde0..103ab1c574 100644 --- a/haystack/components/joiners/document_joiner.py +++ b/haystack/components/joiners/document_joiner.py @@ -54,7 +54,20 @@ class DocumentJoiner: ### Usage example: ```python + from haystack import Pipeline, Document + from haystack.components.embedders import SentenceTransformersTextEmbedder, SentenceTransformersDocumentEmbedder + from haystack.components.joiners import DocumentJoiner + from haystack.components.retrievers import InMemoryBM25Retriever + from haystack.components.retrievers import InMemoryEmbeddingRetriever + from haystack.document_stores.in_memory import InMemoryDocumentStore + document_store = InMemoryDocumentStore() + docs = [Document(content="Paris"), Document(content="Berlin"), Document(content="London")] + embedder = SentenceTransformersDocumentEmbedder(model="sentence-transformers/all-MiniLM-L6-v2") + embedder.warm_up() + docs_embeddings = embedder.run(docs) + document_store.write_documents(docs_embeddings['documents']) + p = Pipeline() p.add_component(instance=InMemoryBM25Retriever(document_store=document_store), name="bm25_retriever") p.add_component( @@ -67,7 +80,7 @@ class DocumentJoiner: p.connect("embedding_retriever", "joiner") p.connect("text_embedder", "embedding_retriever") query = "What is the capital of France?" - p.run(data={"query": query}) + p.run(data={"query": query, "text": query, "top_k": 1}) ``` """