Remove Google web-search Programmable SERP (#5156)

This commit is contained in:
Timothy Carambat 2026-03-05 14:49:32 -08:00 committed by GitHub
parent f833c34045
commit 1d8c488e97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 4 additions and 137 deletions

View File

@ -1,55 +1,3 @@
export function GoogleSearchOptions({ settings }) {
return (
<>
<p className="text-sm text-white/60 my-2">
You can get a free search engine & API key{" "}
<a
href="https://programmablesearchengine.google.com/controlpanel/create"
target="_blank"
rel="noreferrer"
className="text-blue-300 underline"
>
from Google here.
</a>
</p>
<div className="flex gap-x-4">
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-3">
Search engine ID
</label>
<input
type="text"
name="env::AgentGoogleSearchEngineId"
className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
placeholder="Google Search Engine Id"
defaultValue={settings?.AgentGoogleSearchEngineId}
required={true}
autoComplete="off"
spellCheck={false}
/>
</div>
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-3">
Programmatic Access API Key
</label>
<input
type="password"
name="env::AgentGoogleSearchEngineKey"
className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
placeholder="Google Search Engine API Key"
defaultValue={
settings?.AgentGoogleSearchEngineKey ? "*".repeat(20) : ""
}
required={true}
autoComplete="off"
spellCheck={false}
/>
</div>
</div>
</>
);
}
const SerpApiEngines = [
{ name: "Google Search", value: "google" },
{ name: "Google Images", value: "google_images_light" },

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1,7 +1,6 @@
import React, { useEffect, useRef, useState } from "react";
import Admin from "@/models/admin";
import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png";
import GoogleSearchIcon from "./icons/google.png";
import SerpApiIcon from "./icons/serpapi.png";
import SearchApiIcon from "./icons/searchapi.png";
import SerperDotDevIcon from "./icons/serper.png";
@ -24,7 +23,6 @@ import {
SerpApiOptions,
SearchApiOptions,
SerperDotDevOptions,
GoogleSearchOptions,
BingSearchOptions,
SerplySearchOptions,
SearXNGOptions,
@ -49,13 +47,6 @@ const SEARCH_PROVIDERS = [
options: () => <DuckDuckGoOptions />,
description: "Free and privacy-focused web search using DuckDuckGo.",
},
{
name: "Google Search Engine",
value: "google-search-engine",
logo: GoogleSearchIcon,
options: (settings) => <GoogleSearchOptions settings={settings} />,
description: "Web search powered by a custom Google Search Engine.",
},
{
name: "SerpApi",
value: "serpapi",
@ -164,9 +155,9 @@ export default function AgentWebSearchSelection({
.catch(() => setSelectedProvider("none"));
}, []);
const selectedSearchProviderObject = SEARCH_PROVIDERS.find(
(provider) => provider.value === selectedProvider
);
const selectedSearchProviderObject =
SEARCH_PROVIDERS.find((provider) => provider.value === selectedProvider) ??
SEARCH_PROVIDERS[1];
return (
<div className="p-2">

View File

@ -291,8 +291,6 @@ const SystemSettings = {
// --------------------------------------------------------
// Agent Settings & Configs
// --------------------------------------------------------
AgentGoogleSearchEngineId: process.env.AGENT_GSE_CTX || null,
AgentGoogleSearchEngineKey: !!process.env.AGENT_GSE_KEY || null,
AgentSerpApiKey: !!process.env.AGENT_SERPAPI_API_KEY || null,
AgentSerpApiEngine: process.env.AGENT_SERPAPI_ENGINE || "google",
AgentSearchApiKey: !!process.env.AGENT_SEARCHAPI_API_KEY || null,

View File

@ -66,9 +66,6 @@ const webBrowsing = {
?.value ?? "unknown";
let engine;
switch (provider) {
case "google-search-engine":
engine = "_googleSearchEngine";
break;
case "serpapi":
engine = "_serpApi";
break;
@ -97,7 +94,7 @@ const webBrowsing = {
engine = "_exaSearch";
break;
default:
engine = "_googleSearchEngine";
engine = "_duckDuckGoEngine";
}
return await this[engine](query);
},
@ -114,65 +111,6 @@ const webBrowsing = {
return `${str.slice(0, length)}...${str.slice(-length)}`;
},
/**
* Use Google Custom Search Engines
* Free to set up, easy to use, 100 calls/day
* https://programmablesearchengine.google.com/controlpanel/create
*/
_googleSearchEngine: async function (query) {
if (!process.env.AGENT_GSE_CTX || !process.env.AGENT_GSE_KEY) {
this.super.introspect(
`${this.caller}: I can't use Google searching because the user has not defined the required API keys.\nVisit: https://programmablesearchengine.google.com/controlpanel/create to create the API keys.`
);
return `Search is disabled and no content was found. This functionality is disabled because the user has not set it up yet.`;
}
const searchURL = new URL(
"https://www.googleapis.com/customsearch/v1"
);
searchURL.searchParams.append("key", process.env.AGENT_GSE_KEY);
searchURL.searchParams.append("cx", process.env.AGENT_GSE_CTX);
searchURL.searchParams.append("q", query);
this.super.introspect(
`${this.caller}: Searching on Google for "${
query.length > 100 ? `${query.slice(0, 100)}...` : query
}"`
);
const data = await fetch(searchURL)
.then((res) => {
if (res.ok) return res.json();
throw new Error(
`${res.status} - ${res.statusText}. params: ${JSON.stringify({ key: this.middleTruncate(process.env.AGENT_GSE_KEY, 5), cx: this.middleTruncate(process.env.AGENT_GSE_CTX, 5), q: query })}`
);
})
.then((searchResult) => searchResult?.items || [])
.then((items) => {
return items.map((item) => {
return {
title: item.title,
link: item.link,
snippet: item.snippet,
};
});
})
.catch((e) => {
this.super.handlerProps.log(
`${this.name}: Google Search Error: ${e.message}`
);
return [];
});
if (data.length === 0)
return `No information was found online for the search query.`;
const result = JSON.stringify(data);
this.super.introspect(
`${this.caller}: I found ${data.length} results - reviewing the results now. (~${this.countTokens(result)} tokens)`
);
return result;
},
/**
* Use SerpApi
* SerpApi supports dozens of search engines across the major platforms including Google, DuckDuckGo, Bing, eBay, Amazon, Baidu, Yandex, and more.

View File

@ -562,14 +562,6 @@ const KEY_MAPPING = {
},
// Agent Integration ENVs
AgentGoogleSearchEngineId: {
envKey: "AGENT_GSE_CTX",
checks: [],
},
AgentGoogleSearchEngineKey: {
envKey: "AGENT_GSE_KEY",
checks: [],
},
AgentSerpApiKey: {
envKey: "AGENT_SERPAPI_API_KEY",
checks: [],