Skip to main content

optimize

Method
This is a method of the ContextOptimizer class in the models module.
Optimize messages to fit within target tokens.

Signature

def optimize(messages: List[Dict[str, Any]], target_tokens: int, ledger: ContextLedger) -> tuple[List[Dict[str, Any]], OptimizationResult]

Parameters

messages
List
required
No description available.
target_tokens
int
required
No description available.
ledger
ContextLedger
required
No description available.

Returns

Returns
tuple[List[Dict[str, Any]], OptimizationResult]
The result of the operation.