Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -6,21 +6,32 @@ import yaml
|
|
| 6 |
import gradio as gr
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
|
| 9 |
-
from
|
| 10 |
|
| 11 |
@tool
|
| 12 |
-
def calculator(a: int, b: int) ->
|
| 13 |
-
"""
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
a (int): First number
|
| 16 |
b (int): Second number
|
|
|
|
| 17 |
|
| 18 |
Returns:
|
| 19 |
-
|
| 20 |
"""
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
@tool
|
| 26 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -65,7 +76,7 @@ from smolagents import load_tool
|
|
| 65 |
tool_registry = {
|
| 66 |
"calculator": {
|
| 67 |
"tool": calculator,
|
| 68 |
-
"schema":
|
| 69 |
"enabled": True
|
| 70 |
},
|
| 71 |
"get_current_time_in_timezone": {
|
|
|
|
| 1 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
|
| 9 |
+
from smolagents import tool
|
| 10 |
|
| 11 |
@tool
|
| 12 |
+
def calculator(a: int, b: int, operation: str = "multiply") -> float:
|
| 13 |
+
"""
|
| 14 |
+
Perform basic arithmetic operations on two numbers.
|
| 15 |
+
|
| 16 |
+
Args:
|
| 17 |
a (int): First number
|
| 18 |
b (int): Second number
|
| 19 |
+
operation (str): Operation to perform ("add", "subtract", "multiply", "divide")
|
| 20 |
|
| 21 |
Returns:
|
| 22 |
+
float: Result of the operation
|
| 23 |
"""
|
| 24 |
+
if operation == "add":
|
| 25 |
+
return a + b
|
| 26 |
+
elif operation == "subtract":
|
| 27 |
+
return a - b
|
| 28 |
+
elif operation == "multiply":
|
| 29 |
+
return a * b
|
| 30 |
+
elif operation == "divide":
|
| 31 |
+
return a / b if b != 0 else float("inf")
|
| 32 |
+
else:
|
| 33 |
+
raise ValueError(f"Unsupported operation: {operation}")
|
| 34 |
+
|
| 35 |
|
| 36 |
@tool
|
| 37 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 76 |
tool_registry = {
|
| 77 |
"calculator": {
|
| 78 |
"tool": calculator,
|
| 79 |
+
"schema": calculator.tool_schema(),
|
| 80 |
"enabled": True
|
| 81 |
},
|
| 82 |
"get_current_time_in_timezone": {
|