Andrea Cosentino created CAMEL-23463:
----------------------------------------
Summary: Camel-AWS-Bedrock: invokeTextModel throws "Unexpected
model" for image/embedding/rerank/Stability/Nova-canvas models declared in
BedrockModels
Key: CAMEL-23463
URL: https://issues.apache.org/jira/browse/CAMEL-23463
Project: Camel
Issue Type: Bug
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
{{BedrockProducer#setResponseText}} switches on {{modelId}} to extract text
from invocation responses. The switch is missing several entries that are
present in the {{BedrockModels}} enum and listed in
{{BedrockConfiguration.modelId}}'s {{@UriParam(enums=...)}}. These models fall
through to the {{default}} branch and throw {{IllegalStateException("Unexpected
model: <modelId>")}}.
*Affected models declared but not handled:*
* {{cohere.embed-english-v3}}, {{cohere.embed-multilingual-v3}},
{{cohere.rerank-v3-5:0}}
* {{amazon.rerank-v1:0}}
* {{amazon.titan-embed-text-v1}}, {{amazon.titan-embed-image-v1}}
* {{amazon.nova-canvas-v1:0}}, {{amazon.nova-reel-v1:0}},
{{amazon.nova-reel-v1:1}}, {{amazon.nova-sonic-v1:0}}
* {{amazon.titan-image-generator-v1}}, {{amazon.titan-image-generator-v2:0}}
* All {{stability.*}} models
These are listed as valid model IDs in the endpoint configuration's
{{@UriParam(enums=...)}}, so users will reasonably try them via
{{invokeTextModel}} and get a confusing {{IllegalStateException}}.
*Files:*
*
{{components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockProducer.java:265-375}}
*
{{components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/BedrockModels.java}}
*Suggested fix:*
* Either route image/embedding/rerank model IDs to the appropriate operation
({{invokeImageModel}} / {{invokeEmbeddingsModel}}) automatically, or document
that those models cannot be used with {{invokeTextModel}} and validate at
endpoint creation time.
* Consider extracting the per-model response shaping into a
{{ResponseParserFactory}} mirroring {{StreamParserFactory}} to avoid the
brittle {{switch}} list.
----
_Filed by Claude Code on behalf of Andrea Cosentino._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)