Class: Phronomy::LlmContextWindow::TokenBudget
- Inherits:
-
Object
- Object
- Phronomy::LlmContextWindow::TokenBudget
- Defined in:
- lib/phronomy/llm_context_window/token_budget.rb
Overview
Immutable arithmetic value for one resolved model context budget. Model-registry lookup belongs to Agent::TokenBudgetResolver.
Instance Attribute Summary collapse
-
#context_window ⇒ Object
readonly
Returns the value of attribute context_window.
-
#max_output_tokens ⇒ Object
readonly
Returns the value of attribute max_output_tokens.
Instance Method Summary collapse
- #available(used: 0) ⇒ Object private
- #effective_input_limit ⇒ Object private
-
#initialize(context_window:, max_output_tokens:) ⇒ TokenBudget
constructor
private
A new instance of TokenBudget.
Constructor Details
#initialize(context_window:, max_output_tokens:) ⇒ TokenBudget
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TokenBudget.
11 12 13 14 |
# File 'lib/phronomy/llm_context_window/token_budget.rb', line 11 def initialize(context_window:, max_output_tokens:) @context_window = Integer(context_window) @max_output_tokens = Integer(max_output_tokens) end |
Instance Attribute Details
#context_window ⇒ Object (readonly)
Returns the value of attribute context_window.
8 9 10 |
# File 'lib/phronomy/llm_context_window/token_budget.rb', line 8 def context_window @context_window end |
#max_output_tokens ⇒ Object (readonly)
Returns the value of attribute max_output_tokens.
8 9 10 |
# File 'lib/phronomy/llm_context_window/token_budget.rb', line 8 def max_output_tokens @max_output_tokens end |
Instance Method Details
#available(used: 0) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/phronomy/llm_context_window/token_budget.rb', line 22 def available(used: 0) [effective_input_limit - Integer(used), 0].max end |
#effective_input_limit ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 |
# File 'lib/phronomy/llm_context_window/token_budget.rb', line 17 def effective_input_limit [@context_window - @max_output_tokens, 0].max end |