Spaces:
Runtime error
Runtime error
Update app.py
Browse filesadded two tools
app.py
CHANGED
@@ -9,14 +9,40 @@ 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 |
-
arg2: the second argument
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
def predict_age_by_name(name:str)-> str: #it's import to specify the return type
|
13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
+
"""A tool that predict the age from agify based on the name
|
15 |
Args:
|
16 |
+
name: the name of the person
|
|
|
17 |
"""
|
18 |
+
try:
|
19 |
+
response = requests.get("https://api.agify.io", params={"name": name})
|
20 |
+
if response:
|
21 |
+
response_dict = response.json()
|
22 |
+
return response_dict['age']
|
23 |
+
else:
|
24 |
+
raise Exception(f"Non-success status code: {response.status_code}")
|
25 |
+
except Exception as e:
|
26 |
+
return f"Error fetching age for name '{name}': {str(e)}"
|
27 |
+
|
28 |
+
|
29 |
+
@tool
|
30 |
+
def predict_nationality_by_name(name:str)-> str: #it's import to specify the return type
|
31 |
+
#Keep this format for the description / args / args description but feel free to modify the tool
|
32 |
+
"""A tool that predict the nationality from nationalize based on the name
|
33 |
+
Args:
|
34 |
+
name: the name of the person
|
35 |
+
"""
|
36 |
+
try:
|
37 |
+
response = requests.get("https://api.nationalize.io", params={"name": name})
|
38 |
+
if response:
|
39 |
+
response_dict = response.json()
|
40 |
+
return response_dict['country'][0][country_id]
|
41 |
+
else:
|
42 |
+
raise Exception(f"Non-success status code: {response.status_code}")
|
43 |
+
except Exception as e:
|
44 |
+
return f"Error fetching nationality for name '{name}': {str(e)}"
|
45 |
+
|
46 |
|
47 |
@tool
|
48 |
def get_current_time_in_timezone(timezone: str) -> str:
|