Module: LLM::Bedrock::RequestAdapter Private
- Included in:
- LLM::Bedrock
- Defined in:
- lib/llm/providers/bedrock/request_adapter.rb,
lib/llm/providers/bedrock/request_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 llm.rb internal message format to Bedrock Converse API format.
Bedrock Converse uses:
- system: [{text: "..."}] (top-level, separate from messages)
- messages: [{role: "user"|"assistant", content: [{...}, ...]}]
- Content blocks: text, image, document, toolUse, toolResult
- toolConfig: {tools: [{toolSpec: {name:, description:, inputSchema: {json: ...}}}]}
Defined Under Namespace
Classes: Completion
Instance Method Summary collapse
Instance Method Details
#adapt(messages, mode: nil) ⇒ Hash
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.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/llm/providers/bedrock/request_adapter.rb', line 18 def adapt(, mode: nil) payload = {messages: [], system: []} .each do || adapted = Completion.new().adapt next if adapted.nil? if system?() payload[:system].concat Array(adapted[:content]) else payload[:messages] << adapted end end payload.delete(:system) if payload[:system].empty? payload end |