This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch aws-bedrock-guardrails in repository https://gitbox.apache.org/repos/asf/camel.git
commit b4d9119f6ccae7186b7eb2b59cacd02b19a81f04 Author: Andrea Cosentino <[email protected]> AuthorDate: Thu Nov 13 16:58:39 2025 +0100 Camel-AWS-Bedrock: Added Guardrails support Signed-off-by: Andrea Cosentino <[email protected]> --- .../runtime/BedrockComponentConfigurer.java | 18 ++ .../bedrock/runtime/BedrockEndpointConfigurer.java | 18 ++ .../bedrock/runtime/BedrockEndpointUriFactory.java | 5 +- .../aws2/bedrock/runtime/aws-bedrock.json | 109 ++++---- .../aws2/bedrock/runtime/BedrockConfiguration.java | 39 +++ .../aws2/bedrock/runtime/BedrockConstants.java | 14 ++ .../aws2/bedrock/runtime/BedrockOperations.java | 4 +- .../aws2/bedrock/runtime/BedrockProducer.java | 122 +++++++++ .../runtime/stream/ConverseStreamHandler.java | 9 + .../runtime/integration/BedrockGuardrailsIT.java | 278 +++++++++++++++++++++ 10 files changed, 566 insertions(+), 50 deletions(-) diff --git a/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockComponentConfigurer.java b/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockComponentConfigurer.java index 26c047097bad..d971f656db16 100644 --- a/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockComponentConfigurer.java +++ b/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockComponentConfigurer.java @@ -39,6 +39,12 @@ public class BedrockComponentConfigurer extends PropertyConfigurerSupport implem case "bedrockruntimeclient": case "bedrockRuntimeClient": getOrCreateConfiguration(target).setBedrockRuntimeClient(property(camelContext, software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient.class, value)); return true; case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration.class, value)); return true; + case "guardrailidentifier": + case "guardrailIdentifier": getOrCreateConfiguration(target).setGuardrailIdentifier(property(camelContext, java.lang.String.class, value)); return true; + case "guardrailtrace": + case "guardrailTrace": getOrCreateConfiguration(target).setGuardrailTrace(property(camelContext, boolean.class, value)); return true; + case "guardrailversion": + case "guardrailVersion": getOrCreateConfiguration(target).setGuardrailVersion(property(camelContext, java.lang.String.class, value)); return true; case "healthcheckconsumerenabled": case "healthCheckConsumerEnabled": target.setHealthCheckConsumerEnabled(property(camelContext, boolean.class, value)); return true; case "healthcheckproducerenabled": @@ -100,6 +106,12 @@ public class BedrockComponentConfigurer extends PropertyConfigurerSupport implem case "bedrockruntimeclient": case "bedrockRuntimeClient": return software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient.class; case "configuration": return org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration.class; + case "guardrailidentifier": + case "guardrailIdentifier": return java.lang.String.class; + case "guardrailtrace": + case "guardrailTrace": return boolean.class; + case "guardrailversion": + case "guardrailVersion": return java.lang.String.class; case "healthcheckconsumerenabled": case "healthCheckConsumerEnabled": return boolean.class; case "healthcheckproducerenabled": @@ -157,6 +169,12 @@ public class BedrockComponentConfigurer extends PropertyConfigurerSupport implem case "bedrockruntimeclient": case "bedrockRuntimeClient": return getOrCreateConfiguration(target).getBedrockRuntimeClient(); case "configuration": return target.getConfiguration(); + case "guardrailidentifier": + case "guardrailIdentifier": return getOrCreateConfiguration(target).getGuardrailIdentifier(); + case "guardrailtrace": + case "guardrailTrace": return getOrCreateConfiguration(target).isGuardrailTrace(); + case "guardrailversion": + case "guardrailVersion": return getOrCreateConfiguration(target).getGuardrailVersion(); case "healthcheckconsumerenabled": case "healthCheckConsumerEnabled": return target.isHealthCheckConsumerEnabled(); case "healthcheckproducerenabled": diff --git a/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpointConfigurer.java b/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpointConfigurer.java index 2f9abe6fe4cf..142eb4f8a4fe 100644 --- a/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpointConfigurer.java +++ b/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpointConfigurer.java @@ -29,6 +29,12 @@ public class BedrockEndpointConfigurer extends PropertyConfigurerSupport impleme case "bedrockRuntimeAsyncClient": target.getConfiguration().setBedrockRuntimeAsyncClient(property(camelContext, software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient.class, value)); return true; case "bedrockruntimeclient": case "bedrockRuntimeClient": target.getConfiguration().setBedrockRuntimeClient(property(camelContext, software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient.class, value)); return true; + case "guardrailidentifier": + case "guardrailIdentifier": target.getConfiguration().setGuardrailIdentifier(property(camelContext, java.lang.String.class, value)); return true; + case "guardrailtrace": + case "guardrailTrace": target.getConfiguration().setGuardrailTrace(property(camelContext, boolean.class, value)); return true; + case "guardrailversion": + case "guardrailVersion": target.getConfiguration().setGuardrailVersion(property(camelContext, java.lang.String.class, value)); return true; case "includestreamingmetadata": case "includeStreamingMetadata": target.getConfiguration().setIncludeStreamingMetadata(property(camelContext, boolean.class, value)); return true; case "lazystartproducer": @@ -83,6 +89,12 @@ public class BedrockEndpointConfigurer extends PropertyConfigurerSupport impleme case "bedrockRuntimeAsyncClient": return software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient.class; case "bedrockruntimeclient": case "bedrockRuntimeClient": return software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient.class; + case "guardrailidentifier": + case "guardrailIdentifier": return java.lang.String.class; + case "guardrailtrace": + case "guardrailTrace": return boolean.class; + case "guardrailversion": + case "guardrailVersion": return java.lang.String.class; case "includestreamingmetadata": case "includeStreamingMetadata": return boolean.class; case "lazystartproducer": @@ -133,6 +145,12 @@ public class BedrockEndpointConfigurer extends PropertyConfigurerSupport impleme case "bedrockRuntimeAsyncClient": return target.getConfiguration().getBedrockRuntimeAsyncClient(); case "bedrockruntimeclient": case "bedrockRuntimeClient": return target.getConfiguration().getBedrockRuntimeClient(); + case "guardrailidentifier": + case "guardrailIdentifier": return target.getConfiguration().getGuardrailIdentifier(); + case "guardrailtrace": + case "guardrailTrace": return target.getConfiguration().isGuardrailTrace(); + case "guardrailversion": + case "guardrailVersion": return target.getConfiguration().getGuardrailVersion(); case "includestreamingmetadata": case "includeStreamingMetadata": return target.getConfiguration().isIncludeStreamingMetadata(); case "lazystartproducer": diff --git a/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpointUriFactory.java b/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpointUriFactory.java index c227bb3c3424..8a5be556f19b 100644 --- a/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpointUriFactory.java +++ b/components/camel-aws/camel-aws-bedrock/src/generated/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpointUriFactory.java @@ -23,10 +23,13 @@ public class BedrockEndpointUriFactory extends org.apache.camel.support.componen private static final Set<String> SECRET_PROPERTY_NAMES; private static final Map<String, String> MULTI_VALUE_PREFIXES; static { - Set<String> props = new HashSet<>(23); + Set<String> props = new HashSet<>(26); props.add("accessKey"); props.add("bedrockRuntimeAsyncClient"); props.add("bedrockRuntimeClient"); + props.add("guardrailIdentifier"); + props.add("guardrailTrace"); + props.add("guardrailVersion"); props.add("includeStreamingMetadata"); props.add("label"); props.add("lazyStartProducer"); diff --git a/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/runtime/aws-bedrock.json b/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/runtime/aws-bedrock.json index c0e225cebfe3..40345af16750 100644 --- a/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/runtime/aws-bedrock.json +++ b/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/runtime/aws-bedrock.json @@ -25,31 +25,34 @@ }, "componentProperties": { "configuration": { "index": 0, "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "Component configuration" }, - "includeStreamingMetadata": { "index": 1, "kind": "property", "displayName": "Include Streaming Metadata", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Whether to include streaming metadata in the response hea [...] - "lazyStartProducer": { "index": 2, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...] - "modelId": { "index": 3, "kind": "property", "displayName": "Model Id", "group": "producer", "label": "", "required": true, "type": "enum", "javaType": "java.lang.String", "enum": [ "amazon.titan-text-express-v1", "amazon.titan-text-lite-v1", "amazon.titan-image-generator-v1", "amazon.titan-embed-text-v1", "amazon.titan-embed-image-v1", "amazon.titan-text-premier-v1:0", "amazon.titan-embed-text-v2:0", "amazon.titan-image-generator-v2:0", "amazon.nova-canvas-v1:0", "amazon.nova-lite-v [...] - "operation": { "index": 4, "kind": "property", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "enum", "javaType": "org.apache.camel.component.aws2.bedrock.runtime.BedrockOperations", "enum": [ "invokeTextModel", "invokeImageModel", "invokeEmbeddingsModel", "invokeTextModelStreaming", "invokeImageModelStreaming", "invokeEmbeddingsModelStreaming", "converse", "converseStream" ], "deprecated": false, "deprecationNote": "", "autowired": false, "se [...] - "overrideEndpoint": { "index": 5, "kind": "property", "displayName": "Override Endpoint", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used in [...] - "pojoRequest": { "index": 6, "kind": "property", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" }, - "profileCredentialsName": { "index": 7, "kind": "property", "displayName": "Profile Credentials Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If using a profile credentials provider, this para [...] - "region": { "index": 8, "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "us-east-1", "us-west-1", "ap-southeast-1", "ap-northeast-1", "eu-central-1" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The region in which B [...] - "streamOutputMode": { "index": 9, "kind": "property", "displayName": "Stream Output Mode", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "complete", "chunks" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "complete", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The streaming output mode ( [...] - "uriEndpointOverride": { "index": 10, "kind": "property", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination wit [...] - "useDefaultCredentialsProvider": { "index": 11, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expect [...] - "useProfileCredentialsProvider": { "index": 12, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expect [...] - "autowiredEnabled": { "index": 13, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching [...] - "bedrockRuntimeAsyncClient": { "index": 14, "kind": "property", "displayName": "Bedrock Runtime Async Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration [...] - "bedrockRuntimeClient": { "index": 15, "kind": "property", "displayName": "Bedrock Runtime Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description" [...] - "healthCheckConsumerEnabled": { "index": 16, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" }, - "healthCheckProducerEnabled": { "index": 17, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on produce [...] - "proxyHost": { "index": 18, "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Bedrock client" }, - "proxyPort": { "index": 19, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Bedrock client" }, - "proxyProtocol": { "index": 20, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy p [...] - "accessKey": { "index": 21, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" }, - "secretKey": { "index": 22, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, - "sessionToken": { "index": 23, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, - "trustAllCertificates": { "index": 24, "kind": "property", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overrid [...] - "useSessionCredentials": { "index": 25, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expect to use S [...] + "guardrailIdentifier": { "index": 1, "kind": "property", "displayName": "Guardrail Identifier", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The identifier (ID or ARN) for the guardrail to apply to the model invocation" }, + "guardrailTrace": { "index": 2, "kind": "property", "displayName": "Guardrail Trace", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Whether to return trace information from the guardrail" }, + "guardrailVersion": { "index": 3, "kind": "property", "displayName": "Guardrail Version", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "DRAFT", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The version of the guardrail to use. Defaults to DRAFT." }, + "includeStreamingMetadata": { "index": 4, "kind": "property", "displayName": "Include Streaming Metadata", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Whether to include streaming metadata in the response hea [...] + "lazyStartProducer": { "index": 5, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...] + "modelId": { "index": 6, "kind": "property", "displayName": "Model Id", "group": "producer", "label": "", "required": true, "type": "enum", "javaType": "java.lang.String", "enum": [ "amazon.titan-text-express-v1", "amazon.titan-text-lite-v1", "amazon.titan-image-generator-v1", "amazon.titan-embed-text-v1", "amazon.titan-embed-image-v1", "amazon.titan-text-premier-v1:0", "amazon.titan-embed-text-v2:0", "amazon.titan-image-generator-v2:0", "amazon.nova-canvas-v1:0", "amazon.nova-lite-v [...] + "operation": { "index": 7, "kind": "property", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "enum", "javaType": "org.apache.camel.component.aws2.bedrock.runtime.BedrockOperations", "enum": [ "invokeTextModel", "invokeImageModel", "invokeEmbeddingsModel", "invokeTextModelStreaming", "invokeImageModelStreaming", "invokeEmbeddingsModelStreaming", "converse", "converseStream", "applyGuardrail" ], "deprecated": false, "deprecationNote": "", "auto [...] + "overrideEndpoint": { "index": 8, "kind": "property", "displayName": "Override Endpoint", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used in [...] + "pojoRequest": { "index": 9, "kind": "property", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" }, + "profileCredentialsName": { "index": 10, "kind": "property", "displayName": "Profile Credentials Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If using a profile credentials provider, this par [...] + "region": { "index": 11, "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "us-east-1", "us-west-1", "ap-southeast-1", "ap-northeast-1", "eu-central-1" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The region in which [...] + "streamOutputMode": { "index": 12, "kind": "property", "displayName": "Stream Output Mode", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "complete", "chunks" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "complete", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The streaming output mode [...] + "uriEndpointOverride": { "index": 13, "kind": "property", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination wit [...] + "useDefaultCredentialsProvider": { "index": 14, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expect [...] + "useProfileCredentialsProvider": { "index": 15, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expect [...] + "autowiredEnabled": { "index": 16, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching [...] + "bedrockRuntimeAsyncClient": { "index": 17, "kind": "property", "displayName": "Bedrock Runtime Async Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration [...] + "bedrockRuntimeClient": { "index": 18, "kind": "property", "displayName": "Bedrock Runtime Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description" [...] + "healthCheckConsumerEnabled": { "index": 19, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" }, + "healthCheckProducerEnabled": { "index": 20, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on produce [...] + "proxyHost": { "index": 21, "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Bedrock client" }, + "proxyPort": { "index": 22, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Bedrock client" }, + "proxyProtocol": { "index": 23, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy p [...] + "accessKey": { "index": 24, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" }, + "secretKey": { "index": 25, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, + "sessionToken": { "index": 26, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, + "trustAllCertificates": { "index": 27, "kind": "property", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overrid [...] + "useSessionCredentials": { "index": 28, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expect to use S [...] }, "headers": { "CamelAwsBedrockOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#OPERATION" }, @@ -66,31 +69,41 @@ "CamelAwsBedrockConverseAdditionalFields": { "index": 11, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "software.amazon.awssdk.core.document.Document", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The additional model request fields for Converse API", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#CONVERSE_ADDITIONAL_MODEL_REQUEST_FIELDS" }, "CamelAwsBedrockConverseStopReason": { "index": 12, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The stop reason from Converse API response", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#CONVERSE_STOP_REASON" }, "CamelAwsBedrockConverseUsage": { "index": 13, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "TokenUsage", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The usage metrics from Converse API response", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#CONVERSE_USAGE" }, - "CamelAwsBedrockConverseOutputMessage": { "index": 14, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Message", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The output message from Converse API response", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#CONVERSE_OUTPUT_MESSAGE" } + "CamelAwsBedrockConverseOutputMessage": { "index": 14, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Message", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The output message from Converse API response", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#CONVERSE_OUTPUT_MESSAGE" }, + "CamelAwsBedrockGuardrailConfig": { "index": 15, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "GuardrailConfiguration", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The guardrail configuration to apply to the request", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#GUARDRAIL_CONFIG" }, + "CamelAwsBedrockGuardrailContent": { "index": 16, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "List<GuardrailContentBlock>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The content blocks for ApplyGuardrail operation", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#GUARDRAIL_CONTENT" }, + "CamelAwsBedrockGuardrailSource": { "index": 17, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The source type for ApplyGuardrail operation (INPUT or OUTPUT)", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#GUARDRAIL_SOURCE" }, + "CamelAwsBedrockGuardrailOutput": { "index": 18, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "GuardrailAssessment", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The guardrail assessment output from the response", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#GUARDRAIL_OUTPUT" }, + "CamelAwsBedrockGuardrailTrace": { "index": 19, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "GuardrailTrace", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The trace information from guardrail evaluation", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#GUARDRAIL_TRACE" }, + "CamelAwsBedrockGuardrailAssessments": { "index": 20, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "List<GuardrailAssessment>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The guardrail assessments from ApplyGuardrail response", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#GUARDRAIL_ASSESSMENTS" }, + "CamelAwsBedrockGuardrailUsage": { "index": 21, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "GuardrailUsage", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The guardrail usage metrics from ApplyGuardrail response", "constantName": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants#GUARDRAIL_USAGE" } }, "properties": { "label": { "index": 0, "kind": "path", "displayName": "Label", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Logical name" }, - "includeStreamingMetadata": { "index": 1, "kind": "parameter", "displayName": "Include Streaming Metadata", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Whether to include streaming metadata in the response he [...] - "modelId": { "index": 2, "kind": "parameter", "displayName": "Model Id", "group": "producer", "label": "", "required": true, "type": "enum", "javaType": "java.lang.String", "enum": [ "amazon.titan-text-express-v1", "amazon.titan-text-lite-v1", "amazon.titan-image-generator-v1", "amazon.titan-embed-text-v1", "amazon.titan-embed-image-v1", "amazon.titan-text-premier-v1:0", "amazon.titan-embed-text-v2:0", "amazon.titan-image-generator-v2:0", "amazon.nova-canvas-v1:0", "amazon.nova-lite- [...] - "operation": { "index": 3, "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "enum", "javaType": "org.apache.camel.component.aws2.bedrock.runtime.BedrockOperations", "enum": [ "invokeTextModel", "invokeImageModel", "invokeEmbeddingsModel", "invokeTextModelStreaming", "invokeImageModelStreaming", "invokeEmbeddingsModelStreaming", "converse", "converseStream" ], "deprecated": false, "deprecationNote": "", "autowired": false, "s [...] - "overrideEndpoint": { "index": 4, "kind": "parameter", "displayName": "Override Endpoint", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used i [...] - "pojoRequest": { "index": 5, "kind": "parameter", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" }, - "profileCredentialsName": { "index": 6, "kind": "parameter", "displayName": "Profile Credentials Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If using a profile credentials provider, this par [...] - "region": { "index": 7, "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "us-east-1", "us-west-1", "ap-southeast-1", "ap-northeast-1", "eu-central-1" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The region in which [...] - "streamOutputMode": { "index": 8, "kind": "parameter", "displayName": "Stream Output Mode", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "complete", "chunks" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "complete", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The streaming output mode [...] - "uriEndpointOverride": { "index": 9, "kind": "parameter", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination wit [...] - "useDefaultCredentialsProvider": { "index": 10, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expec [...] - "useProfileCredentialsProvider": { "index": 11, "kind": "parameter", "displayName": "Use Profile Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expec [...] - "lazyStartProducer": { "index": 12, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produ [...] - "bedrockRuntimeAsyncClient": { "index": 13, "kind": "parameter", "displayName": "Bedrock Runtime Async Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuratio [...] - "bedrockRuntimeClient": { "index": 14, "kind": "parameter", "displayName": "Bedrock Runtime Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description [...] - "proxyHost": { "index": 15, "kind": "parameter", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Bedrock client" }, - "proxyPort": { "index": 16, "kind": "parameter", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Bedrock client" }, - "proxyProtocol": { "index": 17, "kind": "parameter", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy [...] - "accessKey": { "index": 18, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" }, - "secretKey": { "index": 19, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, - "sessionToken": { "index": 20, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, - "trustAllCertificates": { "index": 21, "kind": "parameter", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overri [...] - "useSessionCredentials": { "index": 22, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expect to use [...] + "guardrailIdentifier": { "index": 1, "kind": "parameter", "displayName": "Guardrail Identifier", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The identifier (ID or ARN) for the guardrail to apply to the model invocation" }, + "guardrailTrace": { "index": 2, "kind": "parameter", "displayName": "Guardrail Trace", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Whether to return trace information from the guardrail" }, + "guardrailVersion": { "index": 3, "kind": "parameter", "displayName": "Guardrail Version", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "DRAFT", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The version of the guardrail to use. Defaults to DRAFT." }, + "includeStreamingMetadata": { "index": 4, "kind": "parameter", "displayName": "Include Streaming Metadata", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Whether to include streaming metadata in the response he [...] + "modelId": { "index": 5, "kind": "parameter", "displayName": "Model Id", "group": "producer", "label": "", "required": true, "type": "enum", "javaType": "java.lang.String", "enum": [ "amazon.titan-text-express-v1", "amazon.titan-text-lite-v1", "amazon.titan-image-generator-v1", "amazon.titan-embed-text-v1", "amazon.titan-embed-image-v1", "amazon.titan-text-premier-v1:0", "amazon.titan-embed-text-v2:0", "amazon.titan-image-generator-v2:0", "amazon.nova-canvas-v1:0", "amazon.nova-lite- [...] + "operation": { "index": 6, "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "enum", "javaType": "org.apache.camel.component.aws2.bedrock.runtime.BedrockOperations", "enum": [ "invokeTextModel", "invokeImageModel", "invokeEmbeddingsModel", "invokeTextModelStreaming", "invokeImageModelStreaming", "invokeEmbeddingsModelStreaming", "converse", "converseStream", "applyGuardrail" ], "deprecated": false, "deprecationNote": "", "aut [...] + "overrideEndpoint": { "index": 7, "kind": "parameter", "displayName": "Override Endpoint", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used i [...] + "pojoRequest": { "index": 8, "kind": "parameter", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" }, + "profileCredentialsName": { "index": 9, "kind": "parameter", "displayName": "Profile Credentials Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If using a profile credentials provider, this par [...] + "region": { "index": 10, "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "us-east-1", "us-west-1", "ap-southeast-1", "ap-northeast-1", "eu-central-1" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The region in which [...] + "streamOutputMode": { "index": 11, "kind": "parameter", "displayName": "Stream Output Mode", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "complete", "chunks" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "complete", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "The streaming output mode [...] + "uriEndpointOverride": { "index": 12, "kind": "parameter", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination wi [...] + "useDefaultCredentialsProvider": { "index": 13, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expec [...] + "useProfileCredentialsProvider": { "index": 14, "kind": "parameter", "displayName": "Use Profile Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expec [...] + "lazyStartProducer": { "index": 15, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produ [...] + "bedrockRuntimeAsyncClient": { "index": 16, "kind": "parameter", "displayName": "Bedrock Runtime Async Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuratio [...] + "bedrockRuntimeClient": { "index": 17, "kind": "parameter", "displayName": "Bedrock Runtime Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description [...] + "proxyHost": { "index": 18, "kind": "parameter", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Bedrock client" }, + "proxyPort": { "index": 19, "kind": "parameter", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Bedrock client" }, + "proxyProtocol": { "index": 20, "kind": "parameter", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "To define a proxy [...] + "accessKey": { "index": 21, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" }, + "secretKey": { "index": 22, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, + "sessionToken": { "index": 23, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, + "trustAllCertificates": { "index": 24, "kind": "parameter", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overri [...] + "useSessionCredentials": { "index": 25, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration", "configurationField": "configuration", "description": "Set whether the Bedrock client should expect to use [...] } } diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConfiguration.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConfiguration.java index 64ce5884ac7d..6bf58080d726 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConfiguration.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConfiguration.java @@ -76,6 +76,12 @@ public class BedrockConfiguration implements Cloneable { private String streamOutputMode = "complete"; @UriParam(defaultValue = "true") private boolean includeStreamingMetadata = true; + @UriParam + private String guardrailIdentifier; + @UriParam(defaultValue = "DRAFT") + private String guardrailVersion = "DRAFT"; + @UriParam(defaultValue = "false") + private boolean guardrailTrace; public BedrockRuntimeClient getBedrockRuntimeClient() { return bedrockRuntimeClient; @@ -314,6 +320,39 @@ public class BedrockConfiguration implements Cloneable { this.includeStreamingMetadata = includeStreamingMetadata; } + public String getGuardrailIdentifier() { + return guardrailIdentifier; + } + + /** + * The identifier (ID or ARN) for the guardrail to apply to the model invocation + */ + public void setGuardrailIdentifier(String guardrailIdentifier) { + this.guardrailIdentifier = guardrailIdentifier; + } + + public String getGuardrailVersion() { + return guardrailVersion; + } + + /** + * The version of the guardrail to use. Defaults to DRAFT. + */ + public void setGuardrailVersion(String guardrailVersion) { + this.guardrailVersion = guardrailVersion; + } + + public boolean isGuardrailTrace() { + return guardrailTrace; + } + + /** + * Whether to return trace information from the guardrail + */ + public void setGuardrailTrace(boolean guardrailTrace) { + this.guardrailTrace = guardrailTrace; + } + // ************************************************* // // ************************************************* diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConstants.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConstants.java index 09929fe76515..9feeb736cc3d 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConstants.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConstants.java @@ -53,4 +53,18 @@ public interface BedrockConstants { String CONVERSE_USAGE = "CamelAwsBedrockConverseUsage"; @Metadata(description = "The output message from Converse API response", javaType = "Message") String CONVERSE_OUTPUT_MESSAGE = "CamelAwsBedrockConverseOutputMessage"; + @Metadata(description = "The guardrail configuration to apply to the request", javaType = "GuardrailConfiguration") + String GUARDRAIL_CONFIG = "CamelAwsBedrockGuardrailConfig"; + @Metadata(description = "The content blocks for ApplyGuardrail operation", javaType = "List<GuardrailContentBlock>") + String GUARDRAIL_CONTENT = "CamelAwsBedrockGuardrailContent"; + @Metadata(description = "The source type for ApplyGuardrail operation (INPUT or OUTPUT)", javaType = "String") + String GUARDRAIL_SOURCE = "CamelAwsBedrockGuardrailSource"; + @Metadata(description = "The guardrail assessment output from the response", javaType = "GuardrailAssessment") + String GUARDRAIL_OUTPUT = "CamelAwsBedrockGuardrailOutput"; + @Metadata(description = "The trace information from guardrail evaluation", javaType = "GuardrailTrace") + String GUARDRAIL_TRACE = "CamelAwsBedrockGuardrailTrace"; + @Metadata(description = "The guardrail assessments from ApplyGuardrail response", javaType = "List<GuardrailAssessment>") + String GUARDRAIL_ASSESSMENTS = "CamelAwsBedrockGuardrailAssessments"; + @Metadata(description = "The guardrail usage metrics from ApplyGuardrail response", javaType = "GuardrailUsage") + String GUARDRAIL_USAGE = "CamelAwsBedrockGuardrailUsage"; } diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockOperations.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockOperations.java index 079c82fd0497..36fd2a9cdfd9 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockOperations.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockOperations.java @@ -32,5 +32,7 @@ public enum BedrockOperations { converse, - converseStream + converseStream, + + applyGuardrail } diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockProducer.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockProducer.java index 001ed6bc0c4e..72d6725707f5 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockProducer.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockProducer.java @@ -86,6 +86,9 @@ public class BedrockProducer extends DefaultProducer { case converseStream: converseStream(exchange); break; + case applyGuardrail: + applyGuardrail(getEndpoint().getBedrockRuntimeClient(), exchange); + break; default: throw new IllegalArgumentException("Unsupported operation"); } @@ -578,6 +581,23 @@ public class BedrockProducer extends DefaultProducer { builder.additionalModelRequestFields(additionalFields); } + // Optional: Guardrail configuration + software.amazon.awssdk.services.bedrockruntime.model.GuardrailConfiguration guardrailConfig + = exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_CONFIG, + software.amazon.awssdk.services.bedrockruntime.model.GuardrailConfiguration.class); + if (guardrailConfig != null) { + builder.guardrailConfig(guardrailConfig); + } else if (ObjectHelper.isNotEmpty(getConfiguration().getGuardrailIdentifier())) { + // Build from endpoint configuration + builder.guardrailConfig(software.amazon.awssdk.services.bedrockruntime.model.GuardrailConfiguration.builder() + .guardrailIdentifier(getConfiguration().getGuardrailIdentifier()) + .guardrailVersion(getConfiguration().getGuardrailVersion()) + .trace(getConfiguration().isGuardrailTrace() + ? software.amazon.awssdk.services.bedrockruntime.model.GuardrailTrace.ENABLED + : software.amazon.awssdk.services.bedrockruntime.model.GuardrailTrace.DISABLED) + .build()); + } + request = builder.build(); } @@ -608,6 +628,9 @@ public class BedrockProducer extends DefaultProducer { if (response.usage() != null) { message.setHeader(BedrockConstants.CONVERSE_USAGE, response.usage()); } + if (response.trace() != null && response.trace().guardrail() != null) { + message.setHeader(BedrockConstants.GUARDRAIL_TRACE, response.trace().guardrail()); + } } catch (AwsServiceException ase) { LOG.trace("Converse command returned the error code {}", ase.awsErrorDetails().errorCode()); @@ -674,6 +697,24 @@ public class BedrockProducer extends DefaultProducer { builder.additionalModelRequestFields(additionalFields); } + // Optional: Guardrail configuration (use GuardrailStreamConfiguration for streaming) + software.amazon.awssdk.services.bedrockruntime.model.GuardrailStreamConfiguration guardrailConfig + = exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_CONFIG, + software.amazon.awssdk.services.bedrockruntime.model.GuardrailStreamConfiguration.class); + if (guardrailConfig != null) { + builder.guardrailConfig(guardrailConfig); + } else if (ObjectHelper.isNotEmpty(getConfiguration().getGuardrailIdentifier())) { + // Build from endpoint configuration + builder.guardrailConfig(software.amazon.awssdk.services.bedrockruntime.model.GuardrailStreamConfiguration + .builder() + .guardrailIdentifier(getConfiguration().getGuardrailIdentifier()) + .guardrailVersion(getConfiguration().getGuardrailVersion()) + .streamProcessingMode(getConfiguration().isGuardrailTrace() + ? software.amazon.awssdk.services.bedrockruntime.model.GuardrailStreamProcessingMode.ASYNC + : software.amazon.awssdk.services.bedrockruntime.model.GuardrailStreamProcessingMode.SYNC) + .build()); + } + request = builder.build(); } @@ -742,9 +783,90 @@ public class BedrockProducer extends DefaultProducer { if (metadata.getUsage() != null) { message.setHeader(BedrockConstants.CONVERSE_USAGE, metadata.getUsage()); } + if (metadata.getGuardrailTrace() != null) { + message.setHeader(BedrockConstants.GUARDRAIL_TRACE, metadata.getGuardrailTrace()); + } message.setHeader(BedrockConstants.STREAMING_CHUNK_COUNT, metadata.getChunkCount()); } + private void applyGuardrail(BedrockRuntimeClient bedrockRuntimeClient, Exchange exchange) throws InvalidPayloadException { + software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailRequest request; + + if (getConfiguration().isPojoRequest()) { + Object payload = exchange.getMessage().getMandatoryBody(); + if (payload instanceof software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailRequest) { + request = (software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailRequest) payload; + } else { + throw new IllegalArgumentException( + "ApplyGuardrail operation requires ApplyGuardrailRequest in POJO mode"); + } + } else { + // Build request from headers and configuration + software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailRequest.Builder builder + = software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailRequest.builder(); + + // Guardrail identifier from header or configuration + String guardrailIdentifier = exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_CONFIG, String.class); + if (ObjectHelper.isEmpty(guardrailIdentifier)) { + guardrailIdentifier = getConfiguration().getGuardrailIdentifier(); + } + if (ObjectHelper.isEmpty(guardrailIdentifier)) { + throw new IllegalArgumentException( + "ApplyGuardrail operation requires guardrailIdentifier in configuration or header"); + } + builder.guardrailIdentifier(guardrailIdentifier); + + // Guardrail version from configuration + builder.guardrailVersion(getConfiguration().getGuardrailVersion()); + + // Source (INPUT or OUTPUT) + String source = exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_SOURCE, String.class); + if (ObjectHelper.isEmpty(source)) { + source = "INPUT"; // Default to INPUT + } + builder.source(software.amazon.awssdk.services.bedrockruntime.model.GuardrailContentSource.fromValue(source)); + + // Content blocks from header + @SuppressWarnings("unchecked") + List<software.amazon.awssdk.services.bedrockruntime.model.GuardrailContentBlock> content + = exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_CONTENT, List.class); + if (content != null && !content.isEmpty()) { + builder.content(content); + } else { + throw new IllegalArgumentException( + "ApplyGuardrail operation requires content in header " + BedrockConstants.GUARDRAIL_CONTENT); + } + + request = builder.build(); + } + + try { + software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailResponse response + = bedrockRuntimeClient.applyGuardrail(request); + + org.apache.camel.Message message = getMessageForResponse(exchange); + + // Set action as body + message.setBody(response.action().toString()); + + // Set output content and assessments as headers + if (response.hasOutputs()) { + message.setHeader(BedrockConstants.GUARDRAIL_OUTPUT, response.outputs()); + } + if (response.hasAssessments()) { + // Store assessments as a header for detailed analysis + message.setHeader(BedrockConstants.GUARDRAIL_ASSESSMENTS, response.assessments()); + } + if (response.usage() != null) { + message.setHeader(BedrockConstants.GUARDRAIL_USAGE, response.usage()); + } + + } catch (AwsServiceException ase) { + LOG.trace("ApplyGuardrail command returned the error code {}", ase.awsErrorDetails().errorCode()); + throw ase; + } + } + public static Message getMessageForResponse(final Exchange exchange) { return exchange.getMessage(); } diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/stream/ConverseStreamHandler.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/stream/ConverseStreamHandler.java index 1b242d5481a5..c554f5030844 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/stream/ConverseStreamHandler.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/stream/ConverseStreamHandler.java @@ -128,6 +128,7 @@ public final class ConverseStreamHandler { private String stopReason; private TokenUsage usage; private int chunkCount; + private software.amazon.awssdk.services.bedrockruntime.model.GuardrailTrace guardrailTrace; public String getFullText() { return fullText; @@ -168,5 +169,13 @@ public final class ConverseStreamHandler { public void setChunkCount(int chunkCount) { this.chunkCount = chunkCount; } + + public software.amazon.awssdk.services.bedrockruntime.model.GuardrailTrace getGuardrailTrace() { + return guardrailTrace; + } + + public void setGuardrailTrace(software.amazon.awssdk.services.bedrockruntime.model.GuardrailTrace guardrailTrace) { + this.guardrailTrace = guardrailTrace; + } } } diff --git a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/runtime/integration/BedrockGuardrailsIT.java b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/runtime/integration/BedrockGuardrailsIT.java new file mode 100644 index 000000000000..9297bf393e31 --- /dev/null +++ b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/runtime/integration/BedrockGuardrailsIT.java @@ -0,0 +1,278 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.aws2.bedrock.runtime.integration; + +import org.apache.camel.EndpointInject; +import org.apache.camel.Exchange; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.aws2.bedrock.BedrockModels; +import org.apache.camel.component.aws2.bedrock.runtime.BedrockConstants; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.condition.EnabledIfSystemProperties; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Integration tests for AWS Bedrock Guardrails functionality. Requires a configured guardrail in your AWS account. Must + * be manually tested. Provide your own accessKey, secretKey and guardrail ID using: -Daws.manual.access.key + * -Daws.manual.secret.key -Daws.manual.guardrail.id + */ +@EnabledIfSystemProperties({ + @EnabledIfSystemProperty(named = "aws.manual.access.key", matches = ".*", disabledReason = "Access key not provided"), + @EnabledIfSystemProperty(named = "aws.manual.secret.key", matches = ".*", disabledReason = "Secret key not provided"), + @EnabledIfSystemProperty(named = "aws.manual.guardrail.id", matches = ".*", + disabledReason = "Guardrail ID not provided") +}) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +class BedrockGuardrailsIT extends CamelTestSupport { + + @EndpointInject + private ProducerTemplate template; + + @EndpointInject("mock:result") + private MockEndpoint result; + + @BeforeEach + public void resetMocks() { + result.reset(); + } + + @Test + public void testConverseWithGuardrailsViaEndpointConfig() throws InterruptedException { + result.expectedMessageCount(1); + final Exchange exchange = template.send("direct:converse_with_guardrails_endpoint", ex -> { + // Create a message using the Converse API + java.util.List<software.amazon.awssdk.services.bedrockruntime.model.Message> messages = new java.util.ArrayList<>(); + messages.add(software.amazon.awssdk.services.bedrockruntime.model.Message.builder() + .role(software.amazon.awssdk.services.bedrockruntime.model.ConversationRole.USER) + .content(software.amazon.awssdk.services.bedrockruntime.model.ContentBlock + .fromText("Tell me about Paris")) + .build()); + + ex.getMessage().setHeader(BedrockConstants.CONVERSE_MESSAGES, messages); + + // Optional: Add inference configuration + software.amazon.awssdk.services.bedrockruntime.model.InferenceConfiguration inferenceConfig + = software.amazon.awssdk.services.bedrockruntime.model.InferenceConfiguration.builder() + .maxTokens(200) + .temperature(0.7f) + .build(); + ex.getMessage().setHeader(BedrockConstants.CONVERSE_INFERENCE_CONFIG, inferenceConfig); + }); + + // Verify that the response contains content + assertNotNull(exchange.getMessage().getBody(String.class)); + assertTrue(exchange.getMessage().getBody(String.class).length() > 0); + + // Check if guardrail trace is present (if trace is enabled) + if (exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_TRACE) != null) { + assertNotNull(exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_TRACE)); + } + + MockEndpoint.assertIsSatisfied(context); + } + + @Test + public void testConverseWithGuardrailsViaHeader() throws InterruptedException { + result.expectedMessageCount(1); + final Exchange exchange = template.send("direct:converse_claude", ex -> { + // Create a message using the Converse API + java.util.List<software.amazon.awssdk.services.bedrockruntime.model.Message> messages = new java.util.ArrayList<>(); + messages.add(software.amazon.awssdk.services.bedrockruntime.model.Message.builder() + .role(software.amazon.awssdk.services.bedrockruntime.model.ConversationRole.USER) + .content(software.amazon.awssdk.services.bedrockruntime.model.ContentBlock + .fromText("What is the capital of France?")) + .build()); + + ex.getMessage().setHeader(BedrockConstants.CONVERSE_MESSAGES, messages); + + // Configure guardrail via header + String guardrailId = System.getProperty("aws.manual.guardrail.id"); + software.amazon.awssdk.services.bedrockruntime.model.GuardrailConfiguration guardrailConfig + = software.amazon.awssdk.services.bedrockruntime.model.GuardrailConfiguration.builder() + .guardrailIdentifier(guardrailId) + .guardrailVersion("DRAFT") + .trace(software.amazon.awssdk.services.bedrockruntime.model.GuardrailTrace.ENABLED) + .build(); + ex.getMessage().setHeader(BedrockConstants.GUARDRAIL_CONFIG, guardrailConfig); + + // Optional: Add inference configuration + software.amazon.awssdk.services.bedrockruntime.model.InferenceConfiguration inferenceConfig + = software.amazon.awssdk.services.bedrockruntime.model.InferenceConfiguration.builder() + .maxTokens(100) + .temperature(0.7f) + .build(); + ex.getMessage().setHeader(BedrockConstants.CONVERSE_INFERENCE_CONFIG, inferenceConfig); + }); + + // Verify that the response contains content + assertNotNull(exchange.getMessage().getBody(String.class)); + assertTrue(exchange.getMessage().getBody(String.class).length() > 0); + + // Guardrail trace should be present when enabled + if (exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_TRACE) != null) { + assertNotNull(exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_TRACE)); + } + + MockEndpoint.assertIsSatisfied(context); + } + + @Test + public void testConverseStreamWithGuardrails() throws InterruptedException { + result.expectedMessageCount(1); + final Exchange exchange = template.send("direct:converse_stream_with_guardrails", ex -> { + // Create a message using the Converse API + java.util.List<software.amazon.awssdk.services.bedrockruntime.model.Message> messages = new java.util.ArrayList<>(); + messages.add(software.amazon.awssdk.services.bedrockruntime.model.Message.builder() + .role(software.amazon.awssdk.services.bedrockruntime.model.ConversationRole.USER) + .content(software.amazon.awssdk.services.bedrockruntime.model.ContentBlock + .fromText("Tell me a short story about a robot")) + .build()); + + ex.getMessage().setHeader(BedrockConstants.CONVERSE_MESSAGES, messages); + ex.getMessage().setHeader(BedrockConstants.STREAM_OUTPUT_MODE, "complete"); + + // Optional: Add inference configuration + software.amazon.awssdk.services.bedrockruntime.model.InferenceConfiguration inferenceConfig + = software.amazon.awssdk.services.bedrockruntime.model.InferenceConfiguration.builder() + .maxTokens(300) + .temperature(0.9f) + .build(); + ex.getMessage().setHeader(BedrockConstants.CONVERSE_INFERENCE_CONFIG, inferenceConfig); + }); + + // Verify that the streaming response contains content + assertNotNull(exchange.getMessage().getBody(String.class)); + assertTrue(exchange.getMessage().getBody(String.class).length() > 0); + + MockEndpoint.assertIsSatisfied(context); + } + + @Test + public void testApplyGuardrail() throws InterruptedException { + result.expectedMessageCount(1); + final Exchange exchange = template.send("direct:apply_guardrail", ex -> { + // Create content blocks to check against the guardrail + java.util.List<software.amazon.awssdk.services.bedrockruntime.model.GuardrailContentBlock> content + = new java.util.ArrayList<>(); + content.add(software.amazon.awssdk.services.bedrockruntime.model.GuardrailContentBlock.builder() + .text(software.amazon.awssdk.services.bedrockruntime.model.GuardrailTextBlock.builder() + .text("This is a test message to check against the guardrail.") + .build()) + .build()); + + ex.getMessage().setHeader(BedrockConstants.GUARDRAIL_CONTENT, content); + ex.getMessage().setHeader(BedrockConstants.GUARDRAIL_SOURCE, "INPUT"); + }); + + // Verify that the response contains an action (GUARDRAIL_INTERVENED or NONE) + String action = exchange.getMessage().getBody(String.class); + assertNotNull(action); + assertTrue(action.equals("GUARDRAIL_INTERVENED") || action.equals("NONE")); + + // Verify that output headers are present + if (action.equals("GUARDRAIL_INTERVENED")) { + // When intervened, there should be outputs + assertNotNull(exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_OUTPUT)); + } + + MockEndpoint.assertIsSatisfied(context); + } + + @Test + public void testApplyGuardrailWithPOJO() throws InterruptedException { + result.expectedMessageCount(1); + final Exchange exchange = template.send("direct:apply_guardrail_pojo", ex -> { + // Create content blocks + java.util.List<software.amazon.awssdk.services.bedrockruntime.model.GuardrailContentBlock> content + = new java.util.ArrayList<>(); + content.add(software.amazon.awssdk.services.bedrockruntime.model.GuardrailContentBlock.builder() + .text(software.amazon.awssdk.services.bedrockruntime.model.GuardrailTextBlock.builder() + .text("Another test message for guardrail validation.") + .build()) + .build()); + + // Build the full ApplyGuardrailRequest + String guardrailId = System.getProperty("aws.manual.guardrail.id"); + software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailRequest request + = software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailRequest.builder() + .guardrailIdentifier(guardrailId) + .guardrailVersion("DRAFT") + .source(software.amazon.awssdk.services.bedrockruntime.model.GuardrailContentSource.INPUT) + .content(content) + .build(); + + ex.getMessage().setBody(request); + }); + + // Verify that the response contains an action + String action = exchange.getMessage().getBody(String.class); + assertNotNull(action); + assertTrue(action.equals("GUARDRAIL_INTERVENED") || action.equals("NONE")); + + MockEndpoint.assertIsSatisfied(context); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + String guardrailId = System.getProperty("aws.manual.guardrail.id"); + + from("direct:converse_with_guardrails_endpoint") + .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}})®ion=us-east-1&operation=converse&modelId=" + + BedrockModels.ANTROPHIC_CLAUDE_V3.model + "&guardrailIdentifier=RAW(" + guardrailId + + ")&guardrailVersion=DRAFT&guardrailTrace=true") + .log("Converse with guardrails response: ${body}") + .to(result); + + from("direct:converse_claude") + .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}})®ion=us-east-1&operation=converse&modelId=" + + BedrockModels.ANTROPHIC_CLAUDE_V3.model) + .log("Converse response: ${body}") + .to(result); + + from("direct:converse_stream_with_guardrails") + .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}})®ion=us-east-1&operation=converseStream&modelId=" + + BedrockModels.ANTROPHIC_CLAUDE_V3.model + "&guardrailIdentifier=RAW(" + guardrailId + + ")&guardrailVersion=DRAFT") + .log("Converse stream with guardrails response: ${body}") + .to(result); + + from("direct:apply_guardrail") + .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}})®ion=us-east-1&operation=applyGuardrail&guardrailIdentifier=RAW(" + + guardrailId + ")&guardrailVersion=DRAFT") + .log("ApplyGuardrail action: ${body}") + .log("Guardrail output: ${header." + BedrockConstants.GUARDRAIL_OUTPUT + "}") + .to(result); + + from("direct:apply_guardrail_pojo") + .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}})®ion=us-east-1&operation=applyGuardrail&pojoRequest=true") + .log("ApplyGuardrail POJO action: ${body}") + .to(result); + } + }; + } +}
