refactor: remove Google search engine integration from main module and dependencies (#3154)

This commit is contained in:
Soulter
2025-10-26 18:54:01 +08:00
committed by GitHub
parent 1152b11202
commit 65c71b5f20
3 changed files with 4 additions and 49 deletions

View File

@@ -1,30 +0,0 @@
import os
from googlesearch.asearch import asearch
from . import SearchEngine, SearchResult
from typing import List
class Google(SearchEngine):
def __init__(self) -> None:
super().__init__()
self.proxy = os.environ.get("https_proxy")
async def search(self, query: str, num_results: int) -> List[SearchResult]:
results = []
try:
ls = asearch(
query,
advanced=True,
num_results=num_results,
timeout=3,
proxy=self.proxy,
)
async for i in ls:
results.append(
SearchResult(title=i.title, url=i.url, snippet=i.description)
)
except Exception as e:
raise e
return results

View File

@@ -10,7 +10,6 @@ from astrbot.core.provider.func_tool_manager import FunctionToolManager
from .engines import SearchResult
from .engines.bing import Bing
from .engines.sogo import Sogo
from .engines.google import Google
from readability import Document
from bs4 import BeautifulSoup
from .engines import HEADERS, USER_AGENTS
@@ -46,12 +45,6 @@ class Main(star.Star):
self.bing_search = Bing()
self.sogo_search = Sogo()
self.google = None
try:
self.google = Google()
except Exception as e:
logger.error(f"google search init error: {e}, disable google search")
self.baidu_initialized = False
async def _tidy_text(self, text: str) -> str:
@@ -95,17 +88,10 @@ class Main(star.Star):
self, query, num_results: int = 5
) -> list[SearchResult]:
results = []
if self.google:
try:
results = await self.google.search(query, num_results)
except Exception as e:
logger.error(f"google search error: {e}, try the next one...")
if len(results) == 0:
logger.debug("search google failed")
try:
results = await self.bing_search.search(query, num_results)
except Exception as e:
logger.error(f"bing search error: {e}, try the next one...")
try:
results = await self.bing_search.search(query, num_results)
except Exception as e:
logger.error(f"bing search error: {e}, try the next one...")
if len(results) == 0:
logger.debug("search bing failed")
try:

View File

@@ -24,7 +24,6 @@ dependencies = [
"faiss-cpu==1.10.0",
"filelock>=3.18.0",
"google-genai>=1.14.0",
"mi-googlesearch-python==1.3.0.post1",
"lark-oapi>=1.4.15",
"lxml-html-clean>=0.4.2",
"mcp>=1.8.0",