max_response_length()

Guard that enforces a maximum response length.

Usage

Source

max_response_length(max_chars)

Truncates responses that exceed the character limit, appending an ellipsis to indicate truncation.

Parameters

max_chars: int
Maximum allowed characters in the response.

Returns

Guard
A configured length enforcement guard (output-only).

Examples

bot = tb.ChatBot().guardrail(tb.max_response_length(500))