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 the Gemini model, set the `GOOGLE_API_KEY` environment variable. You can obtain the Google/Gemini API key from [Google AI Studio](https://aistudio.google.com/app/apikey). |
| #6 | |
| #7 | > **Note:** As of the latest release, Mem0 uses the new `google.genai` SDK instead of the deprecated `google.generativeai`. All message formatting and model interaction now use the updated `types` module from `google.genai`. |
| #8 | |
| #9 | > **Note:** Some Gemini models are being deprecated and will retire soon. It is recommended to migrate to the latest stable models like `"gemini-2.0-flash-001"` or `"gemini-2.0-flash-lite-001"` to ensure ongoing support and improvements. |
| #10 | |
| #11 | ## Usage |
| #12 | |
| #13 | <CodeGroup> |
| #14 | ```python Python |
| #15 | import os |
| #16 | from mem0 import Memory |
| #17 | |
| #18 | os.environ["OPENAI_API_KEY"] = "your-openai-api-key" # Used for embedding model |
| #19 | os.environ["GOOGLE_API_KEY"] = "your-gemini-api-key" |
| #20 | |
| #21 | config = { |
| #22 | "llm": { |
| #23 | "provider": "gemini", |
| #24 | "config": { |
| #25 | "model": "gemini-2.0-flash-001", |
| #26 | "temperature": 0.2, |
| #27 | "max_tokens": 2000, |
| #28 | "top_p": 1.0 |
| #29 | } |
| #30 | } |
| #31 | } |
| #32 | |
| #33 | m = Memory.from_config(config) |
| #34 | |
| #35 | messages = [ |
| #36 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #37 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #38 | {"role": "user", "content": "I’m not a big fan of thrillers, but I love sci-fi movies."}, |
| #39 | {"role": "assistant", "content": "Got it! I'll avoid thrillers and suggest sci-fi movies instead."} |
| #40 | ] |
| #41 | |
| #42 | m.add(messages, user_id="alice", metadata={"category": "movies"}) |
| #43 | |
| #44 | ``` |
| #45 | ```typescript TypeScript |
| #46 | import { Memory } from "mem0ai/oss"; |
| #47 | |
| #48 | const config = { |
| #49 | llm: { |
| #50 | // You can also use "google" as provider ( for backward compatibility ) |
| #51 | provider: "gemini", |
| #52 | config: { |
| #53 | model: "gemini-2.0-flash-001", |
| #54 | temperature: 0.1 |
| #55 | } |
| #56 | } |
| #57 | } |
| #58 | |
| #59 | const memory = new Memory(config); |
| #60 | |
| #61 | const messages = [ |
| #62 | { role: "user", content: "I'm planning to watch a movie tonight. Any recommendations?" }, |
| #63 | { role: "assistant", content: "How about thriller movies? They can be quite engaging." }, |
| #64 | { role: "user", content: "I’m not a big fan of thrillers, but I love sci-fi movies." }, |
| #65 | { role: "assistant", content: "Got it! I'll avoid thrillers and suggest sci-fi movies instead." } |
| #66 | ] |
| #67 | |
| #68 | await memory.add(messages, { userId: "alice", metadata: { category: "movies" } }); |
| #69 | ``` |
| #70 | </CodeGroup> |
| #71 | |
| #72 | ## Config |
| #73 | |
| #74 | All available parameters for the `Gemini` config are present in [Master List of All Params in Config](../config). |