Sha256: 1548e6a4b93534f09a9664f983eadaaa9a2563278c27c441870a13946e81a1ba

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module OmniAI
  # An abstract class that provides an interface for chatting for various vendors (e.g. OpenAI::ChatGPT).
  #
  # Usage:
  #
  #   class OmniAI::OpenAI::Chat < OmniAI::Chat
  #     def completion(messages, model:, temperature: 0.0, format: :text)
  #       # TODO: implement
  #     end
  #   end
  #
  # Once defined, it can be used to interface with the vendor's chat API as follows:
  #
  #   client.chat.completion("...", model: "...", temperature: 0.0, format: :text)
  #
  # @param client [OmniAI::Client] the client
  class Chat
    def initialize(client:)
      @client = client
    end

    # @raise [OmniAI::Error]
    # @param messages [String]
    # @param model [String]
    # @param format [Symbol] either :text or :json
    # @param temperature [Float]
    # @return [OmniAI::Chat::Completion] an instance of OmniAI::Chat::Completion
    def completion(messages, model:, temperature: 0.0, format: :text)
      raise NotImplementedError, "#{self.class.name}#completion undefined"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniai-0.0.2 lib/omniai/chat.rb