This PR makes a few sweeping changes to the actor, cli, and overall structure of the project. - CLI commands skeleton - ``arcade run``, ``arcade show``, and ``arcade new`` - Working package mangement solution (``arcade_`` packages) - Actor approach for using frameworks other than FastAPI - Client for calling Engine within ``arcade/core`` - beginning of the config interface. --------- Co-authored-by: Nate Barbettini <nate@arcade-ai.com>
25 lines
710 B
Python
25 lines
710 B
Python
import json
|
|
import serpapi
|
|
from typing import Annotated
|
|
from arcade.sdk.tool import tool, get_secret
|
|
|
|
|
|
@tool
|
|
async def search_google(
|
|
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."""
|
|
|
|
api_key = get_secret("SERP_API_KEY")
|
|
if not api_key:
|
|
raise ValueError("SERP_API_KEY is not set")
|
|
|
|
client = serpapi.Client(api_key=api_key)
|
|
params = {"engine": "google", "q": query}
|
|
|
|
search = client.search(params)
|
|
results = search.as_dict()
|
|
organic_results = results.get("organic_results", [])
|
|
|
|
return json.dumps(organic_results[:n_results])
|