Skip to content

Commit

Permalink
docs: complete docstring for DocumentJoiner code example (deepset-ai#…
Browse files Browse the repository at this point in the history
…8593)

* initial import

* changing a method to static

* reverting staticmethod
  • Loading branch information
davidsbatista authored Dec 5, 2024
1 parent 2282c26 commit e349a7f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion haystack/components/joiners/document_joiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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})
```
"""

Expand Down

0 comments on commit e349a7f

Please sign in to comment.