Truncate Context • Rust AI Agent SDK

truncate_context: Truncate context to fit token limit.

truncate_context

Function

</div>

This function is defined in the rag module.

Truncate context to fit token limit.

Signature

python
def truncate_context(context: &str, max_tokens: usize) -> String

Parameters

ParamField &str

No description available.

ParamField usize

No description available.

Returns

ResponseField String

The result of the operation.

Uses

  • estimate_tokens
  • character
  • min
  • is_char_boundary

Source

View on GitHub

praisonai/src/rag/mod.rs at line 614


Related Documentation