org.llm4s.context.TokenWindow
Manages conversation token windows by trimming conversations to fit within token budgets. Always preserves system messages and applies configurable headroom for safety.
Attributes
Graph
Reset zoom Hide graph Show graph
Supertypes
class Object
trait Matchable
class Any
Self type
Members list
Check if a conversation fits within the budget (including headroom)
Check if a conversation fits within the budget (including headroom)
Attributes
Get current token usage information for a conversation
Get current token usage information for a conversation
Attributes
Trim a conversation to fit within the specified token budget. Always preserves system messages and applies headroom for safety.
Trim a conversation to fit within the specified token budget. Always preserves system messages and applies headroom for safety.
Value parameters
budget
Maximum token budget
conversation
The conversation to trim
headroomPercent
Safety margin (default 8%)
tokenCounter
Token counter for the specific model
Attributes
Returns
Trimmed conversation that fits within budget