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 | You can use embedding models from Ollama to run Mem0 locally. |
| #2 | |
| #3 | ### Usage |
| #4 | |
| #5 | <CodeGroup> |
| #6 | ```python Python |
| #7 | import os |
| #8 | from mem0 import Memory |
| #9 | |
| #10 | os.environ["OPENAI_API_KEY"] = "your_api_key" # For LLM |
| #11 | |
| #12 | config = { |
| #13 | "embedder": { |
| #14 | "provider": "ollama", |
| #15 | "config": { |
| #16 | "model": "mxbai-embed-large" |
| #17 | } |
| #18 | } |
| #19 | } |
| #20 | |
| #21 | m = Memory.from_config(config) |
| #22 | messages = [ |
| #23 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #24 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #25 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #26 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #27 | ] |
| #28 | m.add(messages, user_id="john") |
| #29 | ``` |
| #30 | |
| #31 | ```typescript TypeScript |
| #32 | import { Memory } from 'mem0ai/oss'; |
| #33 | |
| #34 | const config = { |
| #35 | embedder: { |
| #36 | provider: 'ollama', |
| #37 | config: { |
| #38 | model: 'nomic-embed-text:latest', // or any other Ollama embedding model |
| #39 | url: 'http://localhost:11434', // Ollama server URL |
| #40 | }, |
| #41 | }, |
| #42 | }; |
| #43 | |
| #44 | const memory = new Memory(config); |
| #45 | const messages = [ |
| #46 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #47 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #48 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #49 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #50 | ] |
| #51 | await memory.add(messages, { userId: "john" }); |
| #52 | ``` |
| #53 | </CodeGroup> |
| #54 | |
| #55 | ### Config |
| #56 | |
| #57 | Here are the parameters available for configuring Ollama embedder: |
| #58 | |
| #59 | <Tabs> |
| #60 | <Tab title="Python"> |
| #61 | | Parameter | Description | Default Value | |
| #62 | | --- | --- | --- | |
| #63 | | `model` | The name of the Ollama model to use | `nomic-embed-text` | |
| #64 | | `embedding_dims` | Dimensions of the embedding model | `512` | |
| #65 | | `ollama_base_url` | Base URL for ollama connection | `None` | |
| #66 | </Tab> |
| #67 | <Tab title="TypeScript"> |
| #68 | | Parameter | Description | Default Value | |
| #69 | | --- | --- | --- | |
| #70 | | `model` | The name of the Ollama model to use | `nomic-embed-text:latest` | |
| #71 | | `url` | Base URL for Ollama server | `http://localhost:11434` | |
| #72 | | `embeddingDims` | Dimensions of the embedding model | 768 |
| #73 | </Tab> |
| #74 | </Tabs> |