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 | # MongoDB |
| #2 | |
| #3 | [MongoDB](https://www.mongodb.com/) is a versatile document database that supports vector search capabilities, allowing for efficient high-dimensional similarity searches over large datasets with robust scalability and performance. |
| #4 | |
| #5 | ## Usage |
| #6 | |
| #7 | ```python |
| #8 | import os |
| #9 | from mem0 import Memory |
| #10 | |
| #11 | os.environ["OPENAI_API_KEY"] = "sk-xx" |
| #12 | |
| #13 | config = { |
| #14 | "vector_store": { |
| #15 | "provider": "mongodb", |
| #16 | "config": { |
| #17 | "db_name": "mem0-db", |
| #18 | "collection_name": "mem0-collection", |
| #19 | "mongo_uri":"mongodb://username:password@localhost:27017" |
| #20 | } |
| #21 | } |
| #22 | } |
| #23 | |
| #24 | m = Memory.from_config(config) |
| #25 | messages = [ |
| #26 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #27 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #28 | {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, |
| #29 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #30 | ] |
| #31 | m.add(messages, user_id="alice", metadata={"category": "movies"}) |
| #32 | ``` |
| #33 | |
| #34 | ## Config |
| #35 | |
| #36 | Here are the parameters available for configuring MongoDB: |
| #37 | |
| #38 | | Parameter | Description | Default Value | |
| #39 | | --- | --- | --- | |
| #40 | | db_name | Name of the MongoDB database | `"mem0_db"` | |
| #41 | | collection_name | Name of the MongoDB collection | `"mem0_collection"` | |
| #42 | | embedding_model_dims | Dimensions of the embedding vectors | `1536` | |
| #43 | | mongo_uri | The MongoDB URI connection string | `mongodb://username:password@localhost:27017` | |
| #44 | |
| #45 | > **Note**: If `mongo_uri` is not provided, it will default to `mongodb://username:password@localhost:27017`. |
| #46 |