Spaces:
Sleeping
Sleeping
Commit
·
a9ed539
1
Parent(s):
c49a644
add fibonacci
Browse files
app.py
CHANGED
@@ -34,6 +34,21 @@ 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:
|
@@ -55,7 +70,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer, get_current_time_in_timezone,
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
|
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
36 |
|
37 |
+
@tool
|
38 |
+
def fibonacci(n: int) -> str:
|
39 |
+
if n <= 0:
|
40 |
+
return "Input should be a positive integer."
|
41 |
+
elif n == 1:
|
42 |
+
return str(0)
|
43 |
+
elif n == 2:
|
44 |
+
return str(1)
|
45 |
+
else:
|
46 |
+
a, b = 0, 1
|
47 |
+
for _ in range(2, n):
|
48 |
+
a, b = b, a + b
|
49 |
+
return str(b)
|
50 |
+
|
51 |
+
|
52 |
final_answer = FinalAnswerTool()
|
53 |
|
54 |
# 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:
|
|
|
70 |
|
71 |
agent = CodeAgent(
|
72 |
model=model,
|
73 |
+
tools=[final_answer, get_current_time_in_timezone, fibonacci], ## add your tools here (don't remove final answer)
|
74 |
max_steps=6,
|
75 |
verbosity_level=1,
|
76 |
grammar=None,
|