Skip to content

Commit

Permalink
Add support
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Dec 3, 2024
1 parent 4f30032 commit 0ec39f8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
8 changes: 7 additions & 1 deletion langgraph.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
},
"env": ".env",
"python_version": "3.11",
"dependencies": ["."]
"dependencies": ["."],
"store": {
"index": {
"dims": 1536,
"embed": "openai:text-embedding-3-small"
}
}
}
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ readme = "README.md"
license = { text = "MIT" }
requires-python = ">=3.9"
dependencies = [
"langgraph>=0.2.32,<0.3.0",
"langgraph>=0.2.53,<0.3.0",
"langgraph-checkpoint>=2.0.8",
# Optional (for selecting different models)
"langchain-openai>=0.2.1",
"langchain-anthropic>=0.2.1",
"langchain>=0.3.1",
"langchain>=0.3.8",
"python-dotenv>=1.0.1",
"langgraph-sdk>=0.1.32",
"langgraph-sdk>=0.1.40",
"trustcall>=0.0.21",
]

Expand Down
4 changes: 2 additions & 2 deletions src/chatbot/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from chatbot.configuration import ChatConfigurable
from chatbot.utils import format_memories, init_model


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

model = init_model(configurable.model)
prompt = configurable.system_prompt.format(
Expand Down
3 changes: 2 additions & 1 deletion src/memory_graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ async def handle_insertion_memory(
namespace = (configurable.user_id, "events", state.function_name)

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

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

0 comments on commit 0ec39f8

Please sign in to comment.