Prioritize global models in the Bedrock Runtime catalog (#38617)

## What changed

Group Amazon Bedrock Runtime models by routing variant so every Global model
appears before the US cross-region models, while preserving the base model order
within each group. Update catalog priorities and tests to match the new order.

GitOrigin-RevId: e5a55d61163404172a418cb794b25f3b27f83618
This commit is contained in:
Celia Chen
2026-08-14 17:56:30 +00:00
committed by copyberry
parent fa595fbab8
commit 086396f7f6
2 changed files with 19 additions and 20 deletions

View File

@@ -9,7 +9,7 @@ const ROUTING_VARIANTS: [(&str, &str, i32); 2] =
[("global.", "Global", 0), ("us.", "US cross-region", 1)];
pub(super) fn static_runtime_model_catalog() -> ModelsResponse {
let models = static_model_catalog()
let base_models = static_model_catalog()
.models
.into_iter()
.filter(|model| {
@@ -20,19 +20,18 @@ pub(super) fn static_runtime_model_catalog() -> ModelsResponse {
| AMAZON_BEDROCK_GPT_5_6_LUNA_MODEL_ID
)
})
.flat_map(|model| {
ROUTING_VARIANTS
.into_iter()
.map(move |(prefix, routing_label, routing_priority)| {
let mut variant = model.clone();
variant.slug = format!("{prefix}{}", model.slug);
variant.display_name = format!("{} ({routing_label})", model.display_name);
variant.priority = model.priority * 2 + routing_priority;
variant.supports_search_tool = false;
variant
})
})
.collect();
.collect::<Vec<_>>();
let mut models = Vec::with_capacity(ROUTING_VARIANTS.len() * base_models.len());
for (prefix, routing_label, routing_priority) in ROUTING_VARIANTS {
for model in &base_models {
let mut variant = model.clone();
variant.slug = format!("{prefix}{}", model.slug);
variant.display_name = format!("{} ({routing_label})", model.display_name);
variant.priority = routing_priority * base_models.len() as i32 + model.priority;
variant.supports_search_tool = false;
models.push(variant);
}
}
ModelsResponse { models }
}

View File

@@ -18,14 +18,14 @@ fn runtime_catalog_includes_supported_cross_region_models_in_priority_order() {
.collect::<Vec<_>>(),
vec![
("global.openai.gpt-5.6-sol", "GPT-5.6 Sol (Global)", 0),
("us.openai.gpt-5.6-sol", "GPT-5.6 Sol (US cross-region)", 1),
("global.openai.gpt-5.6-terra", "GPT-5.6 Terra (Global)", 2),
("global.openai.gpt-5.6-terra", "GPT-5.6 Terra (Global)", 1),
("global.openai.gpt-5.6-luna", "GPT-5.6 Luna (Global)", 2),
("us.openai.gpt-5.6-sol", "GPT-5.6 Sol (US cross-region)", 3),
(
"us.openai.gpt-5.6-terra",
"GPT-5.6 Terra (US cross-region)",
3,
4,
),
("global.openai.gpt-5.6-luna", "GPT-5.6 Luna (Global)", 4),
(
"us.openai.gpt-5.6-luna",
"GPT-5.6 Luna (US cross-region)",
@@ -51,10 +51,10 @@ fn runtime_catalog_disables_web_search_without_overriding_review_models() {
.collect::<Vec<_>>(),
vec![
("global.openai.gpt-5.6-sol", None, false),
("us.openai.gpt-5.6-sol", None, false),
("global.openai.gpt-5.6-terra", None, false),
("us.openai.gpt-5.6-terra", None, false),
("global.openai.gpt-5.6-luna", None, false),
("us.openai.gpt-5.6-sol", None, false),
("us.openai.gpt-5.6-terra", None, false),
("us.openai.gpt-5.6-luna", None, false),
]
);