Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,21 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
@@ -55,7 +70,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
@tool
|
| 11 |
+
def get_weather(city: str) -> str:
|
| 12 |
+
"""Fetches current weather info for a given city using wttr.in
|
| 13 |
+
Args:
|
| 14 |
+
city: Name of the city to get the weather for.
|
| 15 |
+
"""
|
| 16 |
+
try:
|
| 17 |
+
response = requests.get(f"https://wttr.in/{city}?format=3")
|
| 18 |
+
if response.status_code == 200:
|
| 19 |
+
return f"The current weather in {city} is: {response.text}"
|
| 20 |
+
else:
|
| 21 |
+
return f"Failed to fetch weather data for {city}."
|
| 22 |
+
except Exception as e:
|
| 23 |
+
return f"Error: {str(e)}"
|
| 24 |
+
|
| 25 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 26 |
@tool
|
| 27 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 70 |
|
| 71 |
agent = CodeAgent(
|
| 72 |
model=model,
|
| 73 |
+
tools=[final_answer,get_current_time_in_timezone, get_weather],
|
| 74 |
max_steps=6,
|
| 75 |
verbosity_level=1,
|
| 76 |
grammar=None,
|