Spaces:
Sleeping
Sleeping
Added two trivial tools
Browse files
app.py
CHANGED
|
@@ -33,6 +33,20 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
@@ -55,7 +69,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def get_factorial(number: int) -> str:
|
| 38 |
+
"""A tool that calculates the factorial of a given number.
|
| 39 |
+
Args:
|
| 40 |
+
number: A string representing a the number for which factorial will be calculated.
|
| 41 |
+
"""
|
| 42 |
+
if number < 1:
|
| 43 |
+
return "0"
|
| 44 |
+
elif number > 40:
|
| 45 |
+
return "Too large number"
|
| 46 |
+
fact = 1
|
| 47 |
+
for i in range(1, n + 1):
|
| 48 |
+
fact *= i
|
| 49 |
+
return str(fact)
|
| 50 |
|
| 51 |
final_answer = FinalAnswerTool()
|
| 52 |
|
|
|
|
| 69 |
|
| 70 |
agent = CodeAgent(
|
| 71 |
model=model,
|
| 72 |
+
tools=[final_answer, get_current_time_in_timezone,get_factorial], ## add your tools here (don't remove final answer)
|
| 73 |
max_steps=6,
|
| 74 |
verbosity_level=1,
|
| 75 |
grammar=None,
|