ChatBot.guardrail()
Add a guardrail to the chatbot’s validation pipeline.
Usage
ChatBot.guardrail(guard)Guards run in the order they are added. Input guards validate user messages before the LLM sees them. Output guards validate LLM responses before they are returned to the user. If any guard blocks a message, the pipeline short-circuits.
Parameters
guard: Guard-
A Guard instance, typically created by
@tb.guardrail, or one of the built-in guard factories (tb.no_pii(),tb.max_response_length(), etc.).
Returns
ChatBot- The same instance for method chaining.
Examples
import talk_box as tb
bot = (
tb.ChatBot()
.guardrail(tb.no_pii())
.guardrail(tb.max_response_length(500))
.guardrail(tb.disclaimer_required("Not financial advice."))
)