✨ feat(llm): 优化 DeepSeek 适配器 (#2160)
检查bot是否运行正常 / bot check (push) Waiting to run
CodeQL Code Security Analysis / Analyze (python) (push) Waiting to run
Sequential Lint and Type Check / pyright-call (push) Blocked by required conditions
Release Drafter / Update Release Draft (push) Waiting to run
Ruff Lint / Ruff Lint (push) Waiting to run
Force Sync to Aliyun / sync (push) Waiting to run
Sequential Lint and Type Check / ruff-call (push) Waiting to run
Update Version / update-version (push) Waiting to run

* ✨ feat(llm): 新增 Grok 适配器及 API 密钥重置指令

- 新增 Grok 适配器并支持原生推特检索工具 `x_search`
- 优化 DeepSeek 适配器以迁移至 Responses 协议,增强多模态支持
- 在 LLM 管理插件中新增 `llm reset` 子命令以重置 Key 状态
- 增强 MCP 连接异常处理及流关闭容错能力

* 🚨 auto fix by pre-commit hooks

---------

Co-authored-by: webjoin111 <455457521@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Rumio
2026-09-22 09:02:15 +08:00
committed by GitHub
co-authored by webjoin111 pre-commit-ci[bot]
parent 39ed1ade14
commit 33d6ea1335
13 changed files with 307 additions and 52 deletions
@@ -6,8 +6,10 @@ from zhenxun.configs.path_config import DATA_PATH
from zhenxun.services.ai.core.exceptions import LLMException
from zhenxun.services.ai.llm.api import chat
from zhenxun.services.ai.llm.manager import (
get_configured_providers,
get_model_instance,
list_available_models,
reset_key_status,
)
from zhenxun.services.ai.tools.providers.mcp.provider import mcp_provider
@@ -105,6 +107,34 @@ class DataSource:
return sorted_stats_list
@staticmethod
async def reset_keys(provider_name: str | None = None) -> tuple[bool, str]:
"""重置指定或所有提供商的 API Key 状态"""
providers = get_configured_providers()
if provider_name:
target = next(
(p for p in providers if p.name.lower() == provider_name.lower()), None
)
if not target:
return False, f"❌ 未找到提供商 '{provider_name}',请检查名称是否正确。"
await reset_key_status(target.name)
return (
True,
f"✅ 已成功重置提供商 '{target.name}'"
"的所有 API Key 状态为健康 (HEALTHY)。",
)
else:
count = 0
for p in providers:
await reset_key_status(p.name)
count += 1
return (
True,
f"✅ 已成功重置所有提供商 (共 {count} 个) "
"的 API Key 状态为健康 (HEALTHY)。",
)
@staticmethod
async def get_mcp_list() -> list[dict[str, Any]]:
"""获取排序后的 MCP 列表"""