File tree 4 files changed +15
-7
lines changed
4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 6
6
},
7
7
"env" : " .env" ,
8
8
"python_version" : " 3.11" ,
9
- "dependencies" : [" ." ]
9
+ "dependencies" : [" ." ],
10
+ "store" : {
11
+ "index" : {
12
+ "dims" : 1536 ,
13
+ "embed" : " openai:text-embedding-3-small"
14
+ }
15
+ }
10
16
}
Original file line number Diff line number Diff line change @@ -9,13 +9,14 @@ readme = "README.md"
9
9
license = { text = " MIT" }
10
10
requires-python = " >=3.9"
11
11
dependencies = [
12
- " langgraph>=0.2.32,<0.3.0" ,
12
+ " langgraph>=0.2.53,<0.3.0" ,
13
+ " langgraph-checkpoint>=2.0.8" ,
13
14
# Optional (for selecting different models)
14
15
" langchain-openai>=0.2.1" ,
15
16
" langchain-anthropic>=0.2.1" ,
16
- " langchain>=0.3.1 " ,
17
+ " langchain>=0.3.8 " ,
17
18
" python-dotenv>=1.0.1" ,
18
- " langgraph-sdk>=0.1.32 " ,
19
+ " langgraph-sdk>=0.1.40 " ,
19
20
" trustcall>=0.0.21" ,
20
21
]
21
22
Original file line number Diff line number Diff line change 13
13
from chatbot .configuration import ChatConfigurable
14
14
from chatbot .utils import format_memories , init_model
15
15
16
-
17
16
@dataclass
18
17
class ChatState :
19
18
"""The state of the chatbot."""
@@ -29,7 +28,8 @@ async def bot(
29
28
namespace = (configurable .user_id ,)
30
29
# This lists ALL user memories in the provided namespace (up to the `limit`)
31
30
# 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 )
33
33
34
34
model = init_model (configurable .model )
35
35
prompt = configurable .system_prompt .format (
Original file line number Diff line number Diff line change @@ -80,7 +80,8 @@ async def handle_insertion_memory(
80
80
namespace = (configurable .user_id , "events" , state .function_name )
81
81
82
82
# 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 )
84
85
85
86
# Get the configuration for this memory schema (identified by function_name)
86
87
memory_config = next (
You can’t perform that action at this time.
0 commit comments