Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,10 +9,16 @@ from Gradio_UI import GradioUI
|
|
| 9 |
# Tool personalizzato per ottenere l'ora attuale in qualsiasi città
|
| 10 |
@tool
|
| 11 |
def get_current_time(city: str) -> str:
|
| 12 |
-
"""Restituisce l'ora attuale per una città specificata dall'utente.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
try:
|
| 14 |
-
|
| 15 |
-
timezone = pytz.timezone(pytz.country_timezones.get(city.lower(), 'UTC'))
|
| 16 |
local_time = datetime.datetime.now(timezone).strftime("%Y-%m-%d %H:%M:%S")
|
| 17 |
return f"L'ora attuale a {city.capitalize()} è: {local_time}"
|
| 18 |
except Exception as e:
|
|
@@ -48,7 +54,14 @@ agent = CodeAgent(
|
|
| 48 |
# Funzione per interpretare la richiesta e restituire l'ora della città specificata
|
| 49 |
@tool
|
| 50 |
def interpret_and_respond(query: str) -> str:
|
| 51 |
-
"""Interpreta la richiesta dell'utente e restituisce l'ora per una città specificata.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
words = query.lower().split()
|
| 53 |
if "time" in words or "ora" in words:
|
| 54 |
for word in words:
|
|
|
|
| 9 |
# Tool personalizzato per ottenere l'ora attuale in qualsiasi città
|
| 10 |
@tool
|
| 11 |
def get_current_time(city: str) -> str:
|
| 12 |
+
"""Restituisce l'ora attuale per una città specificata dall'utente.
|
| 13 |
+
|
| 14 |
+
Args:
|
| 15 |
+
city (str): Il nome della città per cui ottenere l'ora.
|
| 16 |
+
|
| 17 |
+
Returns:
|
| 18 |
+
str: L'ora attuale nella città richiesta oppure un messaggio di errore.
|
| 19 |
+
"""
|
| 20 |
try:
|
| 21 |
+
timezone = pytz.timezone(pytz.country_timezones.get(city.lower(), 'Europe/Rome'))
|
|
|
|
| 22 |
local_time = datetime.datetime.now(timezone).strftime("%Y-%m-%d %H:%M:%S")
|
| 23 |
return f"L'ora attuale a {city.capitalize()} è: {local_time}"
|
| 24 |
except Exception as e:
|
|
|
|
| 54 |
# Funzione per interpretare la richiesta e restituire l'ora della città specificata
|
| 55 |
@tool
|
| 56 |
def interpret_and_respond(query: str) -> str:
|
| 57 |
+
"""Interpreta la richiesta dell'utente e restituisce l'ora per una città specificata.
|
| 58 |
+
|
| 59 |
+
Args:
|
| 60 |
+
query (str): La domanda dell'utente.
|
| 61 |
+
|
| 62 |
+
Returns:
|
| 63 |
+
str: L'ora attuale nella città richiesta oppure un messaggio di errore.
|
| 64 |
+
"""
|
| 65 |
words = query.lower().split()
|
| 66 |
if "time" in words or "ora" in words:
|
| 67 |
for word in words:
|