Spaces:
Running
Running
pokeinformation returns moves and evolution chains
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import pytz
|
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
import os
|
|
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
@@ -46,46 +47,64 @@ custom_role_conversions=None,
|
|
46 |
|
47 |
@tool
|
48 |
def get_pokemon_information(pokemon_name: str) -> dict:
|
49 |
-
|
50 |
This tool gives information about a pokemon.
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
61 |
Use this tool to get the information about a pokemon else use the web search tool.
|
|
|
62 |
Args:
|
63 |
pokemon_name: The name of the pokemon.
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
return pokemon_info
|
90 |
|
91 |
web_search_tool = DuckDuckGoSearchTool()
|
|
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
import os
|
8 |
+
import pokebase as pb
|
9 |
|
10 |
from Gradio_UI import GradioUI
|
11 |
|
|
|
47 |
|
48 |
@tool
|
49 |
def get_pokemon_information(pokemon_name: str) -> dict:
|
50 |
+
"""
|
51 |
This tool gives information about a pokemon.
|
52 |
+
Just pass the name of the pokemon as an argument in the string format.
|
53 |
+
|
54 |
+
The information given is:
|
55 |
+
- Moves
|
56 |
+
- Abilities
|
57 |
+
- Types
|
58 |
+
- Pokémon Evolution Chains
|
59 |
+
- base_experience
|
60 |
+
- stats
|
61 |
+
- weight
|
62 |
+
- height
|
63 |
+
|
64 |
Use this tool to get the information about a pokemon else use the web search tool.
|
65 |
+
|
66 |
Args:
|
67 |
pokemon_name: The name of the pokemon.
|
68 |
+
|
69 |
+
Returns:
|
70 |
+
dict: A dictionary conaining The information about the pokemon like moves, abilities, types, evolution chains, base experience, stats, weight, height, sprites
|
71 |
+
"""
|
72 |
+
if type(pokemon_name) != str:
|
73 |
+
return "Please pass the pokemon name as a string"
|
74 |
+
|
75 |
+
client = pb
|
76 |
+
pokemon = client.pokemon(pokemon_name)
|
77 |
+
if pokemon is None:
|
78 |
+
return "Please pass a valid pokemon name"
|
79 |
+
|
80 |
+
|
81 |
+
evolution_number = client.pokemon_species(pokemon_name).evolution_chain.id
|
82 |
+
e_chain = client.evolution_chain(evolution_number).chain
|
83 |
+
|
84 |
+
|
85 |
+
e2 = "none"
|
86 |
+
e3 = "none"
|
87 |
+
e1 = e_chain.species.name
|
88 |
+
if len(e_chain.evolves_to)>0:
|
89 |
+
e2 = e_chain.evolves_to[0].species.name
|
90 |
+
if len(e_chain.evolves_to[0].evolves_to)>0:
|
91 |
+
e3 = e_chain.evolves_to[0].evolves_to[0].species.name
|
92 |
+
|
93 |
+
chain_str = f"Evolution chain is: {e1} -> {e2} -> {e3}"
|
94 |
+
|
95 |
+
|
96 |
+
pokemon_info = {
|
97 |
+
"moves": str([move.name for move in pb.move(pokemon_name).results]),
|
98 |
+
"types": str([type.type.name for type in pokemon.types]),
|
99 |
+
"stats": str({ stats.stat.name: pokemon.stats[i].base_stat for i, stats in enumerate(pokemon.stats)}),
|
100 |
+
"expierience": pokemon.base_experience,
|
101 |
+
"species": pokemon.species,
|
102 |
+
"weight": pokemon.weight,
|
103 |
+
"height": pokemon.height,
|
104 |
+
"abilities": str([ability.ability for ability in pokemon.abilities]),
|
105 |
+
"evolution_chain": chain_str
|
106 |
+
}
|
107 |
+
|
108 |
return pokemon_info
|
109 |
|
110 |
web_search_tool = DuckDuckGoSearchTool()
|