Sha256: 2e6f4ec87eef26d088ef8752f73bc4dd45caa845cf35613dd957d73ef2e53acb

Contents?: true

Size: 994 Bytes

Versions: 3

Compression:

Stored size: 994 Bytes

Contents

require "httparty"

require_relative "openai/client"
require_relative "openai/files"
require_relative "openai/finetunes"
require_relative "openai/images"
require_relative "openai/models"
require_relative "openai/version"

module OpenAI
  class Error < StandardError; end
  class ConfigurationError < Error; end

  class Configuration
    attr_writer :access_token
    attr_accessor :api_version, :organization_id

    DEFAULT_API_VERSION = "v1".freeze

    def initialize
      @access_token = nil
      @api_version = DEFAULT_API_VERSION
      @organization_id = nil
    end

    def access_token
      return @access_token if @access_token

      error_text = "OpenAI access token missing! See https://github.com/alexrudall/ruby-openai#usage"
      raise ConfigurationError, error_text
    end
  end

  class << self
    attr_writer :configuration
  end

  def self.configuration
    @configuration ||= OpenAI::Configuration.new
  end

  def self.configure
    yield(configuration)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-openai-3.5.0 lib/openai.rb
ruby-openai-3.4.0 lib/openai.rb
ruby-openai-3.3.0 lib/openai.rb