Sha256: 4228804f9baef5e16e784c7abc630f920db68ad438f6bbae3d380572641f9b45

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

require_relative "quick_openai/version"
require_relative "quick_openai/dalle2"
require_relative "quick_openai/gpt3"
require_relative "quick_openai/extensions/string"

module QuickOpenAI
  class Error < StandardError; end

  def self.client
    OpenAI::Client.new
  end

  def self.fetch_response_from_client
    begin
      response = yield client
    rescue StandardError
      raise QuickOpenAI::Error, "Unable to fetch response."
    end

    if (error = response.dig("error", "message"))
      raise QuickOpenAI::Error, "Unable to fetch response: #{error}"
    end

    response
  end
end

require "down"
require "ruby/openai"
require "tempfile"

class String
  include QuickOpenAI::Extensions::String
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quick_openai-0.1.0 lib/quick_openai.rb