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
- STORAGE_BACKENDS =
%i[log active_record custom].freeze
- UNKNOWN_PRICING_BEHAVIORS =
%i[ignore warn raise].freeze
Instance Attribute Summary collapse
-
#budget_exceeded_behavior ⇒ Object
:notify, :raise, :block_requests.
-
#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
:notify, :raise, :block_requests.
-
#prices_file ⇒ Object
Returns the value of attribute prices_file.
-
#pricing_overrides ⇒ Object
Returns the value of attribute pricing_overrides.
-
#storage_backend ⇒ Object
:notify, :raise, :block_requests.
-
#storage_error_behavior ⇒ Object
:notify, :raise, :block_requests.
-
#unknown_pricing_behavior ⇒ Object
:notify, :raise, :block_requests.
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.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/llm_cost_tracker/configuration.rb', line 33 def initialize @enabled = true self.storage_backend = :log @custom_storage = nil @default_tags = {} @on_budget_exceeded = nil @monthly_budget = nil self.budget_exceeded_behavior = :notify self.storage_error_behavior = :warn self.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
:notify, :raise, :block_requests
27 28 29 |
# File 'lib/llm_cost_tracker/configuration.rb', line 27 def budget_exceeded_behavior @budget_exceeded_behavior end |
#custom_storage ⇒ Object
Returns the value of attribute custom_storage.
18 19 20 |
# File 'lib/llm_cost_tracker/configuration.rb', line 18 def custom_storage @custom_storage end |
#default_tags ⇒ Object
Returns the value of attribute default_tags.
18 19 20 |
# File 'lib/llm_cost_tracker/configuration.rb', line 18 def @default_tags end |
#enabled ⇒ Object
Returns the value of attribute enabled.
18 19 20 |
# File 'lib/llm_cost_tracker/configuration.rb', line 18 def enabled @enabled end |
#log_level ⇒ Object
Returns the value of attribute log_level.
18 19 20 |
# File 'lib/llm_cost_tracker/configuration.rb', line 18 def log_level @log_level end |
#monthly_budget ⇒ Object
Returns the value of attribute monthly_budget.
18 19 20 |
# File 'lib/llm_cost_tracker/configuration.rb', line 18 def monthly_budget @monthly_budget end |
#on_budget_exceeded ⇒ Object
Returns the value of attribute on_budget_exceeded.
18 19 20 |
# File 'lib/llm_cost_tracker/configuration.rb', line 18 def on_budget_exceeded @on_budget_exceeded end |
#openai_compatible_providers ⇒ Object
:notify, :raise, :block_requests
27 28 29 |
# File 'lib/llm_cost_tracker/configuration.rb', line 27 def openai_compatible_providers @openai_compatible_providers end |
#prices_file ⇒ Object
Returns the value of attribute prices_file.
18 19 20 |
# File 'lib/llm_cost_tracker/configuration.rb', line 18 def prices_file @prices_file end |
#pricing_overrides ⇒ Object
Returns the value of attribute pricing_overrides.
18 19 20 |
# File 'lib/llm_cost_tracker/configuration.rb', line 18 def pricing_overrides @pricing_overrides end |
#storage_backend ⇒ Object
:notify, :raise, :block_requests
27 28 29 |
# File 'lib/llm_cost_tracker/configuration.rb', line 27 def storage_backend @storage_backend end |
#storage_error_behavior ⇒ Object
:notify, :raise, :block_requests
27 28 29 |
# File 'lib/llm_cost_tracker/configuration.rb', line 27 def storage_error_behavior @storage_error_behavior end |
#unknown_pricing_behavior ⇒ Object
:notify, :raise, :block_requests
27 28 29 |
# File 'lib/llm_cost_tracker/configuration.rb', line 27 def unknown_pricing_behavior @unknown_pricing_behavior end |
Instance Method Details
#active_record? ⇒ Boolean
88 89 90 |
# File 'lib/llm_cost_tracker/configuration.rb', line 88 def active_record? storage_backend == :active_record end |
#log? ⇒ Boolean
92 93 94 |
# File 'lib/llm_cost_tracker/configuration.rb', line 92 def log? storage_backend == :log end |
#normalize_openai_compatible_providers! ⇒ Object
84 85 86 |
# File 'lib/llm_cost_tracker/configuration.rb', line 84 def normalize_openai_compatible_providers! self.openai_compatible_providers = openai_compatible_providers end |