Skip to content

Commit cd08c77

Browse files
authored
INTPYTHON-887 & INTPYTHON-899 Update langgraph-mongodb-store docs (langchain-ai#321)
1 parent 175c304 commit cd08c77

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ It contains the following packages.
3838
### LangGraph
3939

4040
- Checkpointing (BaseCheckpointSaver)
41-
- [MongoDBSaver](https://langchain-mongodb.readthedocs.io/en/latest/langgraph_checkpoint_mongodb/saver/langgraph.checkpoint.mongodb.saver.MongoDBSaver.html#mongodbsaver)
41+
- [MongoDBSaver](https://www.mongodb.com/docs/atlas/ai-integrations/langgraph/#mongodb-langgraph-checkpointer--short-term-memory-)
4242

4343
- Long-term memory (BaseStore)
44-
- [MongoDBStore](https://www.mongodb.com/docs/atlas/ai-integrations/langgraph/#mongodb-langgraph-store--long-term-memory-)
44+
- [MongoDBStore](https://www.mongodb.com/docs/atlas/ai-integrations/langgraph/#mongodb-langgraph-store--long-term-memory-)
4545

4646
## Installation
4747

@@ -51,8 +51,6 @@ You can install `langchain-mongodb`, `langgraph-checkpoint-mongodb` and `langgra
5151
pip install langchain-mongodb langgraph-checkpoint-mongodb langgraph-store-mongodb
5252
```
5353

54-
55-
5654
## Usage
5755

5856
See [langchain-mongodb usage](libs/langchain-mongodb/README.md#usage), [langgraph-checkpoint-mongodb usage](libs/langgraph-checkpoint-mongodb/README.md#usage) and [langgraph-store-mongodb usage](libs/langgraph-store-mongodb/README.md#usage).
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
11
# langraph-store-mongodb
22

33
LangGraph long-term memory using MongoDB.
4+
5+
## Installation
6+
7+
```bash
8+
pip install -U langgraph-store-mongodb
9+
```
10+
11+
## Usage
12+
13+
For more detailed usage examples and documentation, please refer to the [MongoDB LangGraph documentation](https://www.mongodb.com/docs/atlas/ai-integrations/langgraph/).
14+
15+
```python
16+
from langgraph.store.mongodb import MongoDBStore, create_vector_index_config
17+
from langchain_voyageai import VoyageAIEmbeddings
18+
19+
# Vector search index configuration with client-side embedding
20+
index_config = create_vector_index_config(
21+
embed = VoyageAIEmbeddings(),
22+
dims = <dimensions>,
23+
fields = ["<field-name>"],
24+
filters = ["<filter-field-name>", ...] # Optional
25+
)
26+
27+
# Store memories in MongoDB collection
28+
with MongoDBStore.from_conn_string(
29+
conn_string=MONGODB_URI,
30+
db_name="<database-name>",
31+
collection_name="<collection-name>",
32+
index_config=index_config
33+
) as store:
34+
store.put(
35+
namespace=("user", "memories"),
36+
key=f"memory_{hash(content)}",
37+
value={"content": content}
38+
)
39+
40+
# Retrieve memories from MongoDB collection
41+
with MongoDBStore.from_conn_string(
42+
conn_string=MONGODB_URI,
43+
db_name="<database-name>",
44+
collection_name="<collection-name>",
45+
index_config=index_config
46+
) as store:
47+
results = store.search(
48+
("user", "memories"),
49+
query="<query-text>",
50+
limit=3
51+
)
52+
for result in results:
53+
print(result.value)
54+
55+
# To delete memories, use store.delete(namespace, key)
56+
# To batch operations, use store.batch(ops)
57+
```

0 commit comments

Comments
 (0)