Spaces:
Running
Running
fix graph flow
Browse files
.langgraph_api/.langgraph_checkpoint.1.pckl
CHANGED
Binary files a/.langgraph_api/.langgraph_checkpoint.1.pckl and b/.langgraph_api/.langgraph_checkpoint.1.pckl differ
|
|
.langgraph_api/.langgraph_checkpoint.2.pckl
CHANGED
Binary files a/.langgraph_api/.langgraph_checkpoint.2.pckl and b/.langgraph_api/.langgraph_checkpoint.2.pckl differ
|
|
.langgraph_api/.langgraph_ops.pckl
CHANGED
Binary files a/.langgraph_api/.langgraph_ops.pckl and b/.langgraph_api/.langgraph_ops.pckl differ
|
|
.langgraph_api/.langgraph_retry_counter.pckl
CHANGED
Binary files a/.langgraph_api/.langgraph_retry_counter.pckl and b/.langgraph_api/.langgraph_retry_counter.pckl differ
|
|
.langgraph_api/store.pckl
CHANGED
Binary files a/.langgraph_api/store.pckl and b/.langgraph_api/store.pckl differ
|
|
agent/graph.py
CHANGED
@@ -26,8 +26,7 @@ def create_graph_builder():
|
|
26 |
# Set entry point
|
27 |
builder.set_entry_point("agent")
|
28 |
|
29 |
-
builder.add_edge("agent", "write_memory")
|
30 |
-
builder.add_edge("write_memory", END)
|
31 |
|
32 |
# Add conditional edges from agent
|
33 |
builder.add_conditional_edges(
|
@@ -36,12 +35,12 @@ def create_graph_builder():
|
|
36 |
{
|
37 |
"action": "action",
|
38 |
"write_memory": "write_memory",
|
39 |
-
END: END
|
40 |
}
|
41 |
)
|
42 |
|
43 |
# Connect action back to agent
|
44 |
builder.add_edge("action", "agent")
|
|
|
45 |
|
46 |
return builder
|
47 |
|
|
|
26 |
# Set entry point
|
27 |
builder.set_entry_point("agent")
|
28 |
|
29 |
+
# builder.add_edge("agent", "write_memory")
|
|
|
30 |
|
31 |
# Add conditional edges from agent
|
32 |
builder.add_conditional_edges(
|
|
|
35 |
{
|
36 |
"action": "action",
|
37 |
"write_memory": "write_memory",
|
|
|
38 |
}
|
39 |
)
|
40 |
|
41 |
# Connect action back to agent
|
42 |
builder.add_edge("action", "agent")
|
43 |
+
builder.add_edge("write_memory", END)
|
44 |
|
45 |
return builder
|
46 |
|
agent/utils/nodes.py
CHANGED
@@ -80,8 +80,8 @@ def call_model(state: AgentState, config: RunnableConfig, store: BaseStore):
|
|
80 |
messages = [
|
81 |
SystemMessage(content=SYSTEM_PROMPT.format(memory=memory_content))
|
82 |
] + state["messages"]
|
83 |
-
|
84 |
-
response =
|
85 |
return {"messages": [response]}
|
86 |
|
87 |
def update_memory(state: AgentState, config: RunnableConfig, store: BaseStore):
|
@@ -100,7 +100,7 @@ def update_memory(state: AgentState, config: RunnableConfig, store: BaseStore):
|
|
100 |
store.put(namespace, "user_memory", {"memory": new_memory.content})
|
101 |
return state
|
102 |
|
103 |
-
def should_continue(state: AgentState) -> Literal["action", "write_memory"
|
104 |
"""Determine the next node in the graph."""
|
105 |
if not state["messages"]:
|
106 |
return END
|
@@ -114,15 +114,17 @@ def should_continue(state: AgentState) -> Literal["action", "write_memory", END]
|
|
114 |
# Handle tool calls
|
115 |
if hasattr(last_message, "additional_kwargs") and last_message.additional_kwargs.get("tool_calls"):
|
116 |
return "action"
|
|
|
|
|
117 |
|
118 |
-
# Handle memory operations for human messages
|
119 |
-
if last_human_message:
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
|
125 |
-
return END
|
126 |
|
127 |
# Define the memory creation prompt
|
128 |
MEMORY_CREATION_PROMPT = """"You are collecting information about the user to personalize your responses.
|
|
|
80 |
messages = [
|
81 |
SystemMessage(content=SYSTEM_PROMPT.format(memory=memory_content))
|
82 |
] + state["messages"]
|
83 |
+
tool_calling_model = model.bind_tools(tool_belt)
|
84 |
+
response = tool_calling_model.invoke(messages)
|
85 |
return {"messages": [response]}
|
86 |
|
87 |
def update_memory(state: AgentState, config: RunnableConfig, store: BaseStore):
|
|
|
100 |
store.put(namespace, "user_memory", {"memory": new_memory.content})
|
101 |
return state
|
102 |
|
103 |
+
def should_continue(state: AgentState) -> Literal["action", "write_memory"]:
|
104 |
"""Determine the next node in the graph."""
|
105 |
if not state["messages"]:
|
106 |
return END
|
|
|
114 |
# Handle tool calls
|
115 |
if hasattr(last_message, "additional_kwargs") and last_message.additional_kwargs.get("tool_calls"):
|
116 |
return "action"
|
117 |
+
|
118 |
+
return "write_memory"
|
119 |
|
120 |
+
# # Handle memory operations for human messages
|
121 |
+
# if last_human_message:
|
122 |
+
|
123 |
+
# # Write memory for longer messages that might contain personal information
|
124 |
+
# if len(last_human_message.content.split()) > 3:
|
125 |
+
# return "write_memory"
|
126 |
|
127 |
+
# return END
|
128 |
|
129 |
# Define the memory creation prompt
|
130 |
MEMORY_CREATION_PROMPT = """"You are collecting information about the user to personalize your responses.
|