Ali-Developments commited on
Commit
f4df3f7
·
verified ·
1 Parent(s): 409dd63

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +5 -5
agent.py CHANGED
@@ -20,7 +20,7 @@ def calculator_tool_func(query: str):
20
  result = str(eval(query, {"__builtins__": {}}))
21
  return result
22
  except Exception:
23
- return "Could not calculate the input expression."
24
 
25
  calculator_tool = Tool(
26
  name="Calculator",
@@ -72,16 +72,16 @@ def run_ninu(query: str):
72
  conversation = []
73
 
74
  system_prompt = """
75
- You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. 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.
76
  """
77
  conversation.append(HumanMessage(content=system_prompt.strip()))
78
  conversation.append(HumanMessage(content=query))
79
 
80
  response = ninu.invoke({"messages": conversation})
81
  for message in reversed(response["messages"]):
82
- if isinstance(message.content, str) and "FINAL ANSWER:" in message.content:
83
- return message.content.split("FINAL ANSWER:")[-1].strip()
84
- return "FINAL ANSWER: No valid answer found."
85
 
86
  # --- Example test ---
87
  if __name__ == "__main__":
 
20
  result = str(eval(query, {"__builtins__": {}}))
21
  return result
22
  except Exception:
23
+ return "I couldn't compute that expression."
24
 
25
  calculator_tool = Tool(
26
  name="Calculator",
 
72
  conversation = []
73
 
74
  system_prompt = """
75
+ You are a smart, helpful, and curious assistant. Think step by step and use any available tools if needed. Explain your reasoning, be honest about what you know and don't know, and speak naturally in English.
76
  """
77
  conversation.append(HumanMessage(content=system_prompt.strip()))
78
  conversation.append(HumanMessage(content=query))
79
 
80
  response = ninu.invoke({"messages": conversation})
81
  for message in reversed(response["messages"]):
82
+ if isinstance(message.content, str):
83
+ return message.content.strip()
84
+ return "No response received."
85
 
86
  # --- Example test ---
87
  if __name__ == "__main__":