Update app.py
#605
by
Kanishkajoshi19 - opened
app.py
CHANGED
|
@@ -9,14 +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 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +64,7 @@ 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 weather_at_time(location: str, hour: int)-> 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 |
+
"""Returns the weather forecast for a place at a given hour
|
| 15 |
Args:
|
| 16 |
+
location: Name of the city (example: Delhi, Tokyo, Paris)
|
| 17 |
+
hour: Hour of the day in 24-hour format (0-23)
|
| 18 |
"""
|
| 19 |
+
url = f"https://wttr.in/{location}?format=3"
|
| 20 |
+
|
| 21 |
+
try:
|
| 22 |
+
response = requests.get(url)
|
| 23 |
+
weather = response.text
|
| 24 |
+
|
| 25 |
+
return f"Weather in {location} around {hour}:00 → {weather}"
|
| 26 |
+
|
| 27 |
+
except Exception as e:
|
| 28 |
+
return f"Could not retrieve weather for {location}. Error: {str(e)}"
|
| 29 |
|
| 30 |
@tool
|
| 31 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 64 |
|
| 65 |
agent = CodeAgent(
|
| 66 |
model=model,
|
| 67 |
+
tools=[get_current_time_in_timezone,weather_at_time], ## add your tools here (don't remove final answer)
|
| 68 |
max_steps=6,
|
| 69 |
verbosity_level=1,
|
| 70 |
grammar=None,
|