Spaces:
Sleeping
Sleeping
| from smolagents import tool, DuckDuckGoSearchTool | |
| 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 | |