Jialun He commited on
Commit
53e864e
·
1 Parent(s): eb4d348

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +5 -24
agent.py CHANGED
@@ -83,30 +83,11 @@ def wiki_search(query: str) -> str:
83
 
84
  @tool
85
  def web_search(query: str) -> str:
86
- """Search Tavily and format up to 3 documents."""
87
- retriever = TavilyRetriever(k=3)
88
- docs = retriever.get_relevant_documents(query)
89
-
90
- formatted_docs = "\n\n---\n\n".join(
91
- [
92
- f'<Document source="{doc.metadata.get("source", "unknown")}" page="{doc.metadata.get("page", "")}">\n{doc.page_content}\n</Document>'
93
- for doc in docs
94
- ]
95
- )
96
- return {"web_results": formatted_docs}
97
-
98
-
99
- # def web_search(query: str) -> str:
100
- # """Search Tavily for a query and return maximum 3 results.
101
- # Args:
102
- # query: The search query."""
103
- # search_docs = TavilySearchResults(max_results=3).invoke(query) # Fixed: pass query as positional argument
104
- # formatted_search_docs = "\n\n---\n\n".join(
105
- # [
106
- # f'<Document source="{doc.metadata["source"]}" page="{doc.metadata.get("page", "")}"/>\n{doc.page_content}\n</Document>'
107
- # for doc in search_docs
108
- # ])
109
- # return formatted_search_docs # Also fixed the return type issue
110
 
111
  @tool
112
  def arvix_search(query: str) -> str:
 
83
 
84
  @tool
85
  def web_search(query: str) -> str:
86
+ """Search Tavily for a query and return maximum 3 results.
87
+ Args:
88
+ query: The search query."""
89
+ search_docs = TavilySearchResults(max_results=3).invoke(query) # Fixed: pass query as positional argument
90
+ return {"web_results": search_docs} # Also fixed the return type issue
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
  @tool
93
  def arvix_search(query: str) -> str: