Spaces:
Sleeping
Sleeping
Updated for async
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import requests
|
|
| 4 |
import python_weather
|
| 5 |
import pytz
|
| 6 |
import yaml
|
|
|
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
|
@@ -18,17 +19,16 @@ async def getweather(city: str) -> int:
|
|
| 18 |
|
| 19 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 20 |
@tool
|
| 21 |
-
def get_current_temperature_in_city(arg1: str)-> str:
|
| 22 |
-
|
| 23 |
-
"""A tool that fetches the current temperature in Fahrenheit in a specified city
|
| 24 |
Args:
|
| 25 |
arg1: A string representing a city
|
| 26 |
"""
|
| 27 |
try:
|
| 28 |
-
temp = getweather(arg1)
|
| 29 |
-
return f"The current temperature in {arg1} is {temp}
|
| 30 |
-
except
|
| 31 |
-
return f"Error fetching temperature for the city '{arg1}'"
|
| 32 |
|
| 33 |
@tool
|
| 34 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 4 |
import python_weather
|
| 5 |
import pytz
|
| 6 |
import yaml
|
| 7 |
+
import asyncio
|
| 8 |
from tools.final_answer import FinalAnswerTool
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
|
|
|
| 19 |
|
| 20 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 21 |
@tool
|
| 22 |
+
def get_current_temperature_in_city(arg1: str) -> str:
|
| 23 |
+
"""A tool that fetches the current temperature in Fahrenheit in a specified city.
|
|
|
|
| 24 |
Args:
|
| 25 |
arg1: A string representing a city
|
| 26 |
"""
|
| 27 |
try:
|
| 28 |
+
temp = asyncio.run(getweather(arg1)) # Run the async function synchronously
|
| 29 |
+
return f"The current temperature in {arg1} is {temp}°F"
|
| 30 |
+
except Exception as e:
|
| 31 |
+
return f"Error fetching temperature for the city '{arg1}': {str(e)}"
|
| 32 |
|
| 33 |
@tool
|
| 34 |
def get_current_time_in_timezone(timezone: str) -> str:
|