Update app.py
#719
by allan141 - opened
app.py
CHANGED
|
@@ -9,15 +9,23 @@ 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 |
-
|
| 14 |
-
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
|
|
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 23 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -55,7 +63,13 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def calculate_age(birth_year: int) -> str:
|
| 13 |
+
"""Calculates a person's approximate age from their birth year.
|
| 14 |
+
|
| 15 |
Args:
|
| 16 |
+
birth_year: The person's year of birth, for example 1995.
|
|
|
|
| 17 |
"""
|
| 18 |
+
current_year = datetime.datetime.now().year
|
| 19 |
+
|
| 20 |
+
if birth_year > current_year:
|
| 21 |
+
return "The birth year cannot be in the future."
|
| 22 |
+
|
| 23 |
+
if birth_year < 1900:
|
| 24 |
+
return "Please provide a birth year greater than or equal to 1900."
|
| 25 |
+
|
| 26 |
+
age = current_year - birth_year
|
| 27 |
|
| 28 |
+
return f"A person born in {birth_year} is approximately {age} years old."
|
| 29 |
@tool
|
| 30 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 31 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 63 |
|
| 64 |
agent = CodeAgent(
|
| 65 |
model=model,
|
| 66 |
+
tools=[
|
| 67 |
+
final_answer,
|
| 68 |
+
calculate_age,
|
| 69 |
+
get_current_time_in_timezone,
|
| 70 |
+
DuckDuckGoSearchTool(),
|
| 71 |
+
image_generation_tool,
|
| 72 |
+
],
|
| 73 |
max_steps=6,
|
| 74 |
verbosity_level=1,
|
| 75 |
grammar=None,
|