Denis Davydov
commited on
Commit
·
11d4518
1
Parent(s):
2e79a34
leave just one web_search_tool
Browse files
tools.py
CHANGED
@@ -20,25 +20,6 @@ from dotenv import load_dotenv
|
|
20 |
# Load environment variables
|
21 |
load_dotenv()
|
22 |
|
23 |
-
def web_search_tool_func(query: str) -> str:
|
24 |
-
"""Enhanced web search with Wikipedia priority using DDGS."""
|
25 |
-
try:
|
26 |
-
# Try Wikipedia-specific search first
|
27 |
-
print(f"🔍 Performing web search for: {query}")
|
28 |
-
wiki_results = search_wikipedia(query)
|
29 |
-
if wiki_results and len(wiki_results.strip()) > 100: # Good Wikipedia result
|
30 |
-
return f"Wikipedia search results:\n{wiki_results}"
|
31 |
-
|
32 |
-
# Fall back to general web search
|
33 |
-
general_results = search_general(query)
|
34 |
-
if general_results:
|
35 |
-
return f"Web search results:\n{general_results}"
|
36 |
-
else:
|
37 |
-
return "No relevant search results found."
|
38 |
-
|
39 |
-
except Exception as e:
|
40 |
-
return f"Web search failed: {str(e)}"
|
41 |
-
|
42 |
def search_wikipedia(query: str) -> str:
|
43 |
"""Search Wikipedia specifically for factual information."""
|
44 |
try:
|
@@ -104,12 +85,6 @@ def search_general(query: str) -> str:
|
|
104 |
except Exception as e:
|
105 |
return f"General search failed: {str(e)}"
|
106 |
|
107 |
-
web_search_tool = Tool(
|
108 |
-
name="web_search",
|
109 |
-
func=web_search_tool_func,
|
110 |
-
description="Searches the web for current information. Use this for factual questions, recent events, or when you need to find information not in your training data."
|
111 |
-
)
|
112 |
-
|
113 |
def file_download_tool_func(task_id: str) -> str:
|
114 |
"""Downloads a file associated with a GAIA task ID."""
|
115 |
try:
|
@@ -399,7 +374,7 @@ def search_documents_with_vector_store(documents: list, query: str) -> str:
|
|
399 |
except Exception as e:
|
400 |
return f"Vector search failed: {str(e)}"
|
401 |
|
402 |
-
|
403 |
name="enhanced_web_retrieval",
|
404 |
func=enhanced_web_retrieval_tool_func,
|
405 |
description="Enhanced Wikipedia-only search with vector retrieval. Fetches full content from English Wikipedia pages and uses semantic search to find relevant information. Use this for factual questions that need detailed Wikipedia content analysis."
|
@@ -408,7 +383,6 @@ enhanced_web_retrieval_tool = Tool(
|
|
408 |
# List of all tools for easy import
|
409 |
agent_tools = [
|
410 |
web_search_tool,
|
411 |
-
enhanced_web_retrieval_tool,
|
412 |
file_download_tool,
|
413 |
image_analysis_tool,
|
414 |
calculator_tool,
|
|
|
20 |
# Load environment variables
|
21 |
load_dotenv()
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
def search_wikipedia(query: str) -> str:
|
24 |
"""Search Wikipedia specifically for factual information."""
|
25 |
try:
|
|
|
85 |
except Exception as e:
|
86 |
return f"General search failed: {str(e)}"
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
def file_download_tool_func(task_id: str) -> str:
|
89 |
"""Downloads a file associated with a GAIA task ID."""
|
90 |
try:
|
|
|
374 |
except Exception as e:
|
375 |
return f"Vector search failed: {str(e)}"
|
376 |
|
377 |
+
web_search_tool = Tool(
|
378 |
name="enhanced_web_retrieval",
|
379 |
func=enhanced_web_retrieval_tool_func,
|
380 |
description="Enhanced Wikipedia-only search with vector retrieval. Fetches full content from English Wikipedia pages and uses semantic search to find relevant information. Use this for factual questions that need detailed Wikipedia content analysis."
|
|
|
383 |
# List of all tools for easy import
|
384 |
agent_tools = [
|
385 |
web_search_tool,
|
|
|
386 |
file_download_tool,
|
387 |
image_analysis_tool,
|
388 |
calculator_tool,
|