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: LM Studio |
| #3 | --- |
| #4 | |
| #5 | To use LM Studio with Mem0, you'll need to have LM Studio running locally with its server enabled. LM Studio provides a way to run local LLMs with an OpenAI-compatible API. |
| #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" # used for embedding model |
| #15 | |
| #16 | config = { |
| #17 | "llm": { |
| #18 | "provider": "lmstudio", |
| #19 | "config": { |
| #20 | "model": "lmstudio-community/Meta-Llama-3.1-70B-Instruct-GGUF/Meta-Llama-3.1-70B-Instruct-IQ2_M.gguf", |
| #21 | "temperature": 0.2, |
| #22 | "max_tokens": 2000, |
| #23 | "lmstudio_base_url": "http://localhost:1234/v1", # default LM Studio API URL |
| #24 | "lmstudio_response_format": {"type": "json_schema", "json_schema": {"type": "object", "schema": {}}}, |
| #25 | } |
| #26 | } |
| #27 | } |
| #28 | |
| #29 | m = Memory.from_config(config) |
| #30 | messages = [ |
| #31 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #32 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #33 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #34 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #35 | ] |
| #36 | m.add(messages, user_id="alice", metadata={"category": "movies"}) |
| #37 | ``` |
| #38 | </CodeGroup> |
| #39 | |
| #40 | ### Running Completely Locally |
| #41 | |
| #42 | You can also use LM Studio for both LLM and embedding to run Mem0 entirely locally: |
| #43 | |
| #44 | ```python |
| #45 | from mem0 import Memory |
| #46 | |
| #47 | # No external API keys needed! |
| #48 | config = { |
| #49 | "llm": { |
| #50 | "provider": "lmstudio" |
| #51 | }, |
| #52 | "embedder": { |
| #53 | "provider": "lmstudio" |
| #54 | } |
| #55 | } |
| #56 | |
| #57 | m = Memory.from_config(config) |
| #58 | messages = [ |
| #59 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #60 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #61 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #62 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #63 | ] |
| #64 | m.add(messages, user_id="alice123", metadata={"category": "movies"}) |
| #65 | ``` |
| #66 | |
| #67 | <Note> |
| #68 | When using LM Studio for both LLM and embedding, make sure you have: |
| #69 | 1. An LLM model loaded for generating responses |
| #70 | 2. An embedding model loaded for vector embeddings |
| #71 | 3. The server enabled with the correct endpoints accessible |
| #72 | </Note> |
| #73 | |
| #74 | <Note> |
| #75 | To use LM Studio, you need to: |
| #76 | 1. Download and install [LM Studio](https://lmstudio.ai/) |
| #77 | 2. Start a local server from the "Server" tab |
| #78 | 3. Set the appropriate `lmstudio_base_url` in your configuration (default is usually http://localhost:1234/v1) |
| #79 | </Note> |
| #80 | |
| #81 | ## Config |
| #82 | |
| #83 | All available parameters for the `lmstudio` config are present in [Master List of All Params in Config](../config). |
| #84 |