mirror of
https://github.com/langchain-ai/memory-agent-functional-api.git
synced 2026-06-30 20:38:03 -04:00
Use indexing
This commit is contained in:
@@ -5,6 +5,7 @@ __pycache__/
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
.langgraph_api
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
|
||||
+7
-1
@@ -5,5 +5,11 @@
|
||||
},
|
||||
"env": ".env",
|
||||
"python_version": "3.11",
|
||||
"dependencies": ["."]
|
||||
"dependencies": ["."],
|
||||
"store": {
|
||||
"index": {
|
||||
"dims": 1536,
|
||||
"embed": "openai:text-embedding-3-small"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user