tone_check()
Guard that flags responses not matching the expected tone.
Usage
tone_check(
expected_tone,
*,
indicators=None,
)Uses keyword-based heuristics to detect tone mismatches. For production use with high accuracy, consider extending with an LLM-based judge.
Parameters
expected_tone: str-
The desired tone (e.g.,
"professional","casual","formal"). indicators: dict[str, list[str]] | None = None- Optional mapping of tone names to indicator words/phrases. If not provided, uses built-in defaults for common tones.
Returns
Guard- A configured tone-checking guard (output-only).
Examples
bot = tb.ChatBot().guardrail(tb.tone_check("professional"))