azettl commited on
Commit
28db752
·
verified ·
1 Parent(s): 7efc6b7

Update research_tools/web_search.py

Browse files
Files changed (1) hide show
  1. research_tools/web_search.py +23 -1
research_tools/web_search.py CHANGED
@@ -74,4 +74,26 @@ class WebSearchTool(BaseTool):
74
  elif "syntax" in error_msg.lower():
75
  return f"**Web Search for: {query}**\n\nSearch encountered formatting issues but found relevant information about {query.lower()}."
76
  else:
77
- return self.format_error_response(query, error_msg)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  elif "syntax" in error_msg.lower():
75
  return f"**Web Search for: {query}**\n\nSearch encountered formatting issues but found relevant information about {query.lower()}."
76
  else:
77
+ return self.format_error_response(query, error_msg)
78
+
79
+ def should_use_for_query(self, query: str) -> bool:
80
+ """Web search is good for current events, news, and general information"""
81
+ current_indicators = ['news', 'recent', 'latest', 'current', 'today', '2024', '2025']
82
+ general_indicators = ['what is', 'how to', 'guide', 'tutorial', 'review']
83
+
84
+ query_lower = query.lower()
85
+ return any(indicator in query_lower for indicator in current_indicators + general_indicators)
86
+
87
+ def extract_key_info(self, text: str) -> dict:
88
+ """Extract key information from web search results"""
89
+ base_info = super().extract_key_info(text)
90
+
91
+ if text:
92
+ # Look for news-specific patterns
93
+ base_info.update({
94
+ 'has_news_keywords': bool(any(word in text.lower() for word in ['breaking', 'report', 'announced', 'according to'])),
95
+ 'has_quotes': text.count('"') > 1,
96
+ 'has_sources': bool(any(source in text.lower() for source in ['reuters', 'bloomberg', 'bbc', 'cnn', 'associated press']))
97
+ })
98
+
99
+ return base_info