Class: Qualspec::Configuration
- Inherits:
-
Object
- Object
- Qualspec::Configuration
- Defined in:
- lib/qualspec/configuration.rb
Constant Summary collapse
- DEFAULT_API_URL =
'https://openrouter.ai/api/v1'- DEFAULT_MODEL =
Universal fallback.
openrouter/autoroutes to a sensible model for any request, so qualspec works even with no model configured anywhere. 'openrouter/auto'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Explicitly configured key wins; otherwise fall back to env vars.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#cache_dir ⇒ Object
Returns the value of attribute cache_dir.
-
#cache_enabled ⇒ Object
Returns the value of attribute cache_enabled.
-
#default_model ⇒ Object
Returns the value of attribute default_model.
-
#judge_model ⇒ Object
Returns the value of attribute judge_model.
-
#judge_system_prompt ⇒ Object
Returns the value of attribute judge_system_prompt.
-
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
Instance Method Summary collapse
- #api_headers ⇒ Object
- #api_key_configured? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/qualspec/configuration.rb', line 14 def initialize @api_url = ENV.fetch('QUALSPEC_API_URL', DEFAULT_API_URL) # Default nil: set explicitly via Qualspec.configure { |c| c.api_key = ... }. # When unset, #api_key falls back to env vars (see reader below). @api_key = nil @default_model = ENV.fetch('QUALSPEC_MODEL', DEFAULT_MODEL) @judge_model = ENV.fetch('QUALSPEC_JUDGE_MODEL') { @default_model } @cache_enabled = false @cache_dir = '.qualspec_cache' @judge_system_prompt = nil # Uses default if nil @request_timeout = 120 end |
Instance Attribute Details
#api_key ⇒ Object
Explicitly configured key wins; otherwise fall back to env vars. Prefer QUALSPEC_API_KEY, then OPEN_ROUTER_API_KEY (default backend is OpenRouter). The env vars are a convenience fallback, not a requirement — pass api_key in Qualspec.configure to avoid relying on them.
31 32 33 |
# File 'lib/qualspec/configuration.rb', line 31 def api_key @api_key || ENV['QUALSPEC_API_KEY'] || ENV['OPEN_ROUTER_API_KEY'] end |
#api_url ⇒ Object
Returns the value of attribute api_url.
5 6 7 |
# File 'lib/qualspec/configuration.rb', line 5 def api_url @api_url end |
#cache_dir ⇒ Object
Returns the value of attribute cache_dir.
5 6 7 |
# File 'lib/qualspec/configuration.rb', line 5 def cache_dir @cache_dir end |
#cache_enabled ⇒ Object
Returns the value of attribute cache_enabled.
5 6 7 |
# File 'lib/qualspec/configuration.rb', line 5 def cache_enabled @cache_enabled end |
#default_model ⇒ Object
Returns the value of attribute default_model.
5 6 7 |
# File 'lib/qualspec/configuration.rb', line 5 def default_model @default_model end |
#judge_model ⇒ Object
Returns the value of attribute judge_model.
5 6 7 |
# File 'lib/qualspec/configuration.rb', line 5 def judge_model @judge_model end |
#judge_system_prompt ⇒ Object
Returns the value of attribute judge_system_prompt.
5 6 7 |
# File 'lib/qualspec/configuration.rb', line 5 def judge_system_prompt @judge_system_prompt end |
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
5 6 7 |
# File 'lib/qualspec/configuration.rb', line 5 def request_timeout @request_timeout end |
Instance Method Details
#api_headers ⇒ Object
35 36 37 38 39 |
# File 'lib/qualspec/configuration.rb', line 35 def api_headers headers = { 'Content-Type' => 'application/json' } headers['Authorization'] = "Bearer #{api_key}" unless api_key.to_s.empty? headers end |
#api_key_configured? ⇒ Boolean
41 42 43 |
# File 'lib/qualspec/configuration.rb', line 41 def api_key_configured? !api_key.to_s.empty? end |