Update app.py
Browse files
app.py
CHANGED
|
@@ -9,22 +9,13 @@ 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 does nothing yet
|
| 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.
|
| 24 |
-
Args:
|
| 25 |
-
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
| 26 |
-
"""
|
| 27 |
-
try:
|
| 28 |
# Create timezone object
|
| 29 |
tz = pytz.timezone(timezone)
|
| 30 |
# Get current time in that timezone
|
|
@@ -33,7 +24,23 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
| 39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def get_current_time_in_timezone(timezone: 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 does nothing yet
|
| 15 |
Args:
|
| 16 |
+
timezone: A string representing a valid timezone (e.g., 'Amirica/New_York').
|
|
|
|
| 17 |
"""
|
| 18 |
+
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Create timezone object
|
| 20 |
tz = pytz.timezone(timezone)
|
| 21 |
# Get current time in that timezone
|
|
|
|
| 24 |
except Exception as e:
|
| 25 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 26 |
|
| 27 |
+
@tool
|
| 28 |
+
def get_weather(city: str) -> str:
|
| 29 |
+
"""A tool that fetches the current wether for a given city.
|
| 30 |
+
Args:
|
| 31 |
+
city: Name of the city (e.g., 'New York').
|
| 32 |
+
"""
|
| 33 |
|
| 34 |
+
try:
|
| 35 |
+
url = f"https://wttr.in/{city}?format=%C+%t"
|
| 36 |
+
response = requests.get(url)
|
| 37 |
+
if response.status_code == 200:
|
| 38 |
+
return f"The current weather in {city}" is: {response.text}
|
| 39 |
+
else"
|
| 40 |
+
return "Failed to retrieve weather data."
|
| 41 |
+
except Exception as e:
|
| 42 |
+
return f"Error fetching weather: {str(e)}"
|
| 43 |
+
|
| 44 |
final_answer = FinalAnswerTool()
|
| 45 |
|
| 46 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|