fix(scheduler): 恢复正则模型映射作为上游模型 (#355)

保留 provider_model_mappings 的优先级选择逻辑,但恢复
GlobalModel model_mappings 正则命中后的行为:使用命中的
allowed_model 作为实际上游 mapped_model。

修复了 #354 请求绕过基于正则表达式的模型映射的问题
This commit is contained in:
AAEE86
2026-04-28 10:36:50 +08:00
committed by GitHub
parent 0c9b5ddd77
commit 712b484bc8
3 changed files with 3 additions and 3 deletions

View File

@@ -641,7 +641,7 @@ async fn data_state_reads_minimal_candidate_selection_with_auth_filters() {
assert_eq!(selection[1].key_id, "key-3");
assert_eq!(
selection[1].selected_provider_model_name,
"gpt-4.1-canary".to_string()
"gpt-4.1-edge".to_string()
);
assert_eq!(
selection[1].mapping_matched_model,

View File

@@ -56,7 +56,7 @@ fn resolves_mapping_matched_model_from_global_regex_mapping() {
let resolved = resolve_provider_model_name(&row, "gpt-4.1", "openai:chat")
.expect("candidate should resolve");
assert_eq!(resolved.0, "gpt-4.1-canary");
assert_eq!(resolved.0, "gpt-4.1-variant");
assert_eq!(resolved.1, Some("gpt-4.1-variant".to_string()));
}

View File

@@ -123,7 +123,7 @@ pub fn resolve_provider_model_name(
for pattern in global_model_mappings {
if matches_model_mapping(pattern, allowed_model) {
let allowed_model = allowed_model.to_owned();
return Some((selected_provider_model_name.clone(), Some(allowed_model)));
return Some((allowed_model.clone(), Some(allowed_model)));
}
}
}