Skip to content

Commit

Permalink
Use indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Dec 3, 2024
1 parent b0325a0 commit eed15b9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ __pycache__/

# C extensions
*.so
.langgraph_api

# Distribution / packaging
.Python
Expand Down
8 changes: 7 additions & 1 deletion langgraph.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
},
"env": ".env",
"python_version": "3.11",
"dependencies": ["."]
"dependencies": ["."],
"store": {
"index": {
"dims": 1536,
"embed": "openai:text-embedding-3-small"
}
}
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
# Optional (for selecting different models)
"langchain-openai>=0.2.1",
"langchain-anthropic>=0.2.1",
"langchain>=0.3.1",
"langchain>=0.3.8",
"langchain-core>=0.3.8",
"python-dotenv>=1.0.1",
"langgraph-sdk>=0.1.32",
Expand Down
4 changes: 3 additions & 1 deletion src/memory_agent/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ async def call_model(state: State, config: RunnableConfig, *, store: BaseStore)

# Retrieve the most recent memories for context
memories = await store.asearch(
("memories", configurable.user_id), limit=10
("memories", configurable.user_id),
query=str([m.content for m in state.messages[-3:]]),
limit=10,
)

# Format memories for inclusion in the prompt
Expand Down
2 changes: 1 addition & 1 deletion src/memory_agent/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ async def upsert_memory(
key=str(mem_id),
value={"content": content, "context": context},
)
return f"Stored memory {memory_id}"
return f"Stored memory {mem_id}"
1 change: 0 additions & 1 deletion tests/integration_tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import pytest
from langgraph.checkpoint.memory import MemorySaver
from langgraph.store.memory import InMemoryStore

from memory_agent.graph import builder


Expand Down

0 comments on commit eed15b9

Please sign in to comment.