Module: GenAI::Api::Format::Anthropic

Included in:
Language::Anthropic
Defined in:
lib/gen_ai/api/format/anthropic.rb

Instance Method Summary collapse

Instance Method Details

#extract_completions(response) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/gen_ai/api/format/anthropic.rb', line 11

def extract_completions(response)
  if response['type'] == 'completion'
    [response['completion'].strip]
  else
    response['content'].map { |item| item['text'] }
  end
end

#format_messages(messages) ⇒ Object



7
8
9
# File 'lib/gen_ai/api/format/anthropic.rb', line 7

def format_messages(messages)
  messages.map(&:deep_symbolize_keys)
end