Sha256: 6294c6eab54898422e457f613621c6d9b3558668421ad155bebf8a604a06d87d

Contents?: true

Size: 728 Bytes

Versions: 3

Compression:

Stored size: 728 Bytes

Contents

require 'logger'
require 'openai'

module Bristow
  class Configuration
    attr_accessor :openai_api_key, :default_model, :logger
    attr_reader :client

    def initialize
      @openai_api_key = ENV['OPENAI_API_KEY']
      @default_model = 'gpt-4o-mini'
      @logger = Logger.new(STDOUT)
      reset_client
    end

    def openai_api_key=(key)
      @openai_api_key = key
      reset_client
    end

    private

    def reset_client
      @client = OpenAI::Client.new(access_token: @openai_api_key)
    end
  end

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

  def self.configure
    yield(configuration)
  end

  def self.reset_configuration!
    @configuration = Configuration.new
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bristow-0.2.1 lib/bristow/configuration.rb
bristow-0.2.0 lib/bristow/configuration.rb
bristow-0.1.0 lib/bristow/configuration.rb