Module: LLM::Anthropic::Format

Included in:
LLM::Anthropic
Defined in:
lib/llm/providers/anthropic/format.rb

Instance Method Summary collapse

Instance Method Details

#format(messages) ⇒ Array<Hash>

Parameters:

Returns:

  • (Array<Hash>)


11
12
13
14
15
16
17
18
19
# File 'lib/llm/providers/anthropic/format.rb', line 11

def format(messages)
  messages.map do
    if Hash === _1
      {role: _1[:role], content: format_content(_1[:content])}
    else
      {role: _1.role, content: format_content(_1.content)}
    end
  end
end