1. Add the following tools:
* Google Finance
- get_stock_summary
- get_stock_historical_data
* Google Flights
- search_roundtrip_flights
- search_one_way_flights
* Google Hotels
- search_hotels
2. Add some common helper functions for serpAPI tools.
21 lines
634 B
Python
21 lines
634 B
Python
import json
|
|
from typing import Annotated
|
|
|
|
from arcade.sdk import ToolContext, tool
|
|
|
|
from arcade_search.utils import call_serpapi, prepare_params
|
|
|
|
|
|
@tool(requires_secrets=["SERP_API_KEY"])
|
|
async def search_google(
|
|
context: ToolContext,
|
|
query: Annotated[str, "Search query"],
|
|
n_results: Annotated[int, "Number of results to retrieve"] = 5,
|
|
) -> str:
|
|
"""Search Google using SerpAPI and return organic search results."""
|
|
|
|
params = prepare_params("google", q=query)
|
|
results = call_serpapi(context, params)
|
|
organic_results = results.get("organic_results", [])
|
|
|
|
return json.dumps(organic_results[:n_results])
|