Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -86,41 +86,71 @@ serper_tool = FunctionTool.from_defaults(
|
|
86 |
)
|
87 |
|
88 |
# --- Agents ---
|
|
|
89 |
google_rss_agent = FunctionAgent(
|
90 |
-
name="google_rss_agent",
|
|
|
|
|
91 |
tools=[google_rss_tool],
|
92 |
-
|
|
|
93 |
)
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
97 |
system_prompt=(
|
98 |
-
"When asked for details on a headline
|
99 |
-
"1
|
100 |
-
"2
|
101 |
-
"
|
102 |
-
)
|
|
|
|
|
|
|
103 |
)
|
|
|
|
|
104 |
weather_agent = ReActAgent(
|
105 |
-
name="weather_agent",
|
106 |
-
|
107 |
-
system_prompt="You are a weather agent."
|
|
|
|
|
108 |
)
|
|
|
|
|
109 |
search_agent = ReActAgent(
|
110 |
-
name="search_agent",
|
|
|
|
|
111 |
tools=[search_tool],
|
112 |
-
|
113 |
)
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
description="Return agent name.")],
|
119 |
system_prompt=(
|
120 |
-
"
|
|
|
121 |
"['google_rss_agent','weather_agent','search_agent','web_browsing_agent']."
|
122 |
),
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
)
|
125 |
|
126 |
workflow = AgentWorkflow(
|
|
|
86 |
)
|
87 |
|
88 |
# --- Agents ---
|
89 |
+
# 1. Google News RSS Agent (replaces old google_news_agent)
|
90 |
google_rss_agent = FunctionAgent(
|
91 |
+
name="google_rss_agent",
|
92 |
+
description="Fetches latest headlines and URLs from Google News RSS feed.",
|
93 |
+
system_prompt="You are an agent that fetches the latest headlines and URLs from the Google News RSS feed.",
|
94 |
tools=[google_rss_tool],
|
95 |
+
llm=openai_llm,
|
96 |
+
memory=memory,
|
97 |
)
|
98 |
+
|
99 |
+
# 2. Web Browsing Agent
|
100 |
+
web_browsing_agent = ReActAgent(
|
101 |
+
name="web_browsing_agent",
|
102 |
+
description="Fetches Serper URLs, navigates to each link, extracts the text and builds a summary",
|
103 |
system_prompt=(
|
104 |
+
"You are a news-content agent. When asked for details on a headline:\n"
|
105 |
+
"1. Call `fetch_news_from_serper(query)` to get JSON with article URLs.\n"
|
106 |
+
"2. For each top URL, call `web_navigate(url)` then `web_extract_text()`.\n"
|
107 |
+
"3. Synthesize those texts into a concise summary."
|
108 |
+
),
|
109 |
+
tools=[serper_news_tool, navigate_tool, extract_text_tool, extract_links_tool],
|
110 |
+
llm=llm,
|
111 |
+
memory=memory,
|
112 |
)
|
113 |
+
|
114 |
+
# 3. Weather Agent
|
115 |
weather_agent = ReActAgent(
|
116 |
+
name="weather_agent",
|
117 |
+
description="Answers weather-related questions.",
|
118 |
+
system_prompt="You are a weather agent that provides current weather and forecasts.",
|
119 |
+
tools=[weather_tool, forecast_tool],
|
120 |
+
llm=openai_llm,
|
121 |
)
|
122 |
+
|
123 |
+
# 4. DuckDuckGo Search Agent
|
124 |
search_agent = ReActAgent(
|
125 |
+
name="search_agent",
|
126 |
+
description="Searches general info using DuckDuckGo.",
|
127 |
+
system_prompt="You are a search agent that uses DuckDuckGo to answer questions.",
|
128 |
tools=[search_tool],
|
129 |
+
llm=openai_llm,
|
130 |
)
|
131 |
+
|
132 |
+
router_agent = ReActAgent(
|
133 |
+
name="router_agent",
|
134 |
+
description="Routes queries to the correct specialist agent.",
|
|
|
135 |
system_prompt=(
|
136 |
+
"You are RouterAgent. "
|
137 |
+
"Given the user query, reply with exactly one name from: "
|
138 |
"['google_rss_agent','weather_agent','search_agent','web_browsing_agent']."
|
139 |
),
|
140 |
+
llm=llm,
|
141 |
+
tools=[
|
142 |
+
FunctionTool.from_defaults(
|
143 |
+
fn=lambda ctx, choice: choice,
|
144 |
+
name="choose_agent",
|
145 |
+
description="Return the chosen agent name."
|
146 |
+
)
|
147 |
+
],
|
148 |
+
can_handoff_to=[
|
149 |
+
"google_rss_agent",
|
150 |
+
"weather_agent",
|
151 |
+
"search_agent",
|
152 |
+
"web_browsing_agent",
|
153 |
+
],
|
154 |
)
|
155 |
|
156 |
workflow = AgentWorkflow(
|