Spaces:
Sleeping
Sleeping
Update pipeline.py
Browse files- pipeline.py +25 -3
pipeline.py
CHANGED
|
@@ -209,10 +209,32 @@ def build_rag_chain(vectorstore: FAISS) -> RetrievalQA:
|
|
| 209 |
|
| 210 |
def do_web_search(query: str) -> str:
|
| 211 |
try:
|
|
|
|
|
|
|
|
|
|
| 212 |
search_tool = DuckDuckGoSearchTool()
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
except Exception as e:
|
| 217 |
print(f"Web search failed: {e}")
|
| 218 |
return ""
|
|
|
|
| 209 |
|
| 210 |
def do_web_search(query: str) -> str:
|
| 211 |
try:
|
| 212 |
+
print("DEBUG: Performing a new web search...")
|
| 213 |
+
# model = LiteLLMModel(model_id="gemini/gemini-pro", api_key=os.environ.get("GEMINI_API_KEY"))
|
| 214 |
+
model=HfApiModel()
|
| 215 |
search_tool = DuckDuckGoSearchTool()
|
| 216 |
+
web_agent = CodeAgent(
|
| 217 |
+
tools=[search_tool],
|
| 218 |
+
model=model
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
+
managed_web_agent = ManagedAgent(
|
| 222 |
+
agent=web_agent,
|
| 223 |
+
name="web_search",
|
| 224 |
+
description="Runs a web search for you. Provide your query as an argument."
|
| 225 |
+
)
|
| 226 |
+
|
| 227 |
+
manager_agent = CodeAgent(
|
| 228 |
+
tools=[], # If you have additional tools for the manager, add them here
|
| 229 |
+
model=model,
|
| 230 |
+
managed_agents=[managed_web_agent]
|
| 231 |
+
)
|
| 232 |
+
|
| 233 |
+
new_search_result = manager_agent.run(f"Search for information about: {query}")
|
| 234 |
+
|
| 235 |
+
# 3) Store in cache for future reuse
|
| 236 |
+
store_websearch_result(query, new_search_result)
|
| 237 |
+
return str(new_search_result).strip()
|
| 238 |
except Exception as e:
|
| 239 |
print(f"Web search failed: {e}")
|
| 240 |
return ""
|