Class: Verica::Config
- Inherits:
-
Struct
- Object
- Struct
- Verica::Config
- Defined in:
- lib/verica/config.rb
Overview
Config resolution: options > env vars > defaults. Pure.
Constant Summary collapse
- DEFAULT_ENDPOINT =
Verica's hosted ingest endpoint. Override via the
endpoint:option or the VERICA_ENDPOINT env var for self-host or local dev. Onlytokenis required. 'https://ingest.verica.app'
Instance Attribute Summary collapse
-
#capture_content ⇒ Object
Returns the value of attribute capture_content.
-
#conversation_id ⇒ Object
Returns the value of attribute conversation_id.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#service_name ⇒ Object
Returns the value of attribute service_name.
-
#stream_usage ⇒ Object
Returns the value of attribute stream_usage.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
Instance Attribute Details
#capture_content ⇒ Object
Returns the value of attribute capture_content
5 6 7 |
# File 'lib/verica/config.rb', line 5 def capture_content @capture_content end |
#conversation_id ⇒ Object
Returns the value of attribute conversation_id
5 6 7 |
# File 'lib/verica/config.rb', line 5 def conversation_id @conversation_id end |
#debug ⇒ Object
Returns the value of attribute debug
5 6 7 |
# File 'lib/verica/config.rb', line 5 def debug @debug end |
#endpoint ⇒ Object
Returns the value of attribute endpoint
5 6 7 |
# File 'lib/verica/config.rb', line 5 def endpoint @endpoint end |
#service_name ⇒ Object
Returns the value of attribute service_name
5 6 7 |
# File 'lib/verica/config.rb', line 5 def service_name @service_name end |
#stream_usage ⇒ Object
Returns the value of attribute stream_usage
5 6 7 |
# File 'lib/verica/config.rb', line 5 def stream_usage @stream_usage end |
#tags ⇒ Object
Returns the value of attribute tags
5 6 7 |
# File 'lib/verica/config.rb', line 5 def @tags end |
#token ⇒ Object
Returns the value of attribute token
5 6 7 |
# File 'lib/verica/config.rb', line 5 def token @token end |
Class Method Details
.resolve(options, env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/verica/config.rb', line 11 def self.resolve(, env) token = ([:token] || env['VERICA_TOKEN'] || '').to_s return [nil, ['token']] if token.empty? raw_endpoint = ([:endpoint] || env['VERICA_ENDPOINT'] || DEFAULT_ENDPOINT).to_s capture = [:capture_content] capture = env.key?('VERICA_CAPTURE_CONTENT') ? %w[1 true].include?(env['VERICA_CAPTURE_CONTENT']) : true if capture.nil? [new( token: token, endpoint: raw_endpoint.sub(%r{/+\z}, ''), capture_content: capture, conversation_id: [:conversation_id], tags: Array([:tags]).map(&:to_s).reject(&:empty?).uniq, service_name: [:service_name] || env['OTEL_SERVICE_NAME'] || 'app', debug: [:debug].nil? ? %w[1 true].include?(env['VERICA_DEBUG']) : [:debug], # Opt-in: append `stream_options: { include_usage: true }` to streaming # calls so the provider emits a final usage chunk (tokens + cost). Off by # default because it adds a trailing empty-choices chunk some caller procs # may not expect. stream_usage: [:stream_usage].nil? ? %w[1 true].include?(env['VERICA_STREAM_USAGE']) : [:stream_usage] ), []] end |