refactor(bedrock): share model profile reachability checks (#9046)

* refactor(bedrock): share model profile reachability checks
This commit is contained in:
galsuchetzky-act authored and GitHub committed 2026-11-19 19:33:18 -04:00
1 parent 875794c538
commit 61be3048e7
2 files changed
+7 -5

No files matched your search

@@ -349,8 +349,7 @@ public class BedrockController {
if (model.servedInRegion(region)) {
inferenceTypes.add("ON_DEMAND");
}
if (BedrockModelCatalog.profilesFrom(region).stream()
.anyMatch(profile -> profile.modelId().equals(model.modelId()))) {
if (model.servedThroughProfileFrom(region)) {
inferenceTypes.add("INFERENCE_PROFILE");
}
node.putObject("modelLifecycle").put("status", model.lifecycleStatus());
@@ -31,6 +31,11 @@ final class BedrockModelCatalog {
boolean servedInRegion(String region) {
return inRegion.contains(region);
}
boolean servedThroughProfileFrom(String region) {
return PROFILES.stream().anyMatch(profile -> profile.modelId().equals(modelId)
&& profile.routes().containsKey(region));
}
}
/**
@@ -63,9 +68,7 @@ final class BedrockModelCatalog {
/** The models callable from a Region, in their own Region or through one of their profiles. */
static List<FoundationModel> modelsIn(String region) {
return MODELS.stream()
.filter(model -> model.servedInRegion(region) || PROFILES.stream()
.anyMatch(profile -> profile.modelId().equals(model.modelId())
&& profile.routes().containsKey(region)))
.filter(model -> model.servedInRegion(region) || model.servedThroughProfileFrom(region))
.toList();
}