antonioschiro commited on
Commit
75a2457
·
verified ·
1 Parent(s): def4e0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -27,10 +27,8 @@ class BasicAgent:
27
  response = state_dict["messages"][-1]
28
  try:
29
  response = response.content
30
- if "Final answer:" in response:
31
- response = response.split("Final answer:")[1]
32
- response = response.strip()
33
- return response
34
  except:
35
  return "Sorry, I can't answer to this question."
36
 
 
27
  response = state_dict["messages"][-1]
28
  try:
29
  response = response.content
30
+ matches = re.findall(r"Final Answer:\s*(.*)", response)
31
+ return matches[-1].strip() if matches else response.strip()
 
 
32
  except:
33
  return "Sorry, I can't answer to this question."
34