Update app.py
#572
by
mijwaaadh
- opened
app.py
CHANGED
|
@@ -34,6 +34,34 @@ 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:
|
|
|
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
|
| 37 |
+
|
| 38 |
+
@tool
|
| 39 |
+
def calculator(arg1: int, arg2: int, operation: str) -> str:
|
| 40 |
+
"""
|
| 41 |
+
A basic calculator tool.
|
| 42 |
+
|
| 43 |
+
Args:
|
| 44 |
+
arg1: first integer
|
| 45 |
+
arg2: second integer
|
| 46 |
+
operation: one of ["sum", "product", "difference", "division"]
|
| 47 |
+
"""
|
| 48 |
+
|
| 49 |
+
if operation == "sum":
|
| 50 |
+
result = arg1 + arg2
|
| 51 |
+
elif operation == "product":
|
| 52 |
+
result = arg1 * arg2
|
| 53 |
+
elif operation == "difference":
|
| 54 |
+
result = arg1 - arg2
|
| 55 |
+
elif operation == "division":
|
| 56 |
+
if arg2 == 0:
|
| 57 |
+
return "Error: division by zero"
|
| 58 |
+
result = arg1 / arg2
|
| 59 |
+
else:
|
| 60 |
+
return "Error: unsupported operation"
|
| 61 |
+
|
| 62 |
+
return f"{operation} of {arg1} and {arg2} is {result}"
|
| 63 |
+
|
| 64 |
+
|
| 65 |
final_answer = FinalAnswerTool()
|
| 66 |
|
| 67 |
# 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:
|