Update agent.py
Browse files
agent.py
CHANGED
@@ -174,15 +174,10 @@ def read_and_parse_content(input_path: str) -> List[Document]:
|
|
174 |
return documents
|
175 |
|
176 |
# --- Create the final LlamaIndex Tool from the completed function ---
|
177 |
-
|
178 |
-
fn=
|
179 |
-
name="
|
180 |
-
description=
|
181 |
-
"Use this tool to read and extract content from any given file or URL. "
|
182 |
-
"It handles PDF, DOCX, CSV, JSON, XLSX, and image files, as well as web pages, "
|
183 |
-
"YouTube videos (transcripts), and MP3 audio (transcripts). It also reads plain text "
|
184 |
-
"from files like .py or .txt. The input MUST be a single valid file path or a URL."
|
185 |
-
)
|
186 |
)
|
187 |
|
188 |
def create_rag_tool_fn(documents: List[Document], query: str = None) -> Union[QueryEngineTool, str]:
|
@@ -274,16 +269,9 @@ def information_retrieval_fn (paths : List[str], query : str = None) -> Union[Q
|
|
274 |
information_retrieval_tool = FunctionTool.from_defaults(
|
275 |
fn=information_retrieval_fn,
|
276 |
name="information_retrieval_tool",
|
277 |
-
description=
|
278 |
-
"This is the BEST and OPTIMAL tool to query information from documents parsed from URLs or files. "
|
279 |
-
"Use this tool to build a Retrieval Augmented Generation (RAG) engine from documents AND optionally query it immediately. "
|
280 |
-
"Input: documents (list of documents) and optional query parameter. "
|
281 |
-
"If no query is provided: creates and returns a RAG query engine tool for later use. "
|
282 |
-
"If query is provided: creates the RAG engine AND immediately returns the answer to your question. "
|
283 |
-
"ALWAYS use this tool when you need to retrieve specific information from documents obtained via URLs or file. "
|
284 |
-
"This dual-mode tool enables both RAG engine creation and direct question-answering in one step, making it the most efficient approach for document-based information retrieval."
|
285 |
-
)
|
286 |
)
|
|
|
287 |
# 1. Create the base DuckDuckGo search tool from the official spec.
|
288 |
# This tool returns text summaries of search results, not just URLs.
|
289 |
base_duckduckgo_tool = DuckDuckGoSearchToolSpec().to_tool_list()[1]
|
|
|
174 |
return documents
|
175 |
|
176 |
# --- Create the final LlamaIndex Tool from the completed function ---
|
177 |
+
extract_url_tool = FunctionTool.from_defaults(
|
178 |
+
fn=search_and_extract_top_url,
|
179 |
+
name="extract_url_tool",
|
180 |
+
description="Searches web and returns a relevant URL based on a query"
|
|
|
|
|
|
|
|
|
|
|
181 |
)
|
182 |
|
183 |
def create_rag_tool_fn(documents: List[Document], query: str = None) -> Union[QueryEngineTool, str]:
|
|
|
269 |
information_retrieval_tool = FunctionTool.from_defaults(
|
270 |
fn=information_retrieval_fn,
|
271 |
name="information_retrieval_tool",
|
272 |
+
description="Retrieves and queries information from documents, URLs, or files using RAG"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
)
|
274 |
+
|
275 |
# 1. Create the base DuckDuckGo search tool from the official spec.
|
276 |
# This tool returns text summaries of search results, not just URLs.
|
277 |
base_duckduckgo_tool = DuckDuckGoSearchToolSpec().to_tool_list()[1]
|