Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,20 +3,35 @@ import datetime
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
|
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
|
| 14 |
-
"""A tool that does nothing yet
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
"""
|
| 19 |
-
return "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +70,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,
|
|
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
+
from requests import requests
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
+
def get_number_facts(numbers: list[int]) -> str:
|
| 14 |
+
"""A tool that gets an interesting fact about a given list of numbers
|
|
|
|
| 15 |
Args:
|
| 16 |
+
numbers: A list of numbers to get the information about
|
| 17 |
+
Returns:
|
| 18 |
+
newline-separated interesting facts about given numbers
|
| 19 |
"""
|
| 20 |
+
return "\n".join([
|
| 21 |
+
r.content
|
| 22 |
+
for number in numbers
|
| 23 |
+
if (r := requests.get(f"http://numbersapi.com/{number}").status_code == 200)
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
@tool
|
| 27 |
+
def get_dividors(base_number: int) -> list[int]:
|
| 28 |
+
"""A tool that gets a list of base_number's divisors
|
| 29 |
+
Args:
|
| 30 |
+
base_number: The number to get divisors of
|
| 31 |
+
Returns:
|
| 32 |
+
A list of all `base_number`s divisors
|
| 33 |
+
"""
|
| 34 |
+
return sorted(set([i for i in range(2, abs(base_number)) if base_number%i == 0]))
|
| 35 |
|
| 36 |
@tool
|
| 37 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 70 |
|
| 71 |
agent = CodeAgent(
|
| 72 |
model=model,
|
| 73 |
+
tools=[final_answer, get_number_facts, get_dividors, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
| 74 |
max_steps=6,
|
| 75 |
verbosity_level=1,
|
| 76 |
grammar=None,
|