mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-17 23:51:30 +00:00
Fix Bedrock inference profiles for Nova Canvas image generation
- Replace naive model.split('.')[0] with ARN-aware provider detection
- Use existing get_bedrock_invoke_provider() method for inference profile ARNs
- Filter model_id parameter to prevent 'extraneous key' API errors
- Support ARN format: arn:aws:bedrock:region:account:application-inference-profile/id
- Support cross-region format: us.amazon.nova-canvas-v1:0
- Maintain backward compatibility with regular amazon.nova-canvas-v1:0 format
This commit is contained in:
parent
7c61fa3427
commit
d4d83c0edb
2 changed files with 15 additions and 1 deletions
|
|
@ -67,6 +67,10 @@ class AmazonNovaCanvasConfig:
|
|||
"""
|
||||
task_type = optional_params.pop("taskType", "TEXT_IMAGE")
|
||||
image_generation_config = optional_params.pop("imageGenerationConfig", {})
|
||||
|
||||
# Filter out model_id parameter to prevent "extraneous key" error from Bedrock API
|
||||
optional_params.pop("model_id", None)
|
||||
|
||||
image_generation_config = {**image_generation_config, **optional_params}
|
||||
if task_type == "TEXT_IMAGE":
|
||||
text_to_image_params: Dict[str, Any] = image_generation_config.pop(
|
||||
|
|
|
|||
|
|
@ -233,7 +233,17 @@ class BedrockImageGeneration(BaseAWSLLM):
|
|||
Returns:
|
||||
dict: The request body to use for the Bedrock Image Generation API
|
||||
"""
|
||||
provider = model.split(".")[0]
|
||||
# Use the existing ARN-aware provider detection method
|
||||
bedrock_provider = self.get_bedrock_invoke_provider(model)
|
||||
|
||||
if bedrock_provider == "amazon" or bedrock_provider == "nova":
|
||||
# Handle Amazon Nova Canvas models
|
||||
provider = "amazon"
|
||||
elif bedrock_provider == "stability":
|
||||
provider = "stability"
|
||||
else:
|
||||
# Fallback to original logic for backward compatibility
|
||||
provider = model.split(".")[0]
|
||||
inference_params = copy.deepcopy(optional_params)
|
||||
inference_params.pop(
|
||||
"user", None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue