Class: RosettAi::AiConfig::ContextWindow
- Inherits:
-
Object
- Object
- RosettAi::AiConfig::ContextWindow
- Defined in:
- lib/rosett_ai/ai_config/context_window.rb
Overview
Manages context window configuration settings.
Tracks max tokens, output reserve, and truncation strategy for compilation into engine-native settings.
Constant Summary collapse
- TRUNCATION_STRATEGIES =
['tail', 'head', 'middle'].freeze
- DEFAULT_MAX_TOKENS =
200_000- DEFAULT_RESERVE =
8192
Instance Attribute Summary collapse
-
#max_tokens ⇒ Object
readonly
Returns the value of attribute max_tokens.
-
#output_reserve ⇒ Object
readonly
Returns the value of attribute output_reserve.
-
#truncation_strategy ⇒ Object
readonly
Returns the value of attribute truncation_strategy.
Instance Method Summary collapse
-
#effective_input_tokens ⇒ Integer
Effective input tokens (max minus reserve).
-
#initialize(max_tokens: DEFAULT_MAX_TOKENS, output_reserve: DEFAULT_RESERVE, truncation_strategy: 'tail') ⇒ ContextWindow
constructor
A new instance of ContextWindow.
-
#to_h ⇒ Hash
Serializable representation.
Constructor Details
#initialize(max_tokens: DEFAULT_MAX_TOKENS, output_reserve: DEFAULT_RESERVE, truncation_strategy: 'tail') ⇒ ContextWindow
Returns a new instance of ContextWindow.
22 23 24 25 26 27 28 29 |
# File 'lib/rosett_ai/ai_config/context_window.rb', line 22 def initialize(max_tokens: DEFAULT_MAX_TOKENS, output_reserve: DEFAULT_RESERVE, truncation_strategy: 'tail') validate_strategy!(truncation_strategy) @max_tokens = max_tokens @output_reserve = output_reserve @truncation_strategy = truncation_strategy.freeze end |
Instance Attribute Details
#max_tokens ⇒ Object (readonly)
Returns the value of attribute max_tokens.
17 18 19 |
# File 'lib/rosett_ai/ai_config/context_window.rb', line 17 def max_tokens @max_tokens end |
#output_reserve ⇒ Object (readonly)
Returns the value of attribute output_reserve.
17 18 19 |
# File 'lib/rosett_ai/ai_config/context_window.rb', line 17 def output_reserve @output_reserve end |
#truncation_strategy ⇒ Object (readonly)
Returns the value of attribute truncation_strategy.
17 18 19 |
# File 'lib/rosett_ai/ai_config/context_window.rb', line 17 def truncation_strategy @truncation_strategy end |
Instance Method Details
#effective_input_tokens ⇒ Integer
Returns effective input tokens (max minus reserve).
32 33 34 |
# File 'lib/rosett_ai/ai_config/context_window.rb', line 32 def effective_input_tokens @max_tokens - @output_reserve end |
#to_h ⇒ Hash
Returns serializable representation.
37 38 39 40 41 42 43 |
# File 'lib/rosett_ai/ai_config/context_window.rb', line 37 def to_h { 'max_tokens' => @max_tokens, 'output_reserve' => @output_reserve, 'truncation_strategy' => @truncation_strategy } end |