Skip to content

自带 key 引擎公共构造与首家接入 (fix #333) - #359

Merged
Teeeeeeeerry merged 1 commit into
mainfrom
fix/333-byok-common-construction
Aug 31, 2026
Merged

自带 key 引擎公共构造与首家接入 (fix #333)#359
Teeeeeeeerry merged 1 commit into
mainfrom
fix/333-byok-common-construction

Conversation

@Teeeeeeeerry

Copy link
Copy Markdown
Owner

问题

OpenAI、DeepL、Gemini 三家自带 key 引擎各自重复「过并发闸门、取 key、缺 key 抛错、发请求、按公共判定分类、按类别抛错」整段骨架。

根因

骨架没有公共构造,适配器与骨架混在一起。

修复

新增 createByokEngine 公共构造:闸门保持在最外层(整个请求体含取 key 都在闸门内)、每家引擎仍持有各自的模块级惰性单例闸门、缺 key 时不发请求并抛不可重试的 key 无效类错误、失败分类走公共判定(读错误体的特例经适配器 classifyError 提供);OpenAI 首家接入,请求格式、错误文案、失败类别与改造前完全一致,路由与调用方无需改动。

验证

pnpm typecheck 通过;新增 6 个公共构造骨架用例(请求构造与解析、缺 key 零请求、闸门包裹含取 key、公共分类矩阵、特例优先、模型名传递),pnpm test 647 个用例全部通过;既有引擎单测与跨引擎契约测试未修改且全部通过;pnpm build 正常。

Closes #333

三家自带 key 引擎重复同一段骨架(闸门/取 key/分类抛错)。新增
createByokEngine 公共构造:闸门包裹整个请求体、缺 key 不发请求
抛不可重试错误、分类走公共判定;OpenAI 首家接入,请求格式与
文案逐字一致。

Co-Authored-By: zhexuancai-uts <261878103+zhexuancai-uts@users.noreply.github.com>
@Teeeeeeeerry
Teeeeeeeerry merged commit 90b725e into main Aug 31, 2026
6 checks passed
@Teeeeeeeerry
Teeeeeeeerry deleted the fix/333-byok-common-construction branch August 31, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

309-1 自带 key 引擎公共构造与首家接入(父 #309)

1 participant