refactor(gateway): 适配器暴露 probe_connection 公开探测——provider_deps 弃私有 _client 反手(CR-M1.4)

This commit is contained in:
Yaojia Wang
2026-07-08 13:00:50 +02:00
parent 9439b97804
commit 832ab7dfa1
3 changed files with 53 additions and 3 deletions

View File

@@ -103,6 +103,14 @@ class OpenAICompatAdapter:
def capabilities(self) -> Capabilities:
return Capabilities(structured_output=True, prefix_cache=True, thinking=False)
async def probe_connection(self) -> None:
"""最小连通性探测:列模型即验 Key 有效不消耗生成额度失败原样上抛CR-M1.4)。
凭据连接测试的**公开入口**——调用方apps/api provider_deps经此验 Key无需
反手适配器私有客户端。任一异常上抛,由调用方映射为 LLM 不可用。
"""
await self._client.models.list()
def _structured(self) -> StructuredClient:
if self._structured_client is None:
# 懒构建:从同一 AsyncOpenAI client patch 出 instructor 客户端。