Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -47,15 +47,16 @@ search_tool = FunctionTool.from_defaults(duck_spec.duckduckgo_full_search)
|
|
47 |
|
48 |
# Weather
|
49 |
weather_spec = OpenWeatherMapToolSpec(key=OPENWEATHERMAP_KEY)
|
50 |
-
|
51 |
-
|
|
|
52 |
name="current_weather",
|
53 |
-
description="Get the current weather
|
54 |
)
|
55 |
-
|
56 |
-
|
57 |
name="weather_forecast",
|
58 |
-
description="Get tomorrow
|
59 |
)
|
60 |
|
61 |
# Playwright (synchronous start)
|
@@ -63,9 +64,21 @@ async def _start_browser():
|
|
63 |
return await PlaywrightToolSpec.create_async_playwright_browser(headless=True)
|
64 |
browser = asyncio.get_event_loop().run_until_complete(_start_browser())
|
65 |
pw_spec = PlaywrightToolSpec.from_async_browser(browser)
|
66 |
-
navigate_tool = FunctionTool.from_defaults(
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
# Google News RSS
|
71 |
def fetch_google_news_rss():
|
@@ -87,7 +100,7 @@ async def fetch_serper(ctx, query):
|
|
87 |
r = await s.get(url, headers=hdr)
|
88 |
r.raise_for_status()
|
89 |
return await r.json()
|
90 |
-
|
91 |
fetch_serper, name="fetch_news_from_serper",
|
92 |
description="Search today’s news via Serper."
|
93 |
)
|
|
|
47 |
|
48 |
# Weather
|
49 |
weather_spec = OpenWeatherMapToolSpec(key=OPENWEATHERMAP_KEY)
|
50 |
+
weather_tool_spec = OpenWeatherMapToolSpec(key=openweather_api_key)
|
51 |
+
weather_tool = FunctionTool.from_defaults(
|
52 |
+
weather_tool_spec.weather_at_location,
|
53 |
name="current_weather",
|
54 |
+
description="Get the current weather at a specific location (city, country)."
|
55 |
)
|
56 |
+
forecast_tool = FunctionTool.from_defaults(
|
57 |
+
weather_tool_spec.forecast_tommorrow_at_location,
|
58 |
name="weather_forecast",
|
59 |
+
description="Get tomorrow's weather forecast for a specific location (city, country)."
|
60 |
)
|
61 |
|
62 |
# Playwright (synchronous start)
|
|
|
64 |
return await PlaywrightToolSpec.create_async_playwright_browser(headless=True)
|
65 |
browser = asyncio.get_event_loop().run_until_complete(_start_browser())
|
66 |
pw_spec = PlaywrightToolSpec.from_async_browser(browser)
|
67 |
+
navigate_tool = FunctionTool.from_defaults(
|
68 |
+
playwright_tool_spec.navigate_to,
|
69 |
+
name="web_navigate",
|
70 |
+
description="Navigate to a specific URL."
|
71 |
+
)
|
72 |
+
extract_text_tool = FunctionTool.from_defaults(
|
73 |
+
playwright_tool_spec.extract_text,
|
74 |
+
name="web_extract_text",
|
75 |
+
description="Extract all text from the current page."
|
76 |
+
)
|
77 |
+
extract_links_tool = FunctionTool.from_defaults(
|
78 |
+
playwright_tool_spec.extract_hyperlinks,
|
79 |
+
name="web_extract_links",
|
80 |
+
description="Extract all hyperlinks from the current page."
|
81 |
+
)
|
82 |
|
83 |
# Google News RSS
|
84 |
def fetch_google_news_rss():
|
|
|
100 |
r = await s.get(url, headers=hdr)
|
101 |
r.raise_for_status()
|
102 |
return await r.json()
|
103 |
+
serper_news_tool = FunctionTool.from_defaults(
|
104 |
fetch_serper, name="fetch_news_from_serper",
|
105 |
description="Search today’s news via Serper."
|
106 |
)
|