Class: PromptBuilder::Serializers::Converse::Request

Inherits:
Base
  • Object
show all
Defined in:
lib/prompt_builder/serializers/converse/request.rb

Overview

Request serializer for the Amazon Bedrock Converse API format.

Unsupported Open Responses features

These session fields are not supported and are silently omitted from the serialized output:

  • background — background/async mode is not supported on the Converse endpoint

  • frequency_penalty — not supported by the Converse API

  • include — response-field inclusion is an Open Responses-only concept

  • max_tool_calls — per-request tool-call caps are not supported

  • parallel_tool_calls — parallel tool call control is not supported

  • presence_penalty — not supported by the Converse API

  • prompt_cache_key / prompt_cache_retention — explicit prompt cache keys are not supported

  • reasoning — extended thinking is not supported on the Converse endpoint

  • safety_identifier — no equivalent user-safety field on the Converse endpoint

  • store — server-side response storage is not supported

  • stream — SSE streaming is handled outside the Converse request payload

  • stream_options — stream event options are not supported

  • top_logprobs — log probability output is not supported

  • truncation — server-side context truncation is not supported

Partially supported session fields (unsupported keys/values are omitted):

  • metadata — only scalar values are forwarded to requestMetadata; Hash/Array values are omitted

  • text — only format.type == “json_schema” is supported

Tool choice restrictions:

  • tool_choice: “none” has no Converse representation and is omitted

Input content restrictions:

  • Reasoning items are silently skipped

  • RefusalContent is dropped silently (a parsed response refusal can stay in session history without breaking subsequent request_payload calls)

  • OutputText.annotations and OutputText.logprobs are dropped silently

  • InputImage content is only supported in user messages (assistant images are omitted)

  • InputImage.detail and InputImage.file_id are silently ignored

  • InputFile content is only supported in user messages (assistant files are omitted)

  • InputFile.file_id is silently ignored

  • InputVideo content is only supported in user messages (assistant videos are omitted)

  • InputImage requires base64 data or an S3 URI (s3://...); content with a public URL is omitted

  • InputFile requires base64 file_data or an S3 URI; format is detected from the filename or file_url extension

  • InputVideo requires an S3 URI (s3://...); a non-S3 URL is omitted

  • Tool (FunctionCallOutput) results support text, image, document, and video content; other content is omitted

Features in Converse not available through Open Responses

The following Converse parameters cannot be set through the Open Responses canonical format:

  • stopSequences — custom stop sequences

  • Guardrail policies (guardrailConfig)

  • Per-model passthrough fields (additionalModelRequestFields)

  • Requested provider response fields (additionalModelResponseFieldPaths)

  • Cross-region routing via inference profiles

  • performanceConfig latency settings beyond serviceTier

  • Prompt management variables (promptVariables)

  • Prompt caching markers (cachePoint)

Constant Summary collapse

IMAGE_MEDIA_TYPE_FORMATS =
{
  "image/jpeg" => "jpeg",
  "image/jpg" => "jpeg",
  "image/png" => "png",
  "image/gif" => "gif",
  "image/webp" => "webp"
}.freeze
IMAGE_URL_EXTENSION_FORMATS =
{
  "jpg" => "jpeg",
  "jpeg" => "jpeg",
  "png" => "png",
  "gif" => "gif",
  "webp" => "webp"
}.freeze
DOCUMENT_FILENAME_EXTENSION_FORMATS =
{
  "pdf" => "pdf",
  "csv" => "csv",
  "doc" => "doc",
  "docx" => "docx",
  "xls" => "xls",
  "xlsx" => "xlsx",
  "html" => "html",
  "htm" => "html",
  "txt" => "txt",
  "md" => "md",
  "markdown" => "md"
}.freeze
VIDEO_URL_EXTENSION_FORMATS =
{
  "mkv" => "mkv",
  "mov" => "mov",
  "mp4" => "mp4",
  "webm" => "webm",
  "flv" => "flv",
  "mpeg" => "mpeg",
  "mpg" => "mpeg",
  "wmv" => "wmv",
  "3gp" => "three_gp"
}.freeze

Method Summary

Methods inherited from Base

parse_response, request_payload