Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ The component supports the following operations on the `operation` URI option:
* `retrieveAndGenerate` — Query a Bedrock Knowledge Base and generate a grounded response from the selected model.
* `retrieve` — Run a semantic search against a Bedrock Knowledge Base and return the matched chunks without LLM generation.
* `invokeFlow` — Invoke a Bedrock Flow by id/alias and stream the resulting events back as Camel message headers.
* `invokeAgent` — Invoke a deployed Bedrock Agent by id/alias and stream the response back.
* `invokeInlineAgent` — Invoke an agent defined inline at invocation time (foundation model plus instruction).

=== Retrieving from a Bedrock Knowledge Base

Expand Down Expand Up @@ -118,6 +120,64 @@ The producer collects emitted events into headers:
The out-message body is the document of the last `FlowOutputEvent` (decoded as `String` when the document is a string,
otherwise the raw `Document`). When the flow emits no outputs, the body is left untouched.

=== Invoking a Bedrock Agent

The `invokeAgent` operation invokes a deployed Bedrock Agent. Like `invokeFlow` it uses the AWS SDK async client, and
the producer transparently allocates a `BedrockAgentRuntimeAsyncClient` when the endpoint is configured with
`operation=invokeAgent`.

Mandatory options:

* `agentId` — the unique id of the agent to invoke (overridable via the `CamelAwsBedrockAgentRuntimeAgentId` header).
* `agentAliasId` — the unique id of the agent alias (overridable via the
`CamelAwsBedrockAgentRuntimeAgentAliasId` header).

The in-message body is the input text sent to the agent. When `pojoRequest=true`, the body must be an
`InvokeAgentRequest` and is sent unchanged.

The agent APIs are session based. Set `sessionId` on the endpoint, or the `CamelAwsBedrockAgentRuntimeSessionId`
header, to continue an existing conversation; when neither is supplied a random session id is generated for the
invocation. The session id used is always echoed back on the `CamelAwsBedrockAgentRuntimeSessionId` header of the
out-message so a route can reuse it on the next call.

[source,java]
----
from("direct:agent")
.to("aws-bedrock-agent-runtime://label?operation=invokeAgent&agentId=RAWAGENTID&agentAliasId=RAWALIASID");
----

=== Invoking an inline Bedrock Agent

The `invokeInlineAgent` operation defines the agent at invocation time instead of referencing a deployed one.

Mandatory options:

* `foundationModel` — the model backing the agent (overridable via the
`CamelAwsBedrockAgentRuntimeAgentFoundationModel` header).
* `instruction` — the instruction given to the agent (overridable via the
`CamelAwsBedrockAgentRuntimeAgentInstruction` header).

For the richer inline options (action groups, knowledge bases, collaborators, guardrails), set `pojoRequest=true` and
send an `InvokeInlineAgentRequest` body, which is passed to AWS unchanged.

=== Agent response and streaming output

Both agent operations stream their response. The producer collects the emitted events into headers:

* `CamelAwsBedrockAgentRuntimeAgentTraces` — the trace events (only when tracing is enabled via `enableTrace` or the
`CamelAwsBedrockAgentRuntimeAgentEnableTrace` header).
* `CamelAwsBedrockAgentRuntimeAgentReturnControl` — the return-control payloads, emitted when the agent asks the
caller to fulfil an action.
* `CamelAwsBedrockAgentRuntimeAgentFiles` — the files emitted by the agent.
* `CamelAwsBedrockAgentRuntimeCitations` — the citations attributed to the response chunks.

The out-message body depends on `streamOutputMode`:

* `complete` (the default) — the response chunks are accumulated and the body is the full text as a `String`.
* `chunks` — the body is the `List<String>` of individual chunks.

The mode can be overridden per exchange with the `CamelAwsBedrockAgentRuntimeAgentStreamOutputMode` header.

=== Static credentials, Default Credential Provider and Profile Credentials Provider

You have the possibility of avoiding the usage of explicit static credentials by specifying the useDefaultCredentialsProvider option and set it to true.
Expand Down
5 changes: 5 additions & 0 deletions components/camel-aws/camel-aws-bedrock/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,10 @@
<version>${mockito-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
switch (ignoreCase ? name.toLowerCase() : name) {
case "accesskey":
case "accessKey": getOrCreateConfiguration(target).setAccessKey(property(camelContext, java.lang.String.class, value)); return true;
case "agentaliasid":
case "agentAliasId": getOrCreateConfiguration(target).setAgentAliasId(property(camelContext, java.lang.String.class, value)); return true;
case "agentid":
case "agentId": getOrCreateConfiguration(target).setAgentId(property(camelContext, java.lang.String.class, value)); return true;
case "autowiredenabled":
case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
case "bedrockagentruntimeasyncclient":
Expand All @@ -45,10 +49,13 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "flowAliasIdentifier": getOrCreateConfiguration(target).setFlowAliasIdentifier(property(camelContext, java.lang.String.class, value)); return true;
case "flowidentifier":
case "flowIdentifier": getOrCreateConfiguration(target).setFlowIdentifier(property(camelContext, java.lang.String.class, value)); return true;
case "foundationmodel":
case "foundationModel": getOrCreateConfiguration(target).setFoundationModel(property(camelContext, java.lang.String.class, value)); return true;
case "healthcheckconsumerenabled":
case "healthCheckConsumerEnabled": target.setHealthCheckConsumerEnabled(property(camelContext, boolean.class, value)); return true;
case "healthcheckproducerenabled":
case "healthCheckProducerEnabled": target.setHealthCheckProducerEnabled(property(camelContext, boolean.class, value)); return true;
case "instruction": getOrCreateConfiguration(target).setInstruction(property(camelContext, java.lang.String.class, value)); return true;
case "knowledgebaseid":
case "knowledgeBaseId": getOrCreateConfiguration(target).setKnowledgeBaseId(property(camelContext, java.lang.String.class, value)); return true;
case "lazystartproducer":
Expand All @@ -71,8 +78,12 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "region": getOrCreateConfiguration(target).setRegion(property(camelContext, java.lang.String.class, value)); return true;
case "secretkey":
case "secretKey": getOrCreateConfiguration(target).setSecretKey(property(camelContext, java.lang.String.class, value)); return true;
case "sessionid":
case "sessionId": getOrCreateConfiguration(target).setSessionId(property(camelContext, java.lang.String.class, value)); return true;
case "sessiontoken":
case "sessionToken": getOrCreateConfiguration(target).setSessionToken(property(camelContext, java.lang.String.class, value)); return true;
case "streamoutputmode":
case "streamOutputMode": getOrCreateConfiguration(target).setStreamOutputMode(property(camelContext, java.lang.String.class, value)); return true;
case "trustallcertificates":
case "trustAllCertificates": getOrCreateConfiguration(target).setTrustAllCertificates(property(camelContext, boolean.class, value)); return true;
case "uriendpointoverride":
Expand All @@ -97,6 +108,10 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
case "accesskey":
case "accessKey": return java.lang.String.class;
case "agentaliasid":
case "agentAliasId": return java.lang.String.class;
case "agentid":
case "agentId": return java.lang.String.class;
case "autowiredenabled":
case "autowiredEnabled": return boolean.class;
case "bedrockagentruntimeasyncclient":
Expand All @@ -110,10 +125,13 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "flowAliasIdentifier": return java.lang.String.class;
case "flowidentifier":
case "flowIdentifier": return java.lang.String.class;
case "foundationmodel":
case "foundationModel": return java.lang.String.class;
case "healthcheckconsumerenabled":
case "healthCheckConsumerEnabled": return boolean.class;
case "healthcheckproducerenabled":
case "healthCheckProducerEnabled": return boolean.class;
case "instruction": return java.lang.String.class;
case "knowledgebaseid":
case "knowledgeBaseId": return java.lang.String.class;
case "lazystartproducer":
Expand All @@ -136,8 +154,12 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "region": return java.lang.String.class;
case "secretkey":
case "secretKey": return java.lang.String.class;
case "sessionid":
case "sessionId": return java.lang.String.class;
case "sessiontoken":
case "sessionToken": return java.lang.String.class;
case "streamoutputmode":
case "streamOutputMode": return java.lang.String.class;
case "trustallcertificates":
case "trustAllCertificates": return boolean.class;
case "uriendpointoverride":
Expand All @@ -158,6 +180,10 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
case "accesskey":
case "accessKey": return getOrCreateConfiguration(target).getAccessKey();
case "agentaliasid":
case "agentAliasId": return getOrCreateConfiguration(target).getAgentAliasId();
case "agentid":
case "agentId": return getOrCreateConfiguration(target).getAgentId();
case "autowiredenabled":
case "autowiredEnabled": return target.isAutowiredEnabled();
case "bedrockagentruntimeasyncclient":
Expand All @@ -171,10 +197,13 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
case "flowAliasIdentifier": return getOrCreateConfiguration(target).getFlowAliasIdentifier();
case "flowidentifier":
case "flowIdentifier": return getOrCreateConfiguration(target).getFlowIdentifier();
case "foundationmodel":
case "foundationModel": return getOrCreateConfiguration(target).getFoundationModel();
case "healthcheckconsumerenabled":
case "healthCheckConsumerEnabled": return target.isHealthCheckConsumerEnabled();
case "healthcheckproducerenabled":
case "healthCheckProducerEnabled": return target.isHealthCheckProducerEnabled();
case "instruction": return getOrCreateConfiguration(target).getInstruction();
case "knowledgebaseid":
case "knowledgeBaseId": return getOrCreateConfiguration(target).getKnowledgeBaseId();
case "lazystartproducer":
Expand All @@ -197,8 +226,12 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
case "region": return getOrCreateConfiguration(target).getRegion();
case "secretkey":
case "secretKey": return getOrCreateConfiguration(target).getSecretKey();
case "sessionid":
case "sessionId": return getOrCreateConfiguration(target).getSessionId();
case "sessiontoken":
case "sessionToken": return getOrCreateConfiguration(target).getSessionToken();
case "streamoutputmode":
case "streamOutputMode": return getOrCreateConfiguration(target).getStreamOutputMode();
case "trustallcertificates":
case "trustAllCertificates": return getOrCreateConfiguration(target).isTrustAllCertificates();
case "uriendpointoverride":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
switch (ignoreCase ? name.toLowerCase() : name) {
case "accesskey":
case "accessKey": target.getConfiguration().setAccessKey(property(camelContext, java.lang.String.class, value)); return true;
case "agentaliasid":
case "agentAliasId": target.getConfiguration().setAgentAliasId(property(camelContext, java.lang.String.class, value)); return true;
case "agentid":
case "agentId": target.getConfiguration().setAgentId(property(camelContext, java.lang.String.class, value)); return true;
case "bedrockagentruntimeasyncclient":
case "bedrockAgentRuntimeAsyncClient": target.getConfiguration().setBedrockAgentRuntimeAsyncClient(property(camelContext, software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeAsyncClient.class, value)); return true;
case "bedrockagentruntimeclient":
Expand All @@ -35,6 +39,9 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "flowAliasIdentifier": target.getConfiguration().setFlowAliasIdentifier(property(camelContext, java.lang.String.class, value)); return true;
case "flowidentifier":
case "flowIdentifier": target.getConfiguration().setFlowIdentifier(property(camelContext, java.lang.String.class, value)); return true;
case "foundationmodel":
case "foundationModel": target.getConfiguration().setFoundationModel(property(camelContext, java.lang.String.class, value)); return true;
case "instruction": target.getConfiguration().setInstruction(property(camelContext, java.lang.String.class, value)); return true;
case "knowledgebaseid":
case "knowledgeBaseId": target.getConfiguration().setKnowledgeBaseId(property(camelContext, java.lang.String.class, value)); return true;
case "lazystartproducer":
Expand All @@ -57,8 +64,12 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "region": target.getConfiguration().setRegion(property(camelContext, java.lang.String.class, value)); return true;
case "secretkey":
case "secretKey": target.getConfiguration().setSecretKey(property(camelContext, java.lang.String.class, value)); return true;
case "sessionid":
case "sessionId": target.getConfiguration().setSessionId(property(camelContext, java.lang.String.class, value)); return true;
case "sessiontoken":
case "sessionToken": target.getConfiguration().setSessionToken(property(camelContext, java.lang.String.class, value)); return true;
case "streamoutputmode":
case "streamOutputMode": target.getConfiguration().setStreamOutputMode(property(camelContext, java.lang.String.class, value)); return true;
case "trustallcertificates":
case "trustAllCertificates": target.getConfiguration().setTrustAllCertificates(property(camelContext, boolean.class, value)); return true;
case "uriendpointoverride":
Expand All @@ -83,6 +94,10 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
case "accesskey":
case "accessKey": return java.lang.String.class;
case "agentaliasid":
case "agentAliasId": return java.lang.String.class;
case "agentid":
case "agentId": return java.lang.String.class;
case "bedrockagentruntimeasyncclient":
case "bedrockAgentRuntimeAsyncClient": return software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeAsyncClient.class;
case "bedrockagentruntimeclient":
Expand All @@ -93,6 +108,9 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "flowAliasIdentifier": return java.lang.String.class;
case "flowidentifier":
case "flowIdentifier": return java.lang.String.class;
case "foundationmodel":
case "foundationModel": return java.lang.String.class;
case "instruction": return java.lang.String.class;
case "knowledgebaseid":
case "knowledgeBaseId": return java.lang.String.class;
case "lazystartproducer":
Expand All @@ -115,8 +133,12 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "region": return java.lang.String.class;
case "secretkey":
case "secretKey": return java.lang.String.class;
case "sessionid":
case "sessionId": return java.lang.String.class;
case "sessiontoken":
case "sessionToken": return java.lang.String.class;
case "streamoutputmode":
case "streamOutputMode": return java.lang.String.class;
case "trustallcertificates":
case "trustAllCertificates": return boolean.class;
case "uriendpointoverride":
Expand All @@ -137,6 +159,10 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
case "accesskey":
case "accessKey": return target.getConfiguration().getAccessKey();
case "agentaliasid":
case "agentAliasId": return target.getConfiguration().getAgentAliasId();
case "agentid":
case "agentId": return target.getConfiguration().getAgentId();
case "bedrockagentruntimeasyncclient":
case "bedrockAgentRuntimeAsyncClient": return target.getConfiguration().getBedrockAgentRuntimeAsyncClient();
case "bedrockagentruntimeclient":
Expand All @@ -147,6 +173,9 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
case "flowAliasIdentifier": return target.getConfiguration().getFlowAliasIdentifier();
case "flowidentifier":
case "flowIdentifier": return target.getConfiguration().getFlowIdentifier();
case "foundationmodel":
case "foundationModel": return target.getConfiguration().getFoundationModel();
case "instruction": return target.getConfiguration().getInstruction();
case "knowledgebaseid":
case "knowledgeBaseId": return target.getConfiguration().getKnowledgeBaseId();
case "lazystartproducer":
Expand All @@ -169,8 +198,12 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
case "region": return target.getConfiguration().getRegion();
case "secretkey":
case "secretKey": return target.getConfiguration().getSecretKey();
case "sessionid":
case "sessionId": return target.getConfiguration().getSessionId();
case "sessiontoken":
case "sessionToken": return target.getConfiguration().getSessionToken();
case "streamoutputmode":
case "streamOutputMode": return target.getConfiguration().getStreamOutputMode();
case "trustallcertificates":
case "trustAllCertificates": return target.getConfiguration().isTrustAllCertificates();
case "uriendpointoverride":
Expand Down
Loading