Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,16 +7,27 @@ 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 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
-
"""A tool that
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -55,7 +66,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
|
|
10 |
@tool
|
11 |
+
def get_pokemon_abilities(name:str,)-> str: #it's import to specify the return type
|
12 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
13 |
+
"""A tool that given a poken name it returns its ability names.
|
14 |
Args:
|
15 |
+
name: name of the Pokémon
|
16 |
+
Returns:
|
17 |
+
A comma-separated string of the Pokémon's abilities, or an error message if not found
|
18 |
"""
|
19 |
+
|
20 |
+
url = f"https://pokeapi.co/api/v2/pokemon/{name.lower()}"
|
21 |
+
response = requests.get(url)
|
22 |
+
|
23 |
+
if response.status_code == 200:
|
24 |
+
data = response.json()
|
25 |
+
abilities = [ ability['ability']['name'] for ability in data['abilities']]
|
26 |
+
|
27 |
+
return ", ".join(abilities)
|
28 |
+
|
29 |
+
|
30 |
+
return "Pokémon not found or invalid name provided."
|
31 |
|
32 |
@tool
|
33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
66 |
|
67 |
agent = CodeAgent(
|
68 |
model=model,
|
69 |
+
tools=[final_answer, get_pokemon_abilities, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
70 |
max_steps=6,
|
71 |
verbosity_level=1,
|
72 |
grammar=None,
|