Phoenix21 commited on
Commit
d7a56c3
·
verified ·
1 Parent(s): 341f0a0

Update pipeline.py

Browse files
Files changed (1) hide show
  1. 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
- search_agent = ManagedAgent(llm=gemini_llm, tools=[search_tool])
214
- search_result = search_agent.run(f"Search for information about: {query}")
215
- return str(search_result).strip()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ""