Spaces:
Runtime error
Runtime error
Added web_search directly
Browse files
app.py
CHANGED
|
@@ -378,6 +378,22 @@ model.__call__ = try_model_call_with_fallbacks
|
|
| 378 |
# Import tool from Hub
|
| 379 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 380 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
with open("prompts.yaml", 'r') as stream:
|
| 382 |
prompt_templates = yaml.safe_load(stream)
|
| 383 |
|
|
@@ -386,6 +402,7 @@ agent = CodeAgent(
|
|
| 386 |
tools=[
|
| 387 |
final_answer,
|
| 388 |
Sonar_Web_Search_Tool,
|
|
|
|
| 389 |
ddg_search_tool, # Added DuckDuckGo search tool
|
| 390 |
# google_search_tool, # Added Google search tool
|
| 391 |
get_current_time_in_timezone,
|
|
|
|
| 378 |
# Import tool from Hub
|
| 379 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 380 |
|
| 381 |
+
@tool
|
| 382 |
+
def web_search(query: str) -> str:
|
| 383 |
+
"""A tool that searches the web for information.
|
| 384 |
+
|
| 385 |
+
Args:
|
| 386 |
+
query: The search query string
|
| 387 |
+
|
| 388 |
+
Returns:
|
| 389 |
+
Search results as text
|
| 390 |
+
"""
|
| 391 |
+
try:
|
| 392 |
+
# Use the already initialized DuckDuckGo search tool
|
| 393 |
+
return ddg_search_tool(query)
|
| 394 |
+
except Exception as e:
|
| 395 |
+
return f"Error performing web search for '{query}': {str(e)}"
|
| 396 |
+
|
| 397 |
with open("prompts.yaml", 'r') as stream:
|
| 398 |
prompt_templates = yaml.safe_load(stream)
|
| 399 |
|
|
|
|
| 402 |
tools=[
|
| 403 |
final_answer,
|
| 404 |
Sonar_Web_Search_Tool,
|
| 405 |
+
web_search, # Added explicit web_search tool
|
| 406 |
ddg_search_tool, # Added DuckDuckGo search tool
|
| 407 |
# google_search_tool, # Added Google search tool
|
| 408 |
get_current_time_in_timezone,
|