optimize • AI Agent SDK
optimize: Optimize messages to fit within target tokens.
optimize
Method
</div>
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
ParamField
ListNo description available.
ParamField
intNo description available.
ParamField
ContextLedgerNo description available.
Returns
ResponseField
tuple[List[Dict[str, Any]], OptimizationResult]The result of the operation.
Source
View on GitHubpraisonaiagents/context/models.py at line 466