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: Ollama |
| #3 | --- |
| #4 | |
| #5 | You can use LLMs from Ollama to run Mem0 locally. These [models](https://ollama.com/search?c=tools) support tool calling. |
| #6 | |
| #7 | ## Usage |
| #8 | |
| #9 | <CodeGroup> |
| #10 | ```python Python |
| #11 | import os |
| #12 | from mem0 import Memory |
| #13 | |
| #14 | os.environ["OPENAI_API_KEY"] = "your-api-key" # for embedder |
| #15 | |
| #16 | config = { |
| #17 | "llm": { |
| #18 | "provider": "ollama", |
| #19 | "config": { |
| #20 | "model": "mixtral:8x7b", |
| #21 | "temperature": 0.1, |
| #22 | "max_tokens": 2000, |
| #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="alice", metadata={"category": "movies"}) |
| #35 | ``` |
| #36 | |
| #37 | ```typescript TypeScript |
| #38 | import { Memory } from 'mem0ai/oss'; |
| #39 | |
| #40 | const config = { |
| #41 | llm: { |
| #42 | provider: 'ollama', |
| #43 | config: { |
| #44 | model: 'llama3.1:8b', // or any other Ollama model |
| #45 | url: 'http://localhost:11434', // Ollama server URL |
| #46 | temperature: 0.1, |
| #47 | }, |
| #48 | }, |
| #49 | }; |
| #50 | |
| #51 | const memory = new Memory(config); |
| #52 | const messages = [ |
| #53 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #54 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #55 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #56 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #57 | ] |
| #58 | await memory.add(messages, { userId: "alice", metadata: { category: "movies" } }); |
| #59 | ``` |
| #60 | </CodeGroup> |
| #61 | |
| #62 | ## Config |
| #63 | |
| #64 | All available parameters for the `ollama` config are present in [Master List of All Params in Config](../config). |