This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 9ff2e15c3c8 CAMEL-20644 - Camel-AWS-Bedrock-Agent-Runtime: Support usage of sessionId to continue the same session with the knowledge base (#13695) 9ff2e15c3c8 is described below commit 9ff2e15c3c8e9fcec1289a59c56de63ecef24eb9 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Apr 4 10:50:34 2024 +0200 CAMEL-20644 - Camel-AWS-Bedrock-Agent-Runtime: Support usage of sessionId to continue the same session with the knowledge base (#13695) Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- .../bedrock/agentruntime/BedrockAgentRuntimeProducer.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducer.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducer.java index 00ef3fd2af2..10b1796aad5 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducer.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducer.java @@ -117,8 +117,16 @@ public class BedrockAgentRuntimeProducer extends DefaultProducer { RetrieveAndGenerateInput input = RetrieveAndGenerateInput.builder() .text(inputText).build(); - RetrieveAndGenerateResponse retrieveAndGenerateResponse = bedrockAgentRuntimeClient.retrieveAndGenerate( - RetrieveAndGenerateRequest.builder().retrieveAndGenerateConfiguration(build).input(input).build()); + RetrieveAndGenerateRequest.Builder request = RetrieveAndGenerateRequest.builder(); + + request.retrieveAndGenerateConfiguration(build).input(input); + + if (ObjectHelper.isNotEmpty(exchange.getMessage().getHeader(BedrockAgentRuntimeConstants.SESSION_ID))) { + request.sessionId(exchange.getMessage().getHeader(BedrockAgentRuntimeConstants.SESSION_ID, String.class)); + } + + RetrieveAndGenerateResponse retrieveAndGenerateResponse + = bedrockAgentRuntimeClient.retrieveAndGenerate(request.build()); Message message = getMessageForResponse(exchange); prepareResponse(retrieveAndGenerateResponse, message);