Class: PromptWarden::Configuration
- Inherits:
-
Object
- Object
- PromptWarden::Configuration
- Defined in:
- lib/prompt_warden/configuration.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#batch_bytes ⇒ Object
Returns the value of attribute batch_bytes.
-
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
-
#price_overrides ⇒ Object
Returns the value of attribute price_overrides.
-
#project_token ⇒ Object
Returns the value of attribute project_token.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#register_adapter(key, &block) ⇒ Object
— adapter registration ——————————————- Called by host app for custom SDKs.
-
#run_pending_adapters ⇒ Object
Invoked by internal loader after all built‑in auto‑detects.
-
#validate! ⇒ Object
— validation ——————————————————.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/prompt_warden/configuration.rb', line 11 def initialize @project_token = ENV['PROMPT_WARDEN_TOKEN'] @flush_interval = 1.0 @batch_bytes = 256 * 1024 @max_retries = 3 @logger = defined?(Rails) ? Rails.logger : Logger.new($stdout) @api_url = ENV['PROMPT_WARDEN_API'] || 'https://staging.promptwarden.dev/api/v1/ingest' @price_overrides = {} # e.g., { "gpt-4o" => 0.005 } @adapter_blocks = {} # lazily‑executed registration procs end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
7 8 9 |
# File 'lib/prompt_warden/configuration.rb', line 7 def api_url @api_url end |
#batch_bytes ⇒ Object
Returns the value of attribute batch_bytes.
7 8 9 |
# File 'lib/prompt_warden/configuration.rb', line 7 def batch_bytes @batch_bytes end |
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
7 8 9 |
# File 'lib/prompt_warden/configuration.rb', line 7 def flush_interval @flush_interval end |
#logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/prompt_warden/configuration.rb', line 7 def logger @logger end |
#max_retries ⇒ Object
Returns the value of attribute max_retries.
7 8 9 |
# File 'lib/prompt_warden/configuration.rb', line 7 def max_retries @max_retries end |
#price_overrides ⇒ Object
Returns the value of attribute price_overrides.
7 8 9 |
# File 'lib/prompt_warden/configuration.rb', line 7 def price_overrides @price_overrides end |
#project_token ⇒ Object
Returns the value of attribute project_token.
7 8 9 |
# File 'lib/prompt_warden/configuration.rb', line 7 def project_token @project_token end |
Instance Method Details
#register_adapter(key, &block) ⇒ Object
— adapter registration ——————————————- Called by host app for custom SDKs
29 30 31 32 |
# File 'lib/prompt_warden/configuration.rb', line 29 def register_adapter(key, &block) @adapter_blocks[key] = block block.call if Gem.loaded_specs.key?(key.to_s) # execute immediately if gem already loaded end |
#run_pending_adapters ⇒ Object
Invoked by internal loader after all built‑in auto‑detects
35 36 37 |
# File 'lib/prompt_warden/configuration.rb', line 35 def run_pending_adapters @adapter_blocks.each_value(&:call) end |
#validate! ⇒ Object
— validation ——————————————————
23 24 25 |
# File 'lib/prompt_warden/configuration.rb', line 23 def validate! raise ArgumentError, 'project_token is required' if @project_token.to_s.empty? end |