ReqLLM.Providers.AmazonBedrock.Response (ReqLLM v1.0.0)

View Source

Shared utilities for unwrapping AWS Bedrock response formats.

Bedrock wraps provider responses in AWS-specific formats (base64 encoding, event streams). This module handles the Bedrock-specific unwrapping so provider modules can work with native provider formats.

Summary

Functions

Unwraps a Bedrock streaming chunk into the underlying provider event format.

Types

t()

@type t() :: %ReqLLM.Providers.AmazonBedrock.Response{payload: term()}

Functions

unwrap_stream_chunk(chunk)

@spec unwrap_stream_chunk(map()) :: {:ok, map()} | {:error, term()}

Unwraps a Bedrock streaming chunk into the underlying provider event format.

Bedrock can wrap events in several formats:

  • %{"chunk" => %{"bytes" => base64}} - AWS SDK format (Anthropic)
  • %{"bytes" => base64} - Direct bytes format
  • %{"type" => ...} - Anthropic JSON event (already decoded)
  • %{"object" => ...} - OpenAI JSON event (already decoded)
  • %{"generation" => ...} - Meta Llama JSON event (already decoded)

Returns the unwrapped event as a map, or an error tuple.