from typing import Any, Optional from smolagents.tools import Tool import requests class CompanyDomainTool(Tool): name = "company_to_domain" description = "Namewhere by CyberMax: the official website domain of a company from its name, with confidence 0-1, evidence (Wikidata, homepage brand match), alternatives, rejected look-alike domains and social links. A domain, URL or email is verified instead. Free tier 25 lookups a day, no key; paid keys at https://namewhere.cybermax-tools.workers.dev/docs" inputs = {'company': {'type': 'string', 'description': "Company name, e.g. 'Monzo Bank'"}, 'country': {'type': 'string', 'description': "Optional ISO-2 country code to prefer, e.g. 'gb'", 'nullable': True}} output_type = "object" def forward(self, company: str, country: str = None): import requests params = {"company": company, "via": "smolagents"} if country: params["country"] = country r = requests.get("https://namewhere.cybermax-tools.workers.dev/api/domain", params=params, timeout=60) return r.json() def __init__(self, *args, **kwargs): self.is_initialized = False