Class BedrockStreamHandler

java.lang.Object
org.apache.camel.component.aws2.bedrock.runtime.stream.BedrockStreamHandler

public final class BedrockStreamHandler extends Object
Utility class for handling streaming responses from Bedrock models
  • Method Details

    • createCompleteHandler

      public static software.amazon.awssdk.services.bedrockruntime.model.InvokeModelWithResponseStreamResponseHandler createCompleteHandler(String modelId, BedrockStreamHandler.StreamMetadata metadata, StringBuilder fullText)
      Create a response handler for complete mode (accumulates all chunks)
      Parameters:
      modelId - the model ID to determine parser
      metadata - the metadata object to populate
      fullText - the string builder to accumulate text
      Returns:
      the response handler
    • createChunksHandler

      public static software.amazon.awssdk.services.bedrockruntime.model.InvokeModelWithResponseStreamResponseHandler createChunksHandler(String modelId, BedrockStreamHandler.StreamMetadata metadata, List<String> chunks, Consumer<String> chunkConsumer)
      Create a response handler for chunks mode (emits each chunk)
      Parameters:
      modelId - the model ID to determine parser
      metadata - the metadata object to populate
      chunks - the list to collect chunks
      chunkConsumer - consumer that receives each chunk
      Returns:
      the response handler