Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
@@ -34,6 +35,37 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
| 39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import math
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
|
|
|
| 35 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 36 |
|
| 37 |
|
| 38 |
+
@tool
|
| 39 |
+
def calculator(a: float, b: float, operation: str) -> str:
|
| 40 |
+
"""
|
| 41 |
+
This tool calculates 2 numbers with given operation.
|
| 42 |
+
Args:
|
| 43 |
+
a: first number
|
| 44 |
+
b: second number
|
| 45 |
+
operation: we currently support this list of operation:
|
| 46 |
+
{'Multiplication':'*', 'Division':'/', 'Addition':'+', 'Subtraction':'-', 'Power':'**', 'Modulus': '%'}
|
| 47 |
+
Note:
|
| 48 |
+
we dont support numbers above `100000.0`
|
| 49 |
+
it is possible we return division by zero error.
|
| 50 |
+
"""
|
| 51 |
+
|
| 52 |
+
if operation == '*':
|
| 53 |
+
return str(a * b)
|
| 54 |
+
elif operation == '/':
|
| 55 |
+
if b == 0:
|
| 56 |
+
return f"Cannot division {a} with zero! Error."
|
| 57 |
+
return str(a / b)
|
| 58 |
+
elif operation == '+':
|
| 59 |
+
return str(a + b)
|
| 60 |
+
elif operation == '-':
|
| 61 |
+
return str(a - b)
|
| 62 |
+
elif operation == '**':
|
| 63 |
+
return str(math.pow(a, b))
|
| 64 |
+
elif operation == '%':
|
| 65 |
+
return str(a % b)
|
| 66 |
+
else:
|
| 67 |
+
return f"Currently operation {operation} dose not supported, chose you'r needed operation from here \{'Multiplication':'*', 'Division':'/', 'Addition':'+', 'Subtraction':'-', 'Power':'**', 'Modulus': '%'\}"
|
| 68 |
+
|
| 69 |
final_answer = FinalAnswerTool()
|
| 70 |
|
| 71 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|