mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 01:40:21 +08:00
Fix regex model mapping direction
This commit is contained in:
@@ -815,7 +815,7 @@ async fn data_state_reads_minimal_candidate_selection_with_auth_filters() {
|
|||||||
assert_eq!(selection[1].key_id, "key-3");
|
assert_eq!(selection[1].key_id, "key-3");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
selection[1].selected_provider_model_name,
|
selection[1].selected_provider_model_name,
|
||||||
"gpt-4.1-edge".to_string()
|
"gpt-4.1-canary".to_string()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
selection[1].mapping_matched_model,
|
selection[1].mapping_matched_model,
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ fn resolves_mapping_matched_model_from_global_regex_mapping() {
|
|||||||
let resolved = resolve_provider_model_name(&row, "gpt-4.1", "openai:chat")
|
let resolved = resolve_provider_model_name(&row, "gpt-4.1", "openai:chat")
|
||||||
.expect("candidate should resolve");
|
.expect("candidate should resolve");
|
||||||
|
|
||||||
assert_eq!(resolved.0, "gpt-4.1-variant");
|
assert_eq!(resolved.0, "gpt-4.1-canary");
|
||||||
assert_eq!(resolved.1, Some("gpt-4.1-variant".to_string()));
|
assert_eq!(resolved.1, Some("gpt-4.1-variant".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,9 @@ pub fn resolve_provider_model_name_with_model_directives(
|
|||||||
for pattern in global_model_mappings {
|
for pattern in global_model_mappings {
|
||||||
if matches_model_mapping(pattern, allowed_model) {
|
if matches_model_mapping(pattern, allowed_model) {
|
||||||
let allowed_model = allowed_model.to_owned();
|
let allowed_model = allowed_model.to_owned();
|
||||||
return Some((allowed_model.clone(), Some(allowed_model)));
|
// Regex mappings prove the key can serve this global model; they do not
|
||||||
|
// override the provider model chosen from the Provider model mapping.
|
||||||
|
return Some((selected_provider_model_name.clone(), Some(allowed_model)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -392,7 +394,9 @@ mod tests {
|
|||||||
resolve_requested_global_model_name_with_model_directives, row_supports_requested_model,
|
resolve_requested_global_model_name_with_model_directives, row_supports_requested_model,
|
||||||
row_supports_requested_model_with_model_directives,
|
row_supports_requested_model_with_model_directives,
|
||||||
};
|
};
|
||||||
use aether_data_contracts::repository::candidate_selection::StoredMinimalCandidateSelectionRow;
|
use aether_data_contracts::repository::candidate_selection::{
|
||||||
|
StoredMinimalCandidateSelectionRow, StoredProviderModelMapping,
|
||||||
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn model_mapping_match_is_case_insensitive() {
|
fn model_mapping_match_is_case_insensitive() {
|
||||||
@@ -411,6 +415,25 @@ mod tests {
|
|||||||
assert!(!matches_model_mapping("([a-z", "gpt-4o"));
|
assert!(!matches_model_mapping("([a-z", "gpt-4o"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn regex_allowed_model_does_not_replace_selected_provider_model_name() {
|
||||||
|
let mut row = sample_row("gpt-5", "gpt-5-upstream");
|
||||||
|
row.key_allowed_models = Some(vec!["gpt-5.4".to_string()]);
|
||||||
|
row.global_model_mappings = Some(vec!["gpt-5(?:\\.\\d+)?".to_string()]);
|
||||||
|
row.model_provider_model_mappings = Some(vec![StoredProviderModelMapping {
|
||||||
|
name: "gpt-5-canonical-upstream".to_string(),
|
||||||
|
priority: 1,
|
||||||
|
api_formats: Some(vec!["openai:chat".to_string()]),
|
||||||
|
endpoint_ids: None,
|
||||||
|
}]);
|
||||||
|
|
||||||
|
let resolved = resolve_provider_model_name(&row, "gpt-5", "openai:chat")
|
||||||
|
.expect("regex-matched allowed model should allow the key");
|
||||||
|
|
||||||
|
assert_eq!(resolved.0, "gpt-5-canonical-upstream");
|
||||||
|
assert_eq!(resolved.1.as_deref(), Some("gpt-5.4"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn model_directive_suffix_matches_base_model_as_fallback() {
|
fn model_directive_suffix_matches_base_model_as_fallback() {
|
||||||
let row = sample_row("gpt-5.4", "gpt-5.4-upstream");
|
let row = sample_row("gpt-5.4", "gpt-5.4-upstream");
|
||||||
|
|||||||
Reference in New Issue
Block a user