Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ import re
|
|
| 12 |
import requests
|
| 13 |
import pytz
|
| 14 |
import yaml
|
|
|
|
| 15 |
|
| 16 |
from tools.final_answer import FinalAnswerTool
|
| 17 |
from Gradio_UI import GradioUI
|
|
@@ -19,9 +20,12 @@ from Gradio_UI import GradioUI
|
|
| 19 |
|
| 20 |
# ---- Custom Tools ----
|
| 21 |
|
|
|
|
| 22 |
@tool
|
| 23 |
-
def get_current_time_in_timezone(
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
try:
|
| 26 |
tz = pytz.timezone(timezone)
|
| 27 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
|
@@ -31,8 +35,10 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 31 |
|
| 32 |
|
| 33 |
@tool
|
| 34 |
-
def fetch_page_title(
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
try:
|
| 37 |
resp = requests.get(url, timeout=10)
|
| 38 |
resp.raise_for_status()
|
|
@@ -44,12 +50,15 @@ def fetch_page_title(url: str) -> str:
|
|
| 44 |
|
| 45 |
|
| 46 |
@tool
|
| 47 |
-
def echo_and_length(
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
t = text.strip()
|
| 50 |
return f"Echo: {t}\nLength: {len(t)}"
|
| 51 |
|
| 52 |
|
|
|
|
| 53 |
# ---- Model & Tools wiring ----
|
| 54 |
|
| 55 |
final_answer = FinalAnswerTool()
|
|
|
|
| 12 |
import requests
|
| 13 |
import pytz
|
| 14 |
import yaml
|
| 15 |
+
from typing import Annotated
|
| 16 |
|
| 17 |
from tools.final_answer import FinalAnswerTool
|
| 18 |
from Gradio_UI import GradioUI
|
|
|
|
| 20 |
|
| 21 |
# ---- Custom Tools ----
|
| 22 |
|
| 23 |
+
|
| 24 |
@tool
|
| 25 |
+
def get_current_time_in_timezone(
|
| 26 |
+
timezone: Annotated[str, "IANA timezone like 'America/Los_Angeles'"]
|
| 27 |
+
) -> str:
|
| 28 |
+
"""Return the current local time for the given timezone."""
|
| 29 |
try:
|
| 30 |
tz = pytz.timezone(timezone)
|
| 31 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
@tool
|
| 38 |
+
def fetch_page_title(
|
| 39 |
+
url: Annotated[str, "An http/https URL to fetch"]
|
| 40 |
+
) -> str:
|
| 41 |
+
"""Fetch the page and return its <title> text."""
|
| 42 |
try:
|
| 43 |
resp = requests.get(url, timeout=10)
|
| 44 |
resp.raise_for_status()
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
@tool
|
| 53 |
+
def echo_and_length(
|
| 54 |
+
text: Annotated[str, "Any text to echo back"]
|
| 55 |
+
) -> str:
|
| 56 |
+
"""Echo the text and report its character length."""
|
| 57 |
t = text.strip()
|
| 58 |
return f"Echo: {t}\nLength: {len(t)}"
|
| 59 |
|
| 60 |
|
| 61 |
+
|
| 62 |
# ---- Model & Tools wiring ----
|
| 63 |
|
| 64 |
final_answer = FinalAnswerTool()
|