feat: dynamic Bedrock model listing with LiteLLM metadata enrichment#3352
Open
carTloyal123 wants to merge 1 commit into
Open
feat: dynamic Bedrock model listing with LiteLLM metadata enrichment#3352carTloyal123 wants to merge 1 commit into
carTloyal123 wants to merge 1 commit into
Conversation
|
|
Replace the hardcoded Bedrock model list with live AWS API calls to ListFoundationModels and ListInferenceProfiles. This ensures users only see models they have access to in their account and region, solving the GovCloud model filtering problem. Key changes: - Add aws-sdk-bedrock dependency for control plane API - Implement init_control_client() for model listing (separate from chat client) - Call ListFoundationModels filtered to ON_DEMAND, streaming, ACTIVE - Call ListInferenceProfiles for cross-region inference profiles - Enrich model metadata (context_length, tools, reasoning, vision) from the LiteLLM community registry JSON - Graceful fallback to hardcoded model list when API permissions are missing - Add optional AWS_USE_FIPS URL param for GovCloud FIPS endpoints - Add 10 new unit tests covering model mapping, enrichment, fallback, and FIPS config GovCloud users with us-gov-west-1 region will now see only their available models with correct context window sizes. Commercial users benefit from seeing only models they have enabled. Co-Authored-By: ForgeCode <noreply@forgecode.dev>
c2fefa1 to
9614c9f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the hardcoded Bedrock model list with live AWS API calls, ensuring users only see models they have access to in their account and region. This solves the GovCloud model filtering problem and improves UX for commercial Bedrock users.
Problem
The Bedrock provider returns ~80+ hardcoded models from
provider.jsonregardless of the user's account, region, or enabled models. GovCloud users see commercial-only models they can't use, and commercial users see models they haven't enabled in their Bedrock console.Solution
Two-source architecture:
AWS
ListFoundationModels+ListInferenceProfiles-- Account/region-aware APIs that return only accessible models. Filtered to ON_DEMAND, streaming-capable, ACTIVE models.LiteLLM community registry (
model_prices_and_context_window.json) -- Enriches each model withcontext_length,tools_supported,supports_reasoning,supports_visionmetadata that AWS APIs don't provide.Both sources gracefully degrade: AWS API failure falls back to the hardcoded list; LiteLLM failure just means missing metadata.
Changes
Cargo.tomlaws-sdk-bedrockworkspace dependencycrates/forge_repo/Cargo.tomlaws-sdk-bedrockcrate referencecrates/forge_repo/src/provider/bedrock.rscrates/forge_repo/src/provider/provider.jsonAWS_USE_FIPSURL param for GovCloudKey Implementation Details
init_control_client()): Separateaws_sdk_bedrock::Clientfor model listing, same auth mode and region as the chat clientus.anthropic.claude-3-5-sonnet) merged and deduplicatedListFoundationModelsfails (missing IAM permission), returns hardcoded list with warning logAWS_USE_FIPS=trueparam enables FIPS endpoints on both data and control plane clientsTesting
cargo checkpasses across full workspaceGovCloud Usage
Co-Authored-By: ForgeCode noreply@forgecode.dev