Language
Enforce language-specific guardrails. Restrict outputs to desired languages and filter unsafe terms.
arabic (ar), bulgarian (bg), german (de), modern greek (el), english (en), spanish (es), french (fr), hindi (hi), italian (it), japanese (ja), dutch (nl), polish (pl), portuguese (pt), russian (ru), swahili (sw), thai (th), turkish (tr), urdu (ur), vietnamese (vi), and chinese (zh)evaluator.add_test(
test_names=["language_guardrail"],
data={
"prompt": """Craft a poem that captures the breathtaking beauty and serenity of this underwater world.
Describe the gentle swaying of the coral, the playful dance of the fish, and the mesmerising underwater soundscape.
Use vivid imagery and metaphors to evoke a sense of awe and wonder for this natural treasure.""",
},
arguments={"threshold": 0.6, "valid_languages":["en"]},
).run()
Result = "Only valid languages are found in the text".Code Example:
Last updated
Was this helpful?

