Class: VibeSort::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/vibe_sort/configuration.rb

Overview

Configuration class for VibeSort Holds provider, API key, model, and temperature settings

Constant Summary collapse

PROVIDERS =
%i[openai anthropic gemini groq spacexai].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, temperature: 0.0, provider: :openai, model: nil) ⇒ Configuration

Initialize a new Configuration

Parameters:

  • api_key (String)

    API key for the selected provider

  • temperature (Float) (defaults to: 0.0)

    Temperature for the model (0.0 to 2.0). Ignored by providers whose current models do not accept it (Anthropic).

  • provider (Symbol, String) (defaults to: :openai)

    LLM provider: :openai (default), :anthropic, :gemini, :groq, or :spacexai

  • model (String, nil) (defaults to: nil)

    Model ID override (nil uses the provider's default)

Raises:

  • (ArgumentError)

    if api_key is nil or empty, or provider is unknown



19
20
21
22
23
24
25
26
27
28
# File 'lib/vibe_sort/configuration.rb', line 19

def initialize(api_key:, temperature: 0.0, provider: :openai, model: nil)
  raise ArgumentError, "API key cannot be nil or empty" if api_key.nil? || api_key.empty?

  @provider = provider.to_s.to_sym
  raise ArgumentError, "Unknown provider: #{provider.inspect} (supported: #{PROVIDERS.join(", ")})" unless PROVIDERS.include?(@provider)

  @api_key = api_key
  @temperature = temperature
  @model = model
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



9
10
11
# File 'lib/vibe_sort/configuration.rb', line 9

def api_key
  @api_key
end

#modelObject (readonly)

Returns the value of attribute model.



9
10
11
# File 'lib/vibe_sort/configuration.rb', line 9

def model
  @model
end

#providerObject (readonly)

Returns the value of attribute provider.



9
10
11
# File 'lib/vibe_sort/configuration.rb', line 9

def provider
  @provider
end

#temperatureObject (readonly)

Returns the value of attribute temperature.



9
10
11
# File 'lib/vibe_sort/configuration.rb', line 9

def temperature
  @temperature
end