giulia-fontanella commited on
Commit
f46a489
·
verified ·
1 Parent(s): 37cf57f

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +13 -2
agent.py CHANGED
@@ -58,9 +58,20 @@ class BasicAgent():
58
  YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
59
  """)
60
  print("Calling assistant with state: ", state["messages"])
61
-
62
- updated_messages = [self.chat_with_tools.invoke(state["messages"])]
63
  # updated_messages = [self.chat_with_tools.invoke([sys_msg] + state["messages"])]
 
 
 
 
 
 
 
 
 
 
 
64
  return {
65
  "messages": updated_messages,
66
  }
 
58
  YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
59
  """)
60
  print("Calling assistant with state: ", state["messages"])
61
+ response = self.chat_with_tools.invoke(state["messages"])
62
+
63
  # updated_messages = [self.chat_with_tools.invoke([sys_msg] + state["messages"])]
64
+
65
+ # Ensure the response is not None
66
+ if response is None:
67
+ raise RuntimeError("chat_with_tools.invoke returned None")
68
+
69
+ # Ensure response is a list if expected
70
+ if isinstance(response, list):
71
+ updated_messages = response
72
+ else:
73
+ updated_messages = [response]
74
+
75
  return {
76
  "messages": updated_messages,
77
  }