diff --git a/integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_document_embedder.py b/integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_document_embedder.py index 6829f0af8..c5dded9f1 100644 --- a/integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_document_embedder.py +++ b/integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_document_embedder.py @@ -28,13 +28,24 @@ class GradientDocumentEmbedder: Usage example: ```python + from haystack_integrations.components.embedders.gradient import GradientDocumentEmbedder + from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever + from haystack import Pipeline + embedder = GradientDocumentEmbedder(model="bge_large") + + documents = [ + Document(content="My name is Jean and I live in Paris."), + Document(content="My name is Mark and I live in Berlin."), + Document(content="My name is Giorgio and I live in Rome."), + ] + p = Pipeline() p.add_component(embedder, name="document_embedder") - p.add_component(instance=GradientDocumentEmbedder( + p.add_component(instance=GradientDocumentEmbedder(), name="document_embedder") p.add_component(instance=DocumentWriter(document_store=InMemoryDocumentStore()), name="document_writer") p.connect("document_embedder", "document_writer") - p.run({"document_embedder": {"documents": documents}}) + p.run(data={"document_embedder": {"documents": documents}}) ``` """ @@ -141,7 +152,7 @@ def run(self, documents: List[Document]): :param documents: A list of Documents to embed. :returns: A dictionary with the following keys: - - documents: The embedded Documents. + - `documents`: The embedded Documents. """ if not isinstance(documents, list) or documents and any(not isinstance(doc, Document) for doc in documents): diff --git a/integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_text_embedder.py b/integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_text_embedder.py index fdd37a17a..a33ad3d40 100644 --- a/integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_text_embedder.py +++ b/integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_text_embedder.py @@ -12,6 +12,10 @@ class GradientTextEmbedder: Usage example: ```python + from haystack_integrations.components.embedders.gradient import GradientTextEmbedder + from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever + from haystack import Pipeline + embedder = GradientTextEmbedder(model="bge_large") p = Pipeline() p.add_component(instance=embedder, name="text_embedder") diff --git a/integrations/gradient/src/haystack_integrations/components/generators/gradient/base.py b/integrations/gradient/src/haystack_integrations/components/generators/gradient/base.py index e3be06a6c..5dee99a5c 100644 --- a/integrations/gradient/src/haystack_integrations/components/generators/gradient/base.py +++ b/integrations/gradient/src/haystack_integrations/components/generators/gradient/base.py @@ -18,6 +18,8 @@ class GradientGenerator: Usage example: ```python + from haystack_integrations.components.generators.gradient import GradientGenerator + llm = GradientGenerator(base_model_slug="llama2-7b-chat") llm.warm_up() print(llm.run(prompt="What is the meaning of life?"))