feat(claude): 补齐 claude-opus-5 接入 - #1959
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
PricingService.matchByModelFamily 中 Opus 5 的回退匹配串仅包含 claude-opus-4-8(短横线)可能无法命中 claude-opus-4.8(点号)键,导致缺少 Opus 5 价卡时回退失效。
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
该 PR 补齐 claude-opus-5 在前后端的模型目录展示、预设映射、Bedrock 映射与计费/定价回退等接入链路,确保模型广场卡片能同时展示 display name 与 model id,并让 Anthropic 分组包含 Opus 5。
Changes:
- 前端:将
claude-opus-5加入 Claude 白名单与 Anthropic/Bedrock 预设映射,并在账号状态组件加入短别名显示与对应测试。 - 后端:在 Claude 默认模型常量与 Bedrock 默认映射中加入
claude-opus-5,并补充网关 beta policy 过滤测试用例。 - 定价/协议:为 Opus 5 增加定价族匹配与 Billing fallback 回退,同时放宽 Bedrock Claude 版本号解析以支持无 minor 的
*-5型号。
File summaries
| File | Description |
|---|---|
| frontend/src/composables/useModelWhitelist.ts | 补充 claude-opus-5 到 Claude 白名单及 Anthropic/Bedrock 预设映射,支撑前端模型展示与选择。 |
| frontend/src/composables/tests/useModelWhitelist.spec.ts | 增加 Claude 平台白名单包含 claude-opus-5 的断言。 |
| frontend/src/components/account/AccountStatusIndicator.vue | 增加 claude-opus-5 的短别名映射用于限流展示。 |
| frontend/src/components/account/tests/AccountStatusIndicator.spec.ts | 新增 Opus 5 限流时短别名展示用例。 |
| backend/internal/service/pricing_service.go | 新增 Opus 5 的模型家族匹配与定价回退入口。 |
| backend/internal/service/gateway_beta_test.go | 增加 Opus 5 与其 Bedrock ID 在 beta policy 下需过滤的测试用例。 |
| backend/internal/service/billing_service.go | 增加 Opus 5 fallback 价格绑定与按模型名兜底命中逻辑。 |
| backend/internal/service/bedrock_request.go | Claude Bedrock 模型版本正则支持无 minor 版本,并调整解析逻辑。 |
| backend/internal/pkg/claude/constants.go | 在 Claude 默认模型列表中公开 claude-opus-5(含 DisplayName/CreatedAt)。 |
| backend/internal/pkg/claude/constants_test.go | 增加 DefaultModels 必含 claude-opus-5 的测试。 |
| backend/internal/domain/constants.go | 增加 claude-opus-5 到默认 Bedrock 模型映射。 |
| backend/internal/domain/constants_test.go | 增加默认 Bedrock 映射包含 claude-opus-5 的测试覆盖。 |
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // 因子串关系误匹配 "claude-opus-4-7"(opus-4.7 系列)。 | ||
| // 注意:原 map 实现存在 Go map 迭代随机性导致的同类 bug,此处改为有序切片修复。 | ||
| families := []modelFamily{ | ||
| {name: "opus-5", match: []string{"claude-opus-5"}, pricing: []string{"claude-opus-5", "claude-opus-4-8"}}, |
Comment on lines
350
to
351
| // claudeVersionRe 匹配 Claude 模型 ID 中的版本号部分 | ||
| // 支持 claude-{tier}-{major}-{minor} 和 claude-{tier}-{major}.{minor} 格式 |
Comment on lines
+81
to
+85
| it('Claude Opus 5 模型限流时显示短别名', () => { | ||
| const wrapper = mount(AccountStatusIndicator, { props: { account: makeAccount({ extra: { model_rate_limits: { 'claude-opus-5': { rate_limited_at: '2026-07-28T00:00:00Z', rate_limit_reset_at: '2099-07-28T00:00:00Z' } } } }) }, global: { stubs: { Icon: true } } }) | ||
| expect(wrapper.text()).toContain('COpus5') | ||
| expect(wrapper.text()).not.toContain('claude-opus-5') | ||
| }) |
移除 Opus 4.7、4.8、5 与 Sonnet 5 默认映射和前端预设中多余的 -v1。 为 Sonnet 5 默认 Beta 白名单补充无版本后缀的模型 ID,并验证区域/全局请求地址与 1h 缓存 TTL。 保留旧型号合法的版本及日期后缀,不改写或兼容已保存的账号映射。 验证:受影响的后端单元测试、前端 34 项 Vitest、ESLint 和 vue-tsc 均通过。
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.
模型广场每张卡片都会展示 display name + model id(例如
Claude Sonnet 5/claude-sonnet-5)。Anthropic 分组里 没有claude-opus-5。