Spaces:
Runtime error
Runtime error
Update agent.py
Browse files
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 "
|
| 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
|
| 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.
|
| 84 |
-
return "
|
| 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__":
|