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: OpenAI |
| #3 | --- |
| #4 | |
| #5 | To use OpenAI embedding models, set the `OPENAI_API_KEY` environment variable. You can obtain the OpenAI API key from the [OpenAI Platform](https://platform.openai.com/account/api-keys). |
| #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" |
| #15 | |
| #16 | config = { |
| #17 | "embedder": { |
| #18 | "provider": "openai", |
| #19 | "config": { |
| #20 | "model": "text-embedding-3-large" |
| #21 | } |
| #22 | } |
| #23 | } |
| #24 | |
| #25 | m = Memory.from_config(config) |
| #26 | messages = [ |
| #27 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #28 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #29 | {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, |
| #30 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #31 | ] |
| #32 | m.add(messages, user_id="john") |
| #33 | ``` |
| #34 | |
| #35 | ```typescript TypeScript |
| #36 | import { Memory } from 'mem0ai/oss'; |
| #37 | |
| #38 | const config = { |
| #39 | embedder: { |
| #40 | provider: 'openai', |
| #41 | config: { |
| #42 | apiKey: 'your-openai-api-key', |
| #43 | model: 'text-embedding-3-large', |
| #44 | }, |
| #45 | }, |
| #46 | }; |
| #47 | |
| #48 | const memory = new Memory(config); |
| #49 | await memory.add("I'm visiting Paris", { userId: "john" }); |
| #50 | ``` |
| #51 | </CodeGroup> |
| #52 | |
| #53 | ### Config |
| #54 | |
| #55 | Here are the parameters available for configuring OpenAI embedder: |
| #56 | |
| #57 | <Tabs> |
| #58 | <Tab title="Python"> |
| #59 | | Parameter | Description | Default Value | |
| #60 | | --- | --- | --- | |
| #61 | | `model` | The name of the embedding model to use | `text-embedding-3-small` | |
| #62 | | `embedding_dims` | Dimensions of the embedding model | `1536` | |
| #63 | | `api_key` | The OpenAI API key | `None` | |
| #64 | </Tab> |
| #65 | <Tab title="TypeScript"> |
| #66 | | Parameter | Description | Default Value | |
| #67 | | --- | --- | --- | |
| #68 | | `model` | The name of the embedding model to use | `text-embedding-3-small` | |
| #69 | | `embeddingDims` | Dimensions of the embedding model | `1536` | |
| #70 | | `apiKey` | The OpenAI API key | `None` | |
| #71 | </Tab> |
| #72 | </Tabs> |
| #73 |