feat(apikey): 增加 混合轮转(聚合 API 优先)选项 - #454
Merged
Merged
Conversation
Contributor
Author
|
All ready for reviewing and merge @qxcnm |
Owner
|
审查结论:暂不合并。虽然当前 CI 全绿,而且在当前主线缓存修复上做的合并态验证中,prompt-cache / cache-affinity 专项 12/12 通过,但仍有功能边界 blocker: |
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.
变更摘要
hybrid_aggregate_first_rotation):与现有「混合轮转(账号优先)」完全对称——优先走聚合 API,聚合候选全部失败且请求未被消费时,回落账号池兜底api_keys.rotation_strategy为自由 TEXT 列,新值直接写入)改动范围
主要文件
网关路由核心:
crates/service/src/gateway/upstream/protocol/aggregate_api.rs:新增AggregateFailurePolicy/AggregateAttemptOutcome;ReleaseRequest策略下候选为空或全部候选失败时归还request(保留失败 trace 日志)crates/service/src/gateway/upstream/proxy.rs:主流程聚合分支支持失败回落账号路径;RouteKind各判断函数新增HybridAggregateFirst分支crates/service/src/gateway/upstream/executor/mod.rs:GatewayUpstreamRouteKind新增HybridAggregateFirst变体API Key 配置:
crates/service/src/apikey/apikey_profile.rs:常量 +normalize_rotation_strategy别名crates/service/src/apikey/apikey_create.rs/apikey_update_model.rs:筛选条件扩展crates/service/src/gateway/mod.rs:websocket 支持判断排除新策略(与现有 hybrid 一致)前端:
apps/src/components/modals/api-key-modal.tsx:下拉新增选项 + 说明文案apps/src/app/apikeys/page.tsx/models/page.tsx/platform-mode/page-sections.tsx:策略标签apps/src/lib/i18n/messages/{en,ko,ru}.ts:文案翻译测试:
apikey_profile_tests.rs、executor/mod_tests.rs、codex_profile_tests.rs验证
pnpm -C apps run testpnpm -C apps run buildpnpm -C apps run test:uicargo test --workspace已执行的实际验证:
未执行的验证与原因:
风险与影响面
match仅新增分支;proxy_aggregate_request现有两个调用点以RespondError策略调用,行为与改动前一致proxy_aggregate_request返回类型变化(Result<(), String>→Result<AggregateAttemptOutcome, String>)为结构性改动,仅影响内部 3 个调用点,均已适配