Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,11 +3,9 @@ import datetime
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
-
from tools.visit_webpage import VisitWebpageTool
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
-
visit_web_page=VisitWebpageTool()
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -27,20 +25,25 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 27 |
|
| 28 |
#Following my creation.
|
| 29 |
@tool
|
| 30 |
-
def
|
| 31 |
-
"""
|
| 32 |
Args:
|
| 33 |
-
|
| 34 |
-
"""
|
| 35 |
try:
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
except Exception as e:
|
| 43 |
-
return f"Sorry,
|
| 44 |
|
| 45 |
final_answer = FinalAnswerTool()
|
| 46 |
|
|
@@ -63,7 +66,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 63 |
|
| 64 |
agent = CodeAgent(
|
| 65 |
model=model,
|
| 66 |
-
tools=[
|
| 67 |
max_steps=6,
|
| 68 |
verbosity_level=1,
|
| 69 |
grammar=None,
|
|
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
|
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
from Gradio_UI import GradioUI
|
| 8 |
|
|
|
|
| 9 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 10 |
@tool
|
| 11 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 25 |
|
| 26 |
#Following my creation.
|
| 27 |
@tool
|
| 28 |
+
def fibonacci(n: int) -> str:
|
| 29 |
+
"""Returns the Fibonacci series up to the nth number.
|
| 30 |
Args:
|
| 31 |
+
n: An integer number to indicate after how many numbers the fibonacci series should stop"""
|
|
|
|
| 32 |
try:
|
| 33 |
+
# Initialize the Fibonacci sequence
|
| 34 |
+
fib_sequence = [0, 1]
|
| 35 |
+
|
| 36 |
+
if n > 30:
|
| 37 |
+
n=30
|
| 38 |
+
# Generate Fibonacci numbers up to n
|
| 39 |
+
for i in range(2, n):
|
| 40 |
+
fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])
|
| 41 |
+
|
| 42 |
+
# Return the sequence as a string
|
| 43 |
+
return f"The Fibonacci series up to the {n}th number (but not higher than 30) is: {', '.join(map(str, fib_sequence))}"
|
| 44 |
+
|
| 45 |
except Exception as e:
|
| 46 |
+
return f"Sorry, there was an error generating the Fibonacci series: {e}"
|
| 47 |
|
| 48 |
final_answer = FinalAnswerTool()
|
| 49 |
|
|
|
|
| 66 |
|
| 67 |
agent = CodeAgent(
|
| 68 |
model=model,
|
| 69 |
+
tools=[fibonacci, final_answer], ## add your tools here (don't remove final answer)
|
| 70 |
max_steps=6,
|
| 71 |
verbosity_level=1,
|
| 72 |
grammar=None,
|