Skip to content

Commit 0ec39f8

Browse files
committed
Add support
1 parent 4f30032 commit 0ec39f8

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

langgraph.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@
66
},
77
"env": ".env",
88
"python_version": "3.11",
9-
"dependencies": ["."]
9+
"dependencies": ["."],
10+
"store": {
11+
"index": {
12+
"dims": 1536,
13+
"embed": "openai:text-embedding-3-small"
14+
}
15+
}
1016
}

pyproject.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ readme = "README.md"
99
license = { text = "MIT" }
1010
requires-python = ">=3.9"
1111
dependencies = [
12-
"langgraph>=0.2.32,<0.3.0",
12+
"langgraph>=0.2.53,<0.3.0",
13+
"langgraph-checkpoint>=2.0.8",
1314
# Optional (for selecting different models)
1415
"langchain-openai>=0.2.1",
1516
"langchain-anthropic>=0.2.1",
16-
"langchain>=0.3.1",
17+
"langchain>=0.3.8",
1718
"python-dotenv>=1.0.1",
18-
"langgraph-sdk>=0.1.32",
19+
"langgraph-sdk>=0.1.40",
1920
"trustcall>=0.0.21",
2021
]
2122

src/chatbot/graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from chatbot.configuration import ChatConfigurable
1414
from chatbot.utils import format_memories, init_model
1515

16-
1716
@dataclass
1817
class ChatState:
1918
"""The state of the chatbot."""
@@ -29,7 +28,8 @@ async def bot(
2928
namespace = (configurable.user_id,)
3029
# This lists ALL user memories in the provided namespace (up to the `limit`)
3130
# you can also filter by content.
32-
items = await store.asearch(namespace)
31+
query = "\n".join(str(message.content) for message in state.messages)
32+
items = await store.asearch(namespace, query=query, limit=10)
3333

3434
model = init_model(configurable.model)
3535
prompt = configurable.system_prompt.format(

src/memory_graph/graph.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ async def handle_insertion_memory(
8080
namespace = (configurable.user_id, "events", state.function_name)
8181

8282
# Fetch existing memories from the store (5 most recent ones) for the this (insert) memory schema
83-
existing_items = await store.asearch(namespace, limit=5)
83+
query = "\n".join(str(message.content) for message in state.messages)[-3000:]
84+
existing_items = await store.asearch(namespace, query=query, limit=5)
8485

8586
# Get the configuration for this memory schema (identified by function_name)
8687
memory_config = next(

0 commit comments

Comments
 (0)