fix(openai): 移除已下线 Codex 模型的内置重定向#1759
Open
specialpointcentral wants to merge 1 commit intoWei-Shaw:mainfrom
Open
fix(openai): 移除已下线 Codex 模型的内置重定向#1759specialpointcentral wants to merge 1 commit intoWei-Shaw:mainfrom
specialpointcentral wants to merge 1 commit intoWei-Shaw:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
该 PR 修复 ChatGPT 登录(Codex/OAuth)路径下仍被内置映射重定向到已下线模型的问题,并同步前后端默认/白名单模型配置,确保只暴露仍可用的模型集合。
Changes:
- 后端移除已下线 Codex 模型的内置重定向,并将 Codex/OAuth 归一化默认兜底切换到可用模型(如
gpt-5.4/gpt-5.3-codex)。 - 前端移除已下线模型的白名单/预设映射/配置模板项,避免继续展示给用户。
- 更新并新增相关单测,覆盖“移除模型不再暴露/回退到可用目标”等行为。
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/composables/useModelWhitelist.ts | 更新 OpenAI 模型白名单与预设映射,移除下线模型 |
| frontend/src/composables/tests/useModelWhitelist.spec.ts | 更新/新增前端白名单相关断言,验证下线模型不再暴露 |
| frontend/src/components/keys/UseKeyModal.vue | 移除已下线模型的配置模板项,避免生成过期配置 |
| backend/internal/service/openai_model_mapping_test.go | 调整 OpenAI/Codex 归一化与回退行为的测试期望 |
| backend/internal/service/openai_codex_transform_test.go | 新增/更新 Codex 模型归一化回退到可用目标的测试 |
| backend/internal/service/openai_codex_transform.go | 移除下线模型映射、更新 normalizeCodexModel 默认兜底与 spark 保留策略 |
| backend/internal/pkg/openai/constants.go | 更新默认 OpenAI 模型列表与默认测试模型 |
| backend/internal/pkg/openai/constants_test.go | 新增测试确保默认模型列表排除已下线模型并更新默认测试模型 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
21
to
25
| // GPT-5.4 系列 | ||
| 'gpt-5.4', 'gpt-5.4-mini', 'gpt-5.4-nano', 'gpt-5.4-2026-03-05', | ||
| 'gpt-5.4', 'gpt-5.4-mini', 'gpt-5.4-2026-03-05', | ||
| // GPT-5.3 系列 | ||
| 'gpt-5.3-codex', 'gpt-5.3-codex-spark', | ||
| 'chatgpt-4o-latest', |
There was a problem hiding this comment.
openaiModels 里 gpt-5.3-codex-spark 被重复加入(这里的 GPT-5.3 系列已包含一次,前面 GPT-5 系列段落也包含一次),会导致下拉/白名单列表出现重复项。建议只保留一个条目并将其放在对应的 GPT-5.3 分组下(同时调整上方分组注释避免误导)。
Comment on lines
74
to
+78
| Credentials: map[string]any{}, | ||
| } | ||
|
|
||
| withoutDefault := normalizeCodexModel(resolveOpenAIForwardModel(account, "claude-opus-4-6", "")) | ||
| if withoutDefault != "gpt-5.1" { | ||
| t.Fatalf("normalizeCodexModel(...) = %q, want %q", withoutDefault, "gpt-5.1") | ||
| if withoutDefault != "gpt-5.4" { |
There was a problem hiding this comment.
该用例现在断言默认回退为 gpt-5.4,但测试函数名仍是 ...FallingBackToGpt51,容易误导后续维护/排查。建议同步重命名测试函数(以及必要时更新描述字符串),与新的回退目标一致。
1ec106a to
31c102a
Compare
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.
说明
修复 ChatGPT 登录用户在 Codex/OAuth 路径下,仍会被内置模型映射重定向到已下线模型的问题。
Closes #1758
改动内容
gpt-5gpt-5.1gpt-5.1-codexgpt-5.1-codex-maxgpt-5.1-codex-minigpt-5.2-codexgpt-5.4gpt-5.4-minigpt-5.3-codexgpt-5.3-codex-sparkgpt-5.2验证
后端
go test ./internal/service ./internal/pkg/openai -run 'TestNormalizeCodexModel|TestDefaultModels_RemovedCodexModelsExcluded|TestNormalizeOpenAIModelForUpstream|TestResolveOpenAIForwardModel_PreventsClaudeModelFromFallingBackToGpt51'前端
pnpm test:run src/composables/__tests__/useModelWhitelist.spec.tspnpm typecheck影响范围