Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -129,17 +129,13 @@ compiled_graph = graph.compile()
|
|
129 |
|
130 |
# 9) Define respond_to_input so that Gradio (and the Hugging Face submission) can call it
|
131 |
def respond_to_input(user_input: str) -> str:
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
final_state = compiled_graph.invoke(initial_state, user_input)
|
140 |
-
# The “final” on END means agent_out has no more tool calls and finished reasoning
|
141 |
-
# We return the last assistant message from state["messages"]:
|
142 |
-
return final_state["messages"][-1].replace("ASSISTANT: ", "")
|
143 |
|
144 |
|
145 |
class BasicAgent:
|
|
|
129 |
|
130 |
# 9) Define respond_to_input so that Gradio (and the Hugging Face submission) can call it
|
131 |
def respond_to_input(user_input: str) -> str:
|
132 |
+
initial_state: AgentState = {"messages": [], "tool_request": None, "tool_result": None}
|
133 |
+
# ✔️ In v0.4.7 (and 0.3.x+), you must use .run():
|
134 |
+
final_state = compiled_graph.run(initial_state, user_input)
|
135 |
+
# Return the last assistant message
|
136 |
+
last = final_state["messages"][-1]
|
137 |
+
return last.replace("ASSISTANT: ", "")
|
138 |
+
|
|
|
|
|
|
|
|
|
139 |
|
140 |
|
141 |
class BasicAgent:
|