Class: Raix::Configuration
- Inherits:
-
Object
- Object
- Raix::Configuration
- 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_MAX_TOOL_CALLS =
25
Class Method Summary collapse
Instance Method Summary collapse
- #client? ⇒ Boolean
-
#initialize(fallback: nil) ⇒ Configuration
constructor
Initializes a new instance of the Configuration class with default values.
- #ruby_llm_configured? ⇒ Boolean
Constructor Details
#initialize(fallback: nil) ⇒ Configuration
Initializes a new instance of the Configuration class with default values.
Note: temperature is intentionally not defaulted. Setting a non-nil
temperature here would force it into every request payload, and some
providers (e.g. Anthropic's Claude 4.7 family on OpenRouter) do not list
temperature in their supported parameters. Combined with
provider.require_parameters: true (which Raix sets when json: true),
an injected default of 0.0 causes OpenRouter to reject the request with
"No endpoints found that can handle the requested parameters." Callers
who want a specific temperature should set one explicitly.
66 67 68 69 70 71 72 73 |
# File 'lib/raix/configuration.rb', line 66 def initialize(fallback: nil) 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
75 76 77 78 |
# File 'lib/raix/configuration.rb', line 75 def client? # Support legacy openrouter_client/openai_client or new RubyLLM config !!(openrouter_client || openai_client || ruby_llm_configured?) end |
#ruby_llm_configured? ⇒ Boolean
80 81 82 83 |
# File 'lib/raix/configuration.rb', line 80 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 |