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

* ✨ 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
@@ -3,6 +3,7 @@ from contextlib import asynccontextmanager
import json
from typing import Any
import anyio
from anyio import create_memory_object_stream, create_task_group
from mcp.shared.message import SessionMessage
from mcp.types import JSONRPCMessage
@@ -61,16 +62,25 @@ class UniversalMcpExtension(BaseMcpProxyExtension):
if not line.strip():
continue
try:
msg = model_validate(
msg_obj = model_validate(
JSONRPCMessage, json.loads(line)
)
await read_prod.send(SessionMessage(message=msg))
await read_prod.send(
SessionMessage(message=msg_obj)
)
except Exception as exc:
await read_prod.send(exc)
except Exception:
except anyio.ClosedResourceError:
pass
except BaseException as e:
logger.debug(
f"🔇 [MCP Universal] 读流异常: {type(e).__name__}: {e}"
)
finally:
await read_prod.aclose()
try:
await read_prod.aclose()
except Exception:
pass
async def stream_writer():
try:
@@ -82,8 +92,12 @@ class UniversalMcpExtension(BaseMcpProxyExtension):
+ b"\n"
)
await process_stream.write(data)
except Exception:
except anyio.ClosedResourceError:
pass
except BaseException as e:
logger.debug(
f"🔇 [MCP Universal] 写流异常: {type(e).__name__}: {e}"
)
async with create_task_group() as tg:
tg.start_soon(stream_reader)