Sha256: cd9b1b46a04c3f5407a1a3f315e8899589560d7c4c94d310f6ccf0fe38da031b

Contents?: true

Size: 455 Bytes

Versions: 4

Compression:

Stored size: 455 Bytes

Contents

# frozen_string_literal: true

module GenAI
  module Api
    module Format
      module Anthropic
        def format_messages(messages)
          messages.map(&:deep_symbolize_keys)
        end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gen-ai-0.4.3 lib/gen_ai/api/format/anthropic.rb
gen-ai-0.4.2 lib/gen_ai/api/format/anthropic.rb
gen-ai-0.4.1 lib/gen_ai/api/format/anthropic.rb
gen-ai-0.4.0 lib/gen_ai/api/format/anthropic.rb