naman1102 commited on
Commit
55affd7
·
1 Parent(s): 3f7f23e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
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
- # Start with an empty state
133
- initial_state: AgentState = {
134
- "messages": [],
135
- "tool_request": None,
136
- "tool_result": None
137
- }
138
- # Use .run(initial_state, user_input) in v0.3.x
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: