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, temperature, and extra request parameters

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, temperature: 0.0, provider: nil, model: nil, extra_params: {}) ⇒ 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, nil) (defaults to: nil)

    LLM provider: :openai, :anthropic, :gemini, :groq, :spacexai, or :openrouter. When nil (default), the provider is inferred from the api_key prefix, falling back to :openai for unrecognized keys.

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

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

  • extra_params (Hash) (defaults to: {})

    Provider-native request parameters deep-merged into the payload last, so they can override anything (e.g. { max_tokens: 100 })

Raises:

  • (ArgumentError)

    if api_key is nil or empty, or provider is unknown



23
24
25
26
27
28
29
30
31
# File 'lib/vibe_sort/configuration.rb', line 23

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

  @provider = resolve_provider(provider, api_key)
  @api_key = api_key
  @temperature = temperature
  @model = model
  @extra_params = extra_params
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

#extra_paramsObject (readonly)

Returns the value of attribute extra_params.



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

def extra_params
  @extra_params
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