chore: opencode冗余清理 + LLM任务级模型选择 + systemd服务化
- 删除 opencode_search.py / mcp_search_server.py 及所有 MCP 引用 - 移除搜索缓存定时任务(scheduled_refresh_search_cache) - 清理前后端所有 opencode/MCP 代码和注释 - LLM 提供商量换:opencode-go→nvidia(默认)+sensenova(合规审查) - llm_configs 新增 is_default 字段,API 层互斥逻辑 - 所有定时任务支持独立 LLM 模型选择(LLM_TASK_PROVIDER env) - compliance_optimizer.py 修复:import os / 解硬编码 / 关键词过滤 - Scheduler 日志修复:始终 INSERT,避免僵尸 running 行 - Systemd 服务化:Restart=always / 单 worker / Type=exec - 搜索提供商:替换 opencode→360/搜狗/微信(免 Key) - 更新 AGENTS.md / PROGRESS.md
This commit is contained in:
+1
-28
@@ -179,32 +179,6 @@ def _call_bing(api_key: str, api_url: str, query: str, max_results: int) -> List
|
||||
} for r in items[:max_results]]
|
||||
|
||||
|
||||
def _call_mcp(api_key: str, api_url: str, query: str, max_results: int) -> List[Dict]:
|
||||
"""Call the MCP search server directly (no API key needed)."""
|
||||
import subprocess
|
||||
try:
|
||||
r = subprocess.run(
|
||||
[sys.executable, str(PROJECT_ROOT / "scripts" / "mcp_search_server.py"),
|
||||
"--query", query],
|
||||
capture_output=True, text=True, timeout=90,
|
||||
)
|
||||
if r.returncode != 0:
|
||||
logger.warning("MCP搜索子进程返回非零: %s", r.stderr[:100])
|
||||
return []
|
||||
results = json.loads(r.stdout)
|
||||
if isinstance(results, list):
|
||||
for res in results:
|
||||
res["source"] = "opencode"
|
||||
return results[:max_results]
|
||||
except json.JSONDecodeError as e:
|
||||
logger.warning("MCP搜索JSON解析失败: %s", e)
|
||||
except subprocess.TimeoutExpired:
|
||||
logger.warning("MCP搜索超时 (90s)")
|
||||
except Exception as e:
|
||||
logger.warning("MCP搜索失败: %s", e)
|
||||
return []
|
||||
|
||||
|
||||
def _call_360(api_key: str, api_url: str, query: str, max_results: int) -> List[Dict]:
|
||||
"""360搜索(HTML爬取,无需 API Key)"""
|
||||
from bs4 import BeautifulSoup
|
||||
@@ -311,7 +285,6 @@ _PROVIDER_CALLS = {
|
||||
"qiniu": _call_qiniu,
|
||||
"tinyfish": _call_tinyfish,
|
||||
"bing": _call_bing,
|
||||
"mcp": _call_mcp,
|
||||
"360": _call_360,
|
||||
"sogou": _call_sogou,
|
||||
"wechat": _call_wechat,
|
||||
@@ -325,7 +298,7 @@ def search(query: str, max_results: int = 5) -> List[Dict]:
|
||||
if (p.get("usage_today") or 0) >= (p.get("daily_limit") or 99999):
|
||||
logger.info("提供商 %s 已达日限 %s,跳过", p.get("name"), p.get("daily_limit"))
|
||||
continue
|
||||
no_key_types = {"mcp", "360", "sogou", "wechat"}
|
||||
no_key_types = {"360", "sogou", "wechat"}
|
||||
if not p.get("api_key") and p.get("provider_type") not in no_key_types:
|
||||
logger.info("提供商 %s 未配置 API Key,跳过", p.get("name"))
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user