Module: LLM::Bedrock::ResponseAdapter Private

Defined in:
lib/llm/providers/bedrock/response_adapter.rb,
lib/llm/providers/bedrock/response_adapter/models.rb,
lib/llm/providers/bedrock/response_adapter/completion.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Adapts Bedrock Converse API responses to llm.rb’s Response format.

Bedrock Converse returns:

{
  output: {message: {role: "assistant", content: [{...}, ...]}},
  usage: {inputTokens: N, outputTokens: N},
  modelId: "anthropic.claude-...",
  stopReason: "end_turn" | "tool_use" | "max_tokens" | ...
}

Defined Under Namespace

Modules: Completion, Models

Class Method Summary collapse

Class Method Details

.adapt(res, type:) ⇒ LLM::Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:



23
24
25
26
# File 'lib/llm/providers/bedrock/response_adapter.rb', line 23

def adapt(res, type:)
  response = (LLM::Response === res) ? res : LLM::Response.new(res)
  response.extend(select(type))
end

.select(type) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
35
36
37
38
# File 'lib/llm/providers/bedrock/response_adapter.rb', line 30

def select(type)
  case type
  when :completion then LLM::Bedrock::ResponseAdapter::Completion
  when :models then LLM::Bedrock::ResponseAdapter::Models
  else
    raise ArgumentError,
          "Unknown response adapter type: #{type.inspect}"
  end
end