| from typing import Any, Optional | |
| from smolagents.tools import Tool | |
| from gradio_client import Client | |
| class BroadfieldWebsearch(Tool): | |
| client = Client("broadfield-dev/browser") | |
| name = "broadfield_web_search" | |
| description = "Searches the web with common web search engines." | |
| inputs = {'query': {'type': 'any', 'description': 'The query terms to use for the web search.'}} | |
| output_type = "any" | |
| def forward(self, query: Any) -> Any: | |
| result = result = self.client.predict( | |
| action="Search", | |
| query=query, | |
| browser_name="firefox", | |
| search_engine_name="Ecosia", | |
| api_name="/web_browse" | |
| ) | |
| return result['markdown_content'] | |
| def __init__(self, *args, **kwargs): | |
| self.is_initialized = False | |