Class: Phronomy::LlmContextWindow::TokenBudget

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_windowObject (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_tokensObject (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_limitObject

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