CyberMax-tools's picture
CyberMax google_trending_searches tool for smolagents
6305006 verified
Raw History Blame Contribute Delete
1.16 kB
from typing import Any, Optional
from smolagents.tools import Tool
import requests
class TrendingSearchesTool(Tool):
name = "google_trending_searches"
description = "Swellmeter Trending by CyberMax: Google 'Trending now' searches for up to 5 of 30 countries (rank, approximate traffic, start time, news links), or the searches trending in several countries at once (geo='global'). Free tier 50 calls a day, no key; paid keys at https://swellmeter-api.cybermax-tools.workers.dev/docs"
inputs = {'geo': {'type': 'string', 'description': "Comma-separated ISO-2 country codes, e.g. 'US,GB', or 'global' for cross-country trends"}}
output_type = "object"
def forward(self, geo: str):
import requests
base = "https://swellmeter-api.cybermax-tools.workers.dev/api/"
if geo.strip().lower() == "global":
r = requests.get(base + "global", params={"via": "smolagents"}, timeout=30)
else:
r = requests.get(base + "trending", params={"geo": geo.replace(" ", ""), "via": "smolagents"}, timeout=30)
return r.json()
def __init__(self, *args, **kwargs):
self.is_initialized = False