Class: OmniAI::Anthropic::Chat::Response::Completion

Inherits:
Chat::Response::Completion
  • Object
show all
Defined in:
lib/omniai/anthropic/chat/response/completion.rb

Overview

A completion returned by the API.

Instance Method Summary collapse

Instance Method Details

#choicesArray<OmniAI::Chat::Response::MessageChoice>

Returns:

  • (Array<OmniAI::Chat::Response::MessageChoice>)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/omniai/anthropic/chat/response/completion.rb', line 10

def choices
  @choices ||= begin
    role = @data['role']

    @data['content'].map do |data, index|
      OmniAI::Chat::Response::MessageChoice.new(data: {
        'index' => index,
        'message' => {
          'role' => role,
          'content' => data['text'],
        },
      })
    end
  end
end