muddokon commited on
Commit
2259bc6
·
verified ·
1 Parent(s): 02a7b45

Create get_pokemon_info.py

Browse files
Files changed (1) hide show
  1. tools/get_pokemon_info.py +25 -0
tools/get_pokemon_info.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any, Optional
2
+ from smolagents.tools import Tool
3
+ import requests
4
+ import markdownify
5
+ import smolagents
6
+ import pokebase as pb
7
+
8
+ 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 = "string"
13
+
14
+ def forward(self, url: str) -> 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