自带 key 引擎公共构造与首家接入 (fix #333) - #359
Merged
Merged
Conversation
三家自带 key 引擎重复同一段骨架(闸门/取 key/分类抛错)。新增 createByokEngine 公共构造:闸门包裹整个请求体、缺 key 不发请求 抛不可重试错误、分类走公共判定;OpenAI 首家接入,请求格式与 文案逐字一致。 Co-Authored-By: zhexuancai-uts <261878103+zhexuancai-uts@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
OpenAI、DeepL、Gemini 三家自带 key 引擎各自重复「过并发闸门、取 key、缺 key 抛错、发请求、按公共判定分类、按类别抛错」整段骨架。
根因
骨架没有公共构造,适配器与骨架混在一起。
修复
新增
createByokEngine公共构造:闸门保持在最外层(整个请求体含取 key 都在闸门内)、每家引擎仍持有各自的模块级惰性单例闸门、缺 key 时不发请求并抛不可重试的 key 无效类错误、失败分类走公共判定(读错误体的特例经适配器classifyError提供);OpenAI 首家接入,请求格式、错误文案、失败类别与改造前完全一致,路由与调用方无需改动。验证
pnpm typecheck通过;新增 6 个公共构造骨架用例(请求构造与解析、缺 key 零请求、闸门包裹含取 key、公共分类矩阵、特例优先、模型名传递),pnpm test647 个用例全部通过;既有引擎单测与跨引擎契约测试未修改且全部通过;pnpm build正常。Closes #333