Spaces:
Sleeping
Sleeping
Added get_random_name tool. Still to be parameterized.
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ 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
|
|
@@ -22,6 +23,31 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 22 |
return "What magic will you build ?"
|
| 23 |
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
@tool
|
| 26 |
def get_corporate_bullshit_text()-> str:
|
| 27 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
|
@@ -103,7 +129,12 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 103 |
|
| 104 |
agent = CodeAgent(
|
| 105 |
model=model,
|
| 106 |
-
tools=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
max_steps=6,
|
| 108 |
verbosity_level=1,
|
| 109 |
grammar=None,
|
|
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
+
import random
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
|
|
|
| 23 |
return "What magic will you build ?"
|
| 24 |
|
| 25 |
|
| 26 |
+
@tool
|
| 27 |
+
def get_random_name(nationality: str) -> str:
|
| 28 |
+
"""A tool that retrieves a random name
|
| 29 |
+
Args:
|
| 30 |
+
nationality: A string representing a valid nationality (e.g., 'Mexican').
|
| 31 |
+
"""
|
| 32 |
+
try:
|
| 33 |
+
url = 'https://api.fbi.gov/wanted/v1/list'
|
| 34 |
+
params = {'field_offices': 'philadelphia'} # todo make params a parameter
|
| 35 |
+
response = requests.get(url, params= params)
|
| 36 |
+
|
| 37 |
+
if response.status_code == 200:
|
| 38 |
+
data = response.json()
|
| 39 |
+
# get a random item of the list
|
| 40 |
+
nr_of_items = len(data['items'])
|
| 41 |
+
random_int = random.randint(0,nr_of_items-1)
|
| 42 |
+
# get the title and return it
|
| 43 |
+
return data['items'][str(random_int)]["title"]
|
| 44 |
+
else:
|
| 45 |
+
return f'Error - get_random_name() -> Response status code was not good ({response.status_code})'
|
| 46 |
+
|
| 47 |
+
except Exception as e:
|
| 48 |
+
return f"Error - get_random_name() -> Exception - Well this didn't work"
|
| 49 |
+
|
| 50 |
+
|
| 51 |
@tool
|
| 52 |
def get_corporate_bullshit_text()-> str:
|
| 53 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
|
|
|
| 129 |
|
| 130 |
agent = CodeAgent(
|
| 131 |
model=model,
|
| 132 |
+
tools=[
|
| 133 |
+
final_answer,
|
| 134 |
+
get_corporate_bullshit_text,
|
| 135 |
+
get_techy_phrases_text,
|
| 136 |
+
get_random_name
|
| 137 |
+
], ## add your tools here (don't remove final answer)
|
| 138 |
max_steps=6,
|
| 139 |
verbosity_level=1,
|
| 140 |
grammar=None,
|