mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(bedrock): report inference profile support in model metadata (#9020)
Derive INFERENCE_PROFILE support from existing system profile routes while preserving regional ON_DEMAND support and request-filter validation. Cover Get and List metadata through raw SDK strings, including profile-only and unavailable regions. Closes #8450
This commit is contained in:
1 parent
1ffa5ed2c9
commit
683cb84080
4 files changed
+87
-4
No files matched your search
@@ -134,9 +134,10 @@ The answers depend on the calling Region, as on AWS:
|
||||
the calling Region, so `us.amazon.nova-lite-v1:0` called from `us-west-1` routes to four Regions and from
|
||||
`us-east-1` to three. `GetInferenceProfile` on a profile the Region cannot use returns
|
||||
`ResourceNotFoundException`.
|
||||
- `inferenceTypesSupported` is `ON_DEMAND` only where the model is served in the Region
|
||||
itself, and empty where it is reachable only through an inference profile, so
|
||||
`byInferenceType=ON_DEMAND` leaves those out.
|
||||
- `inferenceTypesSupported` includes `ON_DEMAND` where the model is served in the Region
|
||||
itself, and `INFERENCE_PROFILE` where a seeded system-defined profile can be called from
|
||||
the Region. A model reachable only through a profile reports `INFERENCE_PROFILE` without
|
||||
`ON_DEMAND`, so `byInferenceType=ON_DEMAND` leaves those out.
|
||||
- `modelArn` is `arn:<partition>:bedrock:<region>::foundation-model/<modelId>`, and
|
||||
the system-defined `inferenceProfileArn` carries the calling Region and account.
|
||||
`GetInferenceProfile` answers an ARN of another service or without an account with
|
||||
|
||||
@@ -349,6 +349,10 @@ public class BedrockController {
|
||||
if (model.servedInRegion(region)) {
|
||||
inferenceTypes.add("ON_DEMAND");
|
||||
}
|
||||
if (BedrockModelCatalog.profilesFrom(region).stream()
|
||||
.anyMatch(profile -> profile.modelId().equals(model.modelId()))) {
|
||||
inferenceTypes.add("INFERENCE_PROFILE");
|
||||
}
|
||||
node.putObject("modelLifecycle").put("status", model.lifecycleStatus());
|
||||
return node;
|
||||
}
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package io.floci.aws.services.bedrock;
|
||||
|
||||
import io.floci.aws.testing.AwsTestClients;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.bedrock.BedrockClient;
|
||||
import software.amazon.awssdk.services.bedrock.model.FoundationModelDetails;
|
||||
import software.amazon.awssdk.services.bedrock.model.FoundationModelSummary;
|
||||
import software.amazon.awssdk.services.bedrock.model.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@QuarkusTest
|
||||
class BedrockInferenceProfileMetadataIntegrationTest {
|
||||
|
||||
private static final String MODEL = "amazon.nova-lite-v1:0";
|
||||
|
||||
@Test
|
||||
void getFoundationModelAdvertisesOnDemandAndInferenceProfileSupport() {
|
||||
try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.US_EAST_1)) {
|
||||
FoundationModelDetails model = client.getFoundationModel(request -> request.modelIdentifier(MODEL))
|
||||
.modelDetails();
|
||||
assertEquals(MODEL, model.modelId());
|
||||
assertEquals(List.of("ON_DEMAND", "INFERENCE_PROFILE"), model.inferenceTypesSupportedAsStrings());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void modelWithoutAProfileOnlyAdvertisesOnDemandSupport() {
|
||||
try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.US_EAST_1)) {
|
||||
String modelId = "amazon.titan-embed-text-v2:0";
|
||||
assertEquals(List.of("ON_DEMAND"), client.getFoundationModel(request -> request
|
||||
.modelIdentifier(modelId)).modelDetails().inferenceTypesSupportedAsStrings());
|
||||
FoundationModelSummary listed = client.listFoundationModels(request -> { }).modelSummaries().stream()
|
||||
.filter(model -> modelId.equals(model.modelId())).findFirst().orElseThrow();
|
||||
assertEquals(List.of("ON_DEMAND"), listed.inferenceTypesSupportedAsStrings());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void listFoundationModelsAdvertisesOnDemandAndInferenceProfileSupport() {
|
||||
try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.US_EAST_1)) {
|
||||
FoundationModelSummary model = client.listFoundationModels(request -> { }).modelSummaries().stream()
|
||||
.filter(candidate -> MODEL.equals(candidate.modelId())).findFirst().orElseThrow();
|
||||
assertEquals(List.of("ON_DEMAND", "INFERENCE_PROFILE"), model.inferenceTypesSupportedAsStrings());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void profileOnlyRegionAdvertisesOnlyInferenceProfilesOnGetAndList() {
|
||||
String modelId = "amazon.nova-micro-v1:0";
|
||||
try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.EU_CENTRAL_1)) {
|
||||
assertEquals(List.of("INFERENCE_PROFILE"), client.getFoundationModel(request -> request
|
||||
.modelIdentifier(modelId)).modelDetails().inferenceTypesSupportedAsStrings());
|
||||
FoundationModelSummary listed = client.listFoundationModels(request -> { }).modelSummaries().stream()
|
||||
.filter(model -> modelId.equals(model.modelId())).findFirst().orElseThrow();
|
||||
assertEquals(List.of("INFERENCE_PROFILE"), listed.inferenceTypesSupportedAsStrings());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void unavailableRegionExcludesTheModelAndRetainsGetValidation() {
|
||||
try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022",
|
||||
Region.AP_NORTHEAST_3)) {
|
||||
ValidationException error = assertThrows(ValidationException.class,
|
||||
() -> client.getFoundationModel(request -> request.modelIdentifier(MODEL)));
|
||||
assertEquals(400, error.statusCode());
|
||||
assertFalse(client.listFoundationModels(request -> { }).modelSummaries().stream()
|
||||
.anyMatch(model -> MODEL.equals(model.modelId())));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -146,7 +146,7 @@ class BedrockModelCatalogIntegrationTest {
|
||||
try (BedrockClient client = client("eu-central-1")) {
|
||||
FoundationModelSummary novaMicro = client.listFoundationModels(request -> { }).modelSummaries().stream()
|
||||
.filter(model -> model.modelId().equals(NOVA_MICRO)).findFirst().orElseThrow();
|
||||
assertTrue(novaMicro.inferenceTypesSupported().isEmpty(),
|
||||
assertEquals(List.of("INFERENCE_PROFILE"), novaMicro.inferenceTypesSupportedAsStrings(),
|
||||
"Nova Micro is reachable from eu-central-1 only through eu." + NOVA_MICRO);
|
||||
|
||||
List<String> onDemand = client.listFoundationModels(request -> request
|
||||
|
||||
Reference in new issue
Block a user