Sha256: aced3ad7dcb2a7698f3e317a383df0f4d2e607700b9a3d7701e668f6ab7e45ee

Contents?: true

Size: 607 Bytes

Versions: 3

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true

module OmniAI
  class Chat
    # A choice returned by the API.
    class Choice
      attr_accessor :data

      # @param data [Hash]
      def initialize(data:)
        @data = data
      end

      # @return [Integer]
      def index
        @data['index']
      end

      # @return [OmniAI::Chat::Delta]
      def delta
        Delta.new(data: @data['delta']) if @data['delta']
      end

      # @return [OmniAI::Chat::Message]
      def message
        return unless @data['message']

        @message ||= Message.for(role: @data['message'])
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
omniai-1.0.6 lib/omniai/chat/choice.rb
omniai-1.0.5 lib/omniai/chat/choice.rb
omniai-1.0.4 lib/omniai/chat/choice.rb