chat-ui_test / src /lib /server /searchWeb.ts
nsarrazin's picture
nsarrazin HF staff
Add initial support for web browsing (#237)
0c4cf03 unverified
raw
history blame
446 Bytes
import { SERPAPI_KEY } from "$env/static/private";
import { getJson } from "serpapi";
import type { GoogleParameters } from "serpapi";
// Show result as JSON
export async function searchWeb(query: string) {
const params = {
q: query,
hl: "en",
gl: "us",
google_domain: "google.com",
api_key: SERPAPI_KEY,
} satisfies GoogleParameters;
// Show result as JSON
const response = await getJson("google", params);
return response;
}