repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | ### Vertex AI |
| #2 | |
| #3 | 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/). |
| #4 | |
| #5 | ### Usage |
| #6 | |
| #7 | ```python |
| #8 | import os |
| #9 | from mem0 import Memory |
| #10 | |
| #11 | # Set the path to your Google Cloud credentials JSON file |
| #12 | os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/path/to/your/credentials.json" |
| #13 | os.environ["OPENAI_API_KEY"] = "your_api_key" # For LLM |
| #14 | |
| #15 | config = { |
| #16 | "embedder": { |
| #17 | "provider": "vertexai", |
| #18 | "config": { |
| #19 | "model": "text-embedding-004", |
| #20 | "memory_add_embedding_type": "RETRIEVAL_DOCUMENT", |
| #21 | "memory_update_embedding_type": "RETRIEVAL_DOCUMENT", |
| #22 | "memory_search_embedding_type": "RETRIEVAL_QUERY" |
| #23 | } |
| #24 | } |
| #25 | } |
| #26 | |
| #27 | m = Memory.from_config(config) |
| #28 | messages = [ |
| #29 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #30 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #31 | {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, |
| #32 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #33 | ] |
| #34 | m.add(messages, user_id="john") |
| #35 | ``` |
| #36 | The embedding types can be one of the following: |
| #37 | - SEMANTIC_SIMILARITY |
| #38 | - CLASSIFICATION |
| #39 | - CLUSTERING |
| #40 | - RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY, QUESTION_ANSWERING, FACT_VERIFICATION |
| #41 | - CODE_RETRIEVAL_QUERY |
| #42 | Check out the [Vertex AI documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/task-types#supported_task_types) for more information. |
| #43 | |
| #44 | ### Config |
| #45 | |
| #46 | Here are the parameters available for configuring the Vertex AI embedder: |
| #47 | |
| #48 | | Parameter | Description | Default Value | |
| #49 | | ------------------------- | ------------------------------------------------ | -------------------- | |
| #50 | | `model` | The name of the Vertex AI embedding model to use | `text-embedding-004` | |
| #51 | | `vertex_credentials_json` | Path to the Google Cloud credentials JSON file | `None` | |
| #52 | | `embedding_dims` | Dimensions of the embedding model | `256` | |
| #53 | | `memory_add_embedding_type` | The type of embedding to use for the add memory action | `RETRIEVAL_DOCUMENT` | |
| #54 | | `memory_update_embedding_type` | The type of embedding to use for the update memory action | `RETRIEVAL_DOCUMENT` | |
| #55 | | `memory_search_embedding_type` | The type of embedding to use for the search memory action | `RETRIEVAL_QUERY` | |
| #56 |