PartyPrepAgent / tools /search.py
elliemci's picture
Upload 9 files
fdffbe8 verified
raw
history blame contribute delete
579 Bytes
from smolagents import tool, DuckDuckGoSearchTool
@tool
def search(query: str) -> str:
"""Perrforms a web serach using DuckDuckGo and returns the most relevant information fo the search term.
Args:
query: a str that specifies the information to retrieve.
Returns:
str: The first relevant result snippet or title from the search results.
"""
search_tool = DuckDuckGoSearchTool()
results = search_tool.search(query)
if results:
return results[0]["snippet"] if "snippet" in results[0] else results[0]["title"]
return None