Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src-tauri/src/proxy/forwarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,9 +1159,15 @@ impl RequestForwarder {
// 应用模型映射(独立于格式转换)
// Claude Desktop proxy 模式必须先把 Desktop 可见的 claude-* route
// 映射成真实上游模型名,并且未知 route 要直接报错,不能使用默认模型兜底。
// Codex catalogue 集成模式(Responses 原生直连)使用 catalog 模型,无需 env 映射。
let mapped_body = if matches!(app_type, AppType::ClaudeDesktop) {
crate::claude_desktop_config::map_proxy_request_model(body.clone(), provider)
.map_err(|e| ProxyError::InvalidRequest(e.to_string()))?
} else if matches!(app_type, AppType::Codex | AppType::GrokBuild)
&& super::providers::codex_provider_has_catalog_model(provider)
{
// Codex catalogue provider 使用 catalog 模型,跳过 env 映射
body.clone()
} else {
let (mapped_body, _original_model, _mapped_model) =
super::model_mapper::apply_model_mapping(body.clone(), provider);
Expand Down
12 changes: 12 additions & 0 deletions src-tauri/src/proxy/providers/codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,18 @@ pub fn apply_codex_upstream_model(provider: &Provider, body: &mut JsonValue) ->
Some(upstream_model)
}

/// Check if the provider has a catalog with model mappings
/// This is used to skip env-based model mapping for providers that use catalog models
pub fn codex_provider_has_catalog_model(provider: &Provider) -> bool {
provider
.settings_config
.get("modelCatalog")
.and_then(|catalog| catalog.get("models"))
.and_then(|models| models.as_array())
.map(|models| !models.is_empty())
.unwrap_or(false)
}

pub fn resolve_codex_chat_reasoning_config(
provider: &Provider,
body: &JsonValue,
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/proxy/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ pub use claude::{
};
pub use codex::CodexAdapter;
pub use codex::{
apply_codex_chat_upstream_model, apply_codex_upstream_model, codex_provider_upstream_model,
inject_codex_chat_prompt_cache_key, is_codex_official_provider,
apply_codex_chat_upstream_model, apply_codex_upstream_model, codex_provider_has_catalog_model,
codex_provider_upstream_model, inject_codex_chat_prompt_cache_key, is_codex_official_provider,
provider_needs_responses_namespace_flatten, resolve_codex_catalog_tool_profile,
resolve_codex_chat_reasoning_config, should_convert_codex_responses_to_anthropic,
should_convert_codex_responses_to_chat,
Expand Down
Loading