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 | --- |
| #2 | title: Google AI |
| #3 | --- |
| #4 | |
| #5 | To use Google AI embedding models, set the `GOOGLE_API_KEY` environment variables. You can obtain the Gemini API key from [here](https://aistudio.google.com/app/apikey). |
| #6 | |
| #7 | ### Usage |
| #8 | |
| #9 | <CodeGroup> |
| #10 | ```python Python |
| #11 | import os |
| #12 | from mem0 import Memory |
| #13 | |
| #14 | os.environ["GOOGLE_API_KEY"] = "key" |
| #15 | os.environ["OPENAI_API_KEY"] = "your_api_key" # For LLM |
| #16 | |
| #17 | config = { |
| #18 | "embedder": { |
| #19 | "provider": "gemini", |
| #20 | "config": { |
| #21 | "model": "models/text-embedding-004", |
| #22 | } |
| #23 | } |
| #24 | } |
| #25 | |
| #26 | m = Memory.from_config(config) |
| #27 | messages = [ |
| #28 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #29 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #30 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #31 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #32 | ] |
| #33 | m.add(messages, user_id="john") |
| #34 | ``` |
| #35 | |
| #36 | ```typescript TypeScript |
| #37 | import { Memory } from 'mem0ai/oss'; |
| #38 | |
| #39 | const config = { |
| #40 | embedder: { |
| #41 | provider: "google", |
| #42 | config: { |
| #43 | apiKey: process.env["GOOGLE_API_KEY"], |
| #44 | model: "gemini-embedding-001", |
| #45 | embeddingDims: 1536, |
| #46 | }, |
| #47 | }, |
| #48 | }; |
| #49 | |
| #50 | const memory = new Memory(config); |
| #51 | const messages = [ |
| #52 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #53 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #54 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #55 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #56 | ] |
| #57 | await memory.add(messages, { userId: "john" }); |
| #58 | ``` |
| #59 | </CodeGroup> |
| #60 | |
| #61 | ### Config |
| #62 | |
| #63 | Here are the parameters available for configuring Gemini embedder: |
| #64 | <Tabs> |
| #65 | <Tab title="Python"> |
| #66 | | Parameter | Description | Default Value | |
| #67 | | ---------------- | ------------------------------------ | ----------------------- | |
| #68 | | `model` | The name of the embedding model to use| `models/text-embedding-004` | |
| #69 | | `embedding_dims` | Dimensions of the embedding model | `1536` | |
| #70 | | `api_key` | The Google API key | `None` | |
| #71 | </Tab> |
| #72 | <Tab title="TypeScript"> |
| #73 | | Parameter | Description | Default Value | |
| #74 | | ----------------- | --------------------------------------------- | -------------------------- | |
| #75 | | `model` | The name of the embedding model to use | `gemini-embedding-001` | |
| #76 | | `embeddingDims` | Dimensions of the embedding model | `1536` | |
| #77 | | `apiKey` | Google API key | `None` | |
| #78 | </Tab> |
| #79 | </Tabs> |
| #80 |