Class: Raix::Configuration

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

Overview

The Configuration class holds the configuration options for the Raix gem.

Constant Summary collapse

DEFAULT_MAX_TOKENS =
1000
DEFAULT_MAX_COMPLETION_TOKENS =
16_384
DEFAULT_MODEL =
"meta-llama/llama-3.3-8b-instruct:free"
DEFAULT_TEMPERATURE =
0.0
DEFAULT_MAX_TOOL_CALLS =
25

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fallback: nil) ⇒ Configuration

Initializes a new instance of the Configuration class with default values.



58
59
60
61
62
63
64
65
66
# File 'lib/raix/configuration.rb', line 58

def initialize(fallback: nil)
  self.temperature = DEFAULT_TEMPERATURE
  self.max_completion_tokens = DEFAULT_MAX_COMPLETION_TOKENS
  self.max_tokens = DEFAULT_MAX_TOKENS
  self.model = DEFAULT_MODEL
  self.max_tool_calls = DEFAULT_MAX_TOOL_CALLS
  self.ruby_llm_config = RubyLLM.config
  self.fallback = fallback
end

Class Method Details

.attr_accessor_with_fallback(method_name) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/raix/configuration.rb', line 6

def self.attr_accessor_with_fallback(method_name)
  define_method(method_name) do
    value = instance_variable_get("@#{method_name}")
    return value if value
    return unless fallback

    fallback.public_send(method_name)
  end
  define_method("#{method_name}=") do |value|
    instance_variable_set("@#{method_name}", value)
  end
end

Instance Method Details

#client?Boolean

Returns:

  • (Boolean)


68
69
70
71
# File 'lib/raix/configuration.rb', line 68

def client?
  # Support legacy openrouter_client/openai_client or new RubyLLM config
  !!(openrouter_client || openai_client || ruby_llm_configured?)
end

#ruby_llm_configured?Boolean

Returns:

  • (Boolean)


73
74
75
76
# File 'lib/raix/configuration.rb', line 73

def ruby_llm_configured?
  ruby_llm_config&.openai_api_key || ruby_llm_config&.openrouter_api_key ||
    ruby_llm_config&.anthropic_api_key || ruby_llm_config&.gemini_api_key
end