Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradient - update page for new secrets mgmt #177

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions integrations/gradient.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ from haystack.components.writers import DocumentWriter

from haystack_integrations.components.embedders.gradient import GradientDocumentEmbedder

os.environ["GRADIENT_ACCESS_TOKEN"] = "Your Gradient Access Token"
os.environ["GRADIENT_WORKSPACE_ID"] = "Your Gradient Workspace id: "
os.environ["GRADIENT_ACCESS_TOKEN"] = "YOUR-GRADIENT-ACCESS-TOKEN"
os.environ["GRADIENT_WORKSPACE_ID"] = "YOUR-GRADIENT-WORKSPACE-ID"

documents = [
Document(content="My name is Jean and I live in Paris."),
Expand All @@ -67,6 +67,8 @@ indexing_pipeline.run({"document_embedder": {"documents": documents}})
You can use embedding models with `GradientTextEmbedder` and generative models with `GradientGenerator`. These two are commonly used together in a query pipeline such as a retrievel-augmented generative (RAG) pipeline such as the one below.

```python
import os

from haystack.components.builders.answer_builder import AnswerBuilder
from haystack.components.builders.prompt_builder import PromptBuilder
from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever
Expand All @@ -85,12 +87,13 @@ Given these documents, answer the question.\nDocuments:
\nAnswer:
"""

gradient_access_token = os.environ.get("GRADIENT_ACCESS_TOKEN")
os.environ["GRADIENT_ACCESS_TOKEN"] = "YOUR-GRADIENT-ACCESS-TOKEN"
os.environ["GRADIENT_WORKSPACE_ID"] = "YOUR-GRADIENT-WORKSPACE-ID"

retriever = InMemoryEmbeddingRetriever(document_store)
prompt_builder = PromptBuilder(template=prompt_template)
embedder = GradientTextEmbedder(access_token=gradient_access_token)
generator = GradientGenerator(access_token=gradient_access_token, base_model_slug="llama2-7b-chat")
embedder = GradientTextEmbedder()
generator = GradientGenerator(base_model_slug="llama2-7b-chat")

rag_pipeline = Pipeline()
rag_pipeline.add_component(instance=embedder, name="text_embedder")
Expand All @@ -117,7 +120,7 @@ rag_pipeline.run(
```

## Examples
You can find a full code example showing how to use the integration in [this Colab](https://colab.research.google.com/drive/1kE_NAKKgZztQJMbgm2esyTVkAxlrpGtd#scrollTo=coE-fMtTJ-Pp).
You can find a full code example showing how to use the integration in [this Colab](https://colab.research.google.com/github/deepset-ai/haystack-cookbook/blob/main/notebooks/gradient-embeders-and-generators-for-notion-rag.ipynb).

## License

Expand Down