Update tools/get_pokemon_info.py
Browse files
tools/get_pokemon_info.py
CHANGED
|
@@ -9,17 +9,22 @@ class GetPokemonInfoTool(Tool):
|
|
| 9 |
name = "Get Pokemon Info"
|
| 10 |
description = "Retrieves complete information on a given Pokemon. Use this to get all info for a pokemon."
|
| 11 |
inputs = {'name': {'type': 'string', 'description': 'The name of the pokemon.'}}
|
| 12 |
-
output_type = "
|
| 13 |
|
| 14 |
-
def forward(self, url: str) ->
|
| 15 |
try:
|
| 16 |
import pokebase as pb
|
| 17 |
pokemon = pb.APIResource('pokemon', name)
|
| 18 |
-
|
| 19 |
-
from smolagents.utils import truncate_content
|
| 20 |
except ImportError as e:
|
| 21 |
raise ImportError(
|
| 22 |
"You must install package `pokebase` to run this tool: for instance run `pip install pokebase`."
|
| 23 |
) from e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
def __init__(self, *args, **kwargs):
|
| 25 |
self.is_initialized = False
|
|
|
|
| 9 |
name = "Get Pokemon Info"
|
| 10 |
description = "Retrieves complete information on a given Pokemon. Use this to get all info for a pokemon."
|
| 11 |
inputs = {'name': {'type': 'string', 'description': 'The name of the pokemon.'}}
|
| 12 |
+
output_type = "object"
|
| 13 |
|
| 14 |
+
def forward(self, url: str) -> object:
|
| 15 |
try:
|
| 16 |
import pokebase as pb
|
| 17 |
pokemon = pb.APIResource('pokemon', name)
|
|
|
|
|
|
|
| 18 |
except ImportError as e:
|
| 19 |
raise ImportError(
|
| 20 |
"You must install package `pokebase` to run this tool: for instance run `pip install pokebase`."
|
| 21 |
) from e
|
| 22 |
+
except requests.exceptions.Timeout:
|
| 23 |
+
return "The request timed out. Please try again later."
|
| 24 |
+
except RequestException as e:
|
| 25 |
+
return "Error fetching contents from the pokemon remote API."
|
| 26 |
+
except Exception as e:
|
| 27 |
+
return f"An unexpected error occurred: {str(e)}"
|
| 28 |
+
|
| 29 |
def __init__(self, *args, **kwargs):
|
| 30 |
self.is_initialized = False
|