Class: LlmCostTracker::Configuration
- Inherits:
-
Object
- Object
- LlmCostTracker::Configuration
show all
- Includes:
- Mutability
- Defined in:
- lib/llm_cost_tracker/configuration.rb,
lib/llm_cost_tracker/configuration/tags.rb,
lib/llm_cost_tracker/configuration/budgets.rb,
lib/llm_cost_tracker/configuration/capture.rb,
lib/llm_cost_tracker/configuration/pricing.rb,
lib/llm_cost_tracker/configuration/section.rb,
lib/llm_cost_tracker/configuration/ingestion.rb,
lib/llm_cost_tracker/configuration/mutability.rb
Defined Under Namespace
Modules: Mutability
Classes: Budgets, Capture, Ingestion, Pricing, Section, Tags
Constant Summary
collapse
- SECTIONS =
{
budgets: Budgets, capture: Capture, ingestion: Ingestion, pricing: Pricing, tags: Tags
}.freeze
- SCALAR_ATTRIBUTES =
%i[enabled].freeze
- DEPRECATED_OPTIONS =
{
monthly_budget: { to: %i[budgets monthly] },
daily_budget: { to: %i[budgets daily] },
per_call_budget: { to: %i[budgets per_call] },
budget_exceeded_behavior: { to: %i[budgets exceeded_behavior] },
on_budget_exceeded: { to: %i[budgets on_exceeded] },
default_tags: { to: %i[tags default] },
max_tag_count: { to: %i[tags max_count] },
max_tag_value_bytesize: { to: %i[tags max_value_bytesize] },
redacted_tag_keys: { to: %i[tags redacted_keys] },
report_tag_breakdowns: { to: %i[tags report_breakdown_keys] },
prices_file: { to: %i[pricing file] },
pricing_overrides: { to: %i[pricing overrides] },
unknown_pricing_behavior: { to: %i[pricing unknown_model_behavior] },
ingestion_pool_size: { to: %i[ingestion pool_size] },
auto_enable_stream_usage: { to: %i[capture request_stream_usage] },
openai_compatible_providers: { to: %i[capture openai_compatible_providers] },
cache_rollups: {
to: %i[budgets totals_source],
cast: ->(value) { value ? :cache : :ledger },
uncast: ->(value) { value == :cache }
},
ingestion: { to: %i[ingestion mode], writer_only: true },
log_level: { to: nil, note: "LlmCostTracker logs through Rails.logger, which owns the level" }
}.freeze
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Configuration.
51
52
53
54
55
56
57
|
# File 'lib/llm_cost_tracker/configuration.rb', line 51
def initialize
SECTIONS.each { |name, klass| instance_variable_set(:"@#{name}", klass.new(self)) }
@enabled = true
@log_level = :info
@instrumented_integrations = Set.new
@finalized = false
end
|
Instance Method Details
#finalize! ⇒ Object
102
103
104
105
106
|
# File 'lib/llm_cost_tracker/configuration.rb', line 102
def finalize!
SECTIONS.each_key { |name| public_send(name).finalize! }
@instrumented_integrations = deep_freeze(@instrumented_integrations || Set.new)
@finalized = true
end
|
#finalized? ⇒ Boolean
108
109
110
|
# File 'lib/llm_cost_tracker/configuration.rb', line 108
def finalized?
@finalized
end
|
#instrument(*names) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/llm_cost_tracker/configuration.rb', line 59
def instrument(*names)
ensure_mutable!
names = names.flatten
names = Integrations.names if names == [:all]
@instrumented_integrations.merge(names)
end
|
#instrumented?(name) ⇒ Boolean
66
67
68
|
# File 'lib/llm_cost_tracker/configuration.rb', line 66
def instrumented?(name)
@instrumented_integrations.include?(name)
end
|