feat: codex无重启,无另外调整,纯模型栏切换官模与第三方api#1641
Conversation
|
审查结论:当前不建议合并,主要有以下问题需要先确认:
建议让 routing catalog 同步合并
我本地验证了 |
|
Codex++ maintainer review note 这个方向有价值,但当前 PR 改动覆盖模型目录、relay config、protocol proxy、settings 和前端开关,而且没有 CI/check 结果;暂时不建议直接合并。 请补充以下内容后再复审:
The feature is useful, but it touches model catalog, relay config, protocol proxy, settings, and UI without CI results. Please add coverage and clarify compatibility boundaries before merge. |
Addresses the review on BigPizzaV3#1641. - model_catalog: the routing catalog only listed third-party models, so /models hid the official ones even though Codex's generated model_catalog_json had both. Merge the official slugs back in from model-catalogs/codex-plus-router.json (falling back to models_cache.json before the first launch writes it) and expose them as their own source entry. - relay_switch: switching or editing a provider while routing is on wrote that profile over the router provider, and backfilled the router's live config.toml onto the profile it replaced. Apply the router profile instead and skip the backfill. - protocol_proxy: make the official base URL overridable via CODEX_PLUS_OFFICIAL_BASE_URL and expose the settings+headers entry point so the routing decision can be driven end to end from tests. New coverage: tests/model_routing.rs drives /v1/responses against loopback upstreams for matched third-party models (correct API key), suffixed model ids, unmatched models (official Authorization forwarded, x-api-key withheld), /responses and /responses/compact, duplicate model bindings, missing/placeholder ChatGPT login, and routing turned off. tests/model_catalog.rs asserts the /models payload with routing on and off; tests/relay_switch.rs asserts the switch flow in both states. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Relay APIs commonly resell the same model, so several providers declaring e.g. claude-sonnet-4-6 is a normal setup rather than a misconfiguration. relay_profile_for_model used to bail out and fail the whole request; it now takes the first match in relay_profiles order — the same one the model catalog already collapses the duplicate slug onto — and records the shadowed providers as model_routing.duplicate_model_binding in the diagnostic log so an unexpected choice stays traceable. Reordering the provider list is how the user picks the winner. The function can no longer fail, so it returns Option instead of Result. Also adds an end-to-end test that the per-provider upstream protocol toggle still applies under routing: a Chat Completions provider gets /v1/chat/completions with a converted `messages` body and its own key, while other providers stay on Responses. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
已按复审意见补齐,新提交 1. 官方模型没有出现在模型列表(已确认并修复)问题成立。 修复方式:路由目录现在把官方模型合并回来。读 2. 重复模型名:改为「列表顺序第一个胜出」,不再报错原来的实现在同一模型属于多个供应商时直接 现在 (更彻底的做法是模型别名 —— 3. 端到端 / 接口级测试
4. 顺带修掉的一个真问题:开关开启时切换供应商会破坏路由
现在开关开启时改为走 5. 与现有逻辑的边界
另外新增了 6. 本地验证分测试二进制: (本机 Node 是 v22.11.0,还没默认开启 TS 类型擦除,直接跑 7. CI已在 fork 上跑完一轮 pr-build,三个平台全绿(
产物: (本 PR 面向上游的 checks 需要维护者点一次 “Approve and run”,所以上面这轮是在 fork 上用 |
新增“按模型自动路由供应商”功能,使 ChatGPT 官方模型与第三方 API 模型可以同时出现在 Codex 模型栏中,并仅通过切换模型自动选择对应供应商。
modelList:走该供应商新增“按模型自动路由供应商”独立开关,默认关闭
127.0.0.1:57321/v1/models与 Codex 自身的模型选择器返回同一套集合)mimo-v2.5-pro[1M]复审后补充(
ade7d2a、2fa95e8)/models只返回第三方模型、与生成的 router catalog 不一致的问题relay_profile_for_model因此不再可能失败,返回值由Result收敛为Optionrelay_switch在开关开启时改走 router profile,并跳过会把 router 实时配置回填进上一个 profile 的逻辑crates/codex-plus-core/tests/model_routing.rs(8 个端到端测试)及/models、供应商切换的接口级测试CODEX_PLUS_OFFICIAL_BASE_URL,用于把官方分支指向自建网关或测试上游(未设置即真实 ChatGPT 后端)