naman1102 commited on
Commit
a18a60e
·
1 Parent(s): f1bb56b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -69,12 +69,14 @@ def tool_selector(state: AgentState) -> AgentState:
69
  " {'action':'audio'}\n"
70
  " {'action':'excel'}\n"
71
  " {'action':'final'}\n"
 
72
  )
73
  )
74
  raw = LLM(state.messages + [prompt]).content.strip()
75
  print(f"Tool selector response: {raw}")
76
  state.add(AIMessage(content=raw))
77
  parsed = safe_json(raw)
 
78
  if not parsed or "action" not in parsed:
79
  state.next_action = "final"
80
  return state
@@ -189,6 +191,7 @@ def answer(question: str, task_id: Optional[str] = None) -> str:
189
  state.add(SystemMessage(content="You are a helpful assistant."))
190
  state.add(HumanMessage(content=question))
191
  compiled_graph.invoke(state)
 
192
  return state.final_answer or "No answer."
193
 
194
 
 
69
  " {'action':'audio'}\n"
70
  " {'action':'excel'}\n"
71
  " {'action':'final'}\n"
72
+ "if the tool you want isnt listed above, return {'action':'final'}"
73
  )
74
  )
75
  raw = LLM(state.messages + [prompt]).content.strip()
76
  print(f"Tool selector response: {raw}")
77
  state.add(AIMessage(content=raw))
78
  parsed = safe_json(raw)
79
+ print(f"Parsed: {parsed}")
80
  if not parsed or "action" not in parsed:
81
  state.next_action = "final"
82
  return state
 
191
  state.add(SystemMessage(content="You are a helpful assistant."))
192
  state.add(HumanMessage(content=question))
193
  compiled_graph.invoke(state)
194
+ print(f"Final answer: {state.final_answer}")
195
  return state.final_answer or "No answer."
196
 
197