Spaces:
Runtime error
Runtime error
Update agent.py
Browse files
agent.py
CHANGED
@@ -916,15 +916,17 @@ def should_call_tool(state):
|
|
916 |
if isinstance(last_msg, AIMessage) and last_msg.tool_calls:
|
917 |
return "call_tool"
|
918 |
return "end"
|
|
|
919 |
|
920 |
from typing import TypedDict, List, Optional, Union
|
921 |
from langchain.schema import BaseMessage
|
922 |
|
923 |
class AgentState(TypedDict):
|
924 |
-
messages: List[BaseMessage]
|
925 |
-
input: str
|
926 |
-
intent: str
|
927 |
-
result: Optional[str]
|
|
|
928 |
|
929 |
|
930 |
|
@@ -1133,11 +1135,6 @@ def build_graph() -> StateGraph:
|
|
1133 |
call_llm = llm.bind_tools(tools)
|
1134 |
|
1135 |
# --- Build the graph ---
|
1136 |
-
from langgraph.graph import StateGraph
|
1137 |
-
|
1138 |
-
def build_graph():
|
1139 |
-
builder = StateGraph(AgentState) # Keep your typed state graph
|
1140 |
-
|
1141 |
builder.add_node("retriever", retriever)
|
1142 |
builder.add_node("assistant", assistant)
|
1143 |
builder.add_node("call_llm", call_llm)
|
|
|
916 |
if isinstance(last_msg, AIMessage) and last_msg.tool_calls:
|
917 |
return "call_tool"
|
918 |
return "end"
|
919 |
+
|
920 |
|
921 |
from typing import TypedDict, List, Optional, Union
|
922 |
from langchain.schema import BaseMessage
|
923 |
|
924 |
class AgentState(TypedDict):
|
925 |
+
messages: List[BaseMessage] # Chat history
|
926 |
+
input: str # Original input
|
927 |
+
intent: str # Derived or predicted intent
|
928 |
+
result: Optional[str] # Final or intermediate result
|
929 |
+
|
930 |
|
931 |
|
932 |
|
|
|
1135 |
call_llm = llm.bind_tools(tools)
|
1136 |
|
1137 |
# --- Build the graph ---
|
|
|
|
|
|
|
|
|
|
|
1138 |
builder.add_node("retriever", retriever)
|
1139 |
builder.add_node("assistant", assistant)
|
1140 |
builder.add_node("call_llm", call_llm)
|