Spaces:
Runtime error
Runtime error
Fix my_cutom_tool: return on try
Browse files
app.py
CHANGED
|
@@ -20,6 +20,9 @@ def my_cutom_tool(city_name:str, api_key: str)-> str: #it's import to specify th
|
|
| 20 |
|
| 21 |
try:
|
| 22 |
r = requests.get(weather_url,timeout=3)
|
|
|
|
|
|
|
|
|
|
| 23 |
r.raise_for_status()
|
| 24 |
except requests.exceptions.HTTPError as errh:
|
| 25 |
print ("Http Error:",errh)
|
|
@@ -29,10 +32,7 @@ def my_cutom_tool(city_name:str, api_key: str)-> str: #it's import to specify th
|
|
| 29 |
print ("Timeout Error:",errt)
|
| 30 |
except requests.exceptions.RequestException as err:
|
| 31 |
print ("OOps: Something Else",err)
|
| 32 |
-
|
| 33 |
-
result = r.json()
|
| 34 |
-
return_msg = "The current weather in " + result['location']['region'] + " is " + result['current']['condition']['text']
|
| 35 |
-
return return_msg
|
| 36 |
|
| 37 |
@tool
|
| 38 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 20 |
|
| 21 |
try:
|
| 22 |
r = requests.get(weather_url,timeout=3)
|
| 23 |
+
result = r.json()
|
| 24 |
+
return_msg = "The current weather in " + result['location']['region'] + " is " + result['current']['condition']['text']
|
| 25 |
+
return return_msg
|
| 26 |
r.raise_for_status()
|
| 27 |
except requests.exceptions.HTTPError as errh:
|
| 28 |
print ("Http Error:",errh)
|
|
|
|
| 32 |
print ("Timeout Error:",errt)
|
| 33 |
except requests.exceptions.RequestException as err:
|
| 34 |
print ("OOps: Something Else",err)
|
| 35 |
+
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
@tool
|
| 38 |
def get_current_time_in_timezone(timezone: str) -> str:
|