Add Support for Vertex AI Embeddings (#1840)

This commit is contained in:
Divyanshu Prasad
2024-09-13 17:09:25 +05:30
committed by GitHub
parent f9634b4bf3
commit 959f4bb059
5 changed files with 77 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ Here's a comprehensive list of all parameters that can be used across different
| `model_kwargs` | Key-Value arguments for the Huggingface embedding model |
| `azure_kwargs` | Key-Value arguments for the AzureOpenAI embedding model |
| `openai_base_url` | Base URL for OpenAI API | OpenAI |
| `vertex_credentials_json` | Path to the Google Cloud credentials JSON file for VertexAI |
## Supported Embedding Models

View File

@@ -0,0 +1,35 @@
### Vertex AI
To use Google Cloud's Vertex AI for text embedding models, set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to point to the path of your service account's credentials JSON file. These credentials can be created in the [Google Cloud Console](https://console.cloud.google.com/).
### Usage
```python
import os
from mem0 import Memory
# Set the path to your Google Cloud credentials JSON file
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/path/to/your/credentials.json"
config = {
"embedder": {
"provider": "vertexai",
"config": {
"model": "text-embedding-004"
}
}
}
m = Memory.from_config(config)
m.add("I'm visiting Paris", user_id="john")
```
### Config
Here are the parameters available for configuring the Vertex AI embedder:
| Parameter | Description | Default Value |
| ------------------------- | ------------------------------------------------ | -------------------- |
| `model` | The name of the Vertex AI embedding model to use | `text-embedding-004` |
| `vertex_credentials_json` | Path to the Google Cloud credentials JSON file | `None` |
| `embedding_dims` | Dimensions of the embedding model | `256` |

View File

@@ -13,6 +13,7 @@ See the list of supported embedders below.
<Card title="Azure OpenAI" href="/components/embedders/models/azure_openai"></Card>
<Card title="Ollama" href="/components/embedders/models/ollama"></Card>
<Card title="Hugging Face" href="/components/embedders/models/huggingface"></Card>
<Card title="Vertex AI" href="/components/embedders/models/vertexai"></Card>
</CardGroup>
## Usage