Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -112,22 +112,49 @@ class WikiSourceDocument:
|
|
112 |
page: str
|
113 |
page_content: str
|
114 |
|
115 |
-
# ---
|
116 |
@tool
|
117 |
def wiki_search(query: str, load_max_docs: int = 3) -> List[WikiSourceDocument]:
|
118 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
search_docs = WikipediaLoader(query=query, load_max_docs=load_max_docs).load()
|
120 |
return search_docs
|
121 |
|
122 |
@tool
|
123 |
def web_search(query: str, max_results: int = 3) -> Dict[str, str]:
|
124 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
search_docs = TavilySearchResults(max_results=max_results).invoke(input=query)
|
126 |
return {"web_results": search_docs}
|
127 |
|
128 |
@tool
|
129 |
def arxiv_search(query: str, load_max_docs: int = 3) -> Dict[str, str]:
|
130 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
search_docs = ArxivLoader(query=query, load_max_docs=load_max_docs).load()
|
132 |
formatted_search_docs = "\n\n---\n\n".join(
|
133 |
[
|
@@ -139,6 +166,13 @@ def arxiv_search(query: str, load_max_docs: int = 3) -> Dict[str, str]:
|
|
139 |
)
|
140 |
return {"arxiv_results": formatted_search_docs}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
# --- Agente básico optimizado para preguntas ---
|
143 |
class BasicAgent:
|
144 |
def __init__(self, llm=None, max_iterations=3):
|
|
|
112 |
page: str
|
113 |
page_content: str
|
114 |
|
115 |
+
# --- Search Tools ---
|
116 |
@tool
|
117 |
def wiki_search(query: str, load_max_docs: int = 3) -> List[WikiSourceDocument]:
|
118 |
+
"""
|
119 |
+
Search Wikipedia and return a list of documents.
|
120 |
+
|
121 |
+
Args:
|
122 |
+
query (str): The search query to look up on Wikipedia.
|
123 |
+
load_max_docs (int): The maximum number of documents to retrieve.
|
124 |
+
|
125 |
+
Returns:
|
126 |
+
List[WikiSourceDocument]: A list of documents containing source, page, and content.
|
127 |
+
"""
|
128 |
search_docs = WikipediaLoader(query=query, load_max_docs=load_max_docs).load()
|
129 |
return search_docs
|
130 |
|
131 |
@tool
|
132 |
def web_search(query: str, max_results: int = 3) -> Dict[str, str]:
|
133 |
+
"""
|
134 |
+
Perform a web search and return summarized results.
|
135 |
+
|
136 |
+
Args:
|
137 |
+
query (str): The search query to look up on the web.
|
138 |
+
max_results (int): The maximum number of search results to retrieve.
|
139 |
+
|
140 |
+
Returns:
|
141 |
+
Dict[str, str]: A dictionary containing the web search results.
|
142 |
+
"""
|
143 |
search_docs = TavilySearchResults(max_results=max_results).invoke(input=query)
|
144 |
return {"web_results": search_docs}
|
145 |
|
146 |
@tool
|
147 |
def arxiv_search(query: str, load_max_docs: int = 3) -> Dict[str, str]:
|
148 |
+
"""
|
149 |
+
Search Arxiv and return formatted research documents.
|
150 |
+
|
151 |
+
Args:
|
152 |
+
query (str): The search query for scientific papers.
|
153 |
+
load_max_docs (int): The maximum number of documents to retrieve.
|
154 |
+
|
155 |
+
Returns:
|
156 |
+
Dict[str, str]: A dictionary containing formatted Arxiv search results.
|
157 |
+
"""
|
158 |
search_docs = ArxivLoader(query=query, load_max_docs=load_max_docs).load()
|
159 |
formatted_search_docs = "\n\n---\n\n".join(
|
160 |
[
|
|
|
166 |
)
|
167 |
return {"arxiv_results": formatted_search_docs}
|
168 |
|
169 |
+
|
170 |
+
|
171 |
+
|
172 |
+
|
173 |
+
|
174 |
+
|
175 |
+
|
176 |
# --- Agente básico optimizado para preguntas ---
|
177 |
class BasicAgent:
|
178 |
def __init__(self, llm=None, max_iterations=3):
|