Class: LlmCostTracker::Configuration
- Inherits:
-
Object
- Object
- LlmCostTracker::Configuration
- Defined in:
- lib/llm_cost_tracker/configuration.rb
Constant Summary collapse
- OPENAI_COMPATIBLE_PROVIDERS =
Hostname => provider name for OpenAI-compatible APIs.
{ "openrouter.ai" => "openrouter", "api.deepseek.com" => "deepseek" }.freeze
- BUDGET_EXCEEDED_BEHAVIORS =
%i[notify raise block_requests].freeze
- STORAGE_ERROR_BEHAVIORS =
%i[ignore warn raise].freeze
- UNKNOWN_PRICING_BEHAVIORS =
%i[ignore warn raise].freeze
Instance Attribute Summary collapse
-
#budget_exceeded_behavior ⇒ Object
Returns the value of attribute budget_exceeded_behavior.
-
#custom_storage ⇒ Object
Returns the value of attribute custom_storage.
-
#default_tags ⇒ Object
Returns the value of attribute default_tags.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#monthly_budget ⇒ Object
Returns the value of attribute monthly_budget.
-
#on_budget_exceeded ⇒ Object
Returns the value of attribute on_budget_exceeded.
-
#openai_compatible_providers ⇒ Object
Returns the value of attribute openai_compatible_providers.
-
#prices_file ⇒ Object
Returns the value of attribute prices_file.
-
#pricing_overrides ⇒ Object
Returns the value of attribute pricing_overrides.
-
#storage_backend ⇒ Object
Returns the value of attribute storage_backend.
-
#storage_error_behavior ⇒ Object
Returns the value of attribute storage_error_behavior.
-
#unknown_pricing_behavior ⇒ Object
Returns the value of attribute unknown_pricing_behavior.
Instance Method Summary collapse
- #active_record? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #log? ⇒ Boolean
- #normalize_openai_compatible_providers! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/llm_cost_tracker/configuration.rb', line 30 def initialize @enabled = true @storage_backend = :log @custom_storage = nil @default_tags = {} @on_budget_exceeded = nil @monthly_budget = nil @budget_exceeded_behavior = :notify @storage_error_behavior = :warn @unknown_pricing_behavior = :warn @log_level = :info @prices_file = nil @pricing_overrides = {} self.openai_compatible_providers = OPENAI_COMPATIBLE_PROVIDERS end |
Instance Attribute Details
#budget_exceeded_behavior ⇒ Object
Returns the value of attribute budget_exceeded_behavior.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def budget_exceeded_behavior @budget_exceeded_behavior end |
#custom_storage ⇒ Object
Returns the value of attribute custom_storage.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def custom_storage @custom_storage end |
#default_tags ⇒ Object
Returns the value of attribute default_tags.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def @default_tags end |
#enabled ⇒ Object
Returns the value of attribute enabled.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def enabled @enabled end |
#log_level ⇒ Object
Returns the value of attribute log_level.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def log_level @log_level end |
#monthly_budget ⇒ Object
Returns the value of attribute monthly_budget.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def monthly_budget @monthly_budget end |
#on_budget_exceeded ⇒ Object
Returns the value of attribute on_budget_exceeded.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def on_budget_exceeded @on_budget_exceeded end |
#openai_compatible_providers ⇒ Object
Returns the value of attribute openai_compatible_providers.
28 29 30 |
# File 'lib/llm_cost_tracker/configuration.rb', line 28 def openai_compatible_providers @openai_compatible_providers end |
#prices_file ⇒ Object
Returns the value of attribute prices_file.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def prices_file @prices_file end |
#pricing_overrides ⇒ Object
Returns the value of attribute pricing_overrides.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def pricing_overrides @pricing_overrides end |
#storage_backend ⇒ Object
Returns the value of attribute storage_backend.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def storage_backend @storage_backend end |
#storage_error_behavior ⇒ Object
Returns the value of attribute storage_error_behavior.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def storage_error_behavior @storage_error_behavior end |
#unknown_pricing_behavior ⇒ Object
Returns the value of attribute unknown_pricing_behavior.
15 16 17 |
# File 'lib/llm_cost_tracker/configuration.rb', line 15 def unknown_pricing_behavior @unknown_pricing_behavior end |
Instance Method Details
#active_record? ⇒ Boolean
54 55 56 |
# File 'lib/llm_cost_tracker/configuration.rb', line 54 def active_record? storage_backend == :active_record end |
#log? ⇒ Boolean
58 59 60 |
# File 'lib/llm_cost_tracker/configuration.rb', line 58 def log? storage_backend == :log end |
#normalize_openai_compatible_providers! ⇒ Object
50 51 52 |
# File 'lib/llm_cost_tracker/configuration.rb', line 50 def normalize_openai_compatible_providers! self.openai_compatible_providers = openai_compatible_providers end |