Class: LLM::Bedrock::RequestAdapter::Completion Private

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/providers/bedrock/request_adapter/completion.rb

Overview

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

Adapts a single message to Bedrock Converse content blocks.

Bedrock Converse content blocks include:

- {text: "..."}
- {image: {format: "png", source: {bytes: "..."}}}
- {document: {format: "pdf", name: "...", source: {bytes: "..."}}}
- {toolUse: {toolUseId: "...", name: "...", input: {...}}}
- {toolResult: {toolUseId: "...", content: [{text: "..."}]}}

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ Completion

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.

Returns a new instance of Completion.

Parameters:



18
19
20
# File 'lib/llm/providers/bedrock/request_adapter/completion.rb', line 18

def initialize(message)
  @message = message
end

Instance Method Details

#adaptHash?

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.

Adapts the message for the Bedrock Converse API

Returns:

  • (Hash, nil)


25
26
27
28
29
30
31
32
33
# File 'lib/llm/providers/bedrock/request_adapter/completion.rb', line 25

def adapt
  catch(:abort) do
    if Hash === message
      {role: message[:role], content: adapt_content(message[:content])}
    else
      adapt_message
    end
  end
end