Praison AI
Enterprise
Agents
Bot
Use Cases
University
Docs
Mini-project: Zero-regression release gate
Run
from praisonai import Agent, GuardrailConfig, GuardrailAction, RetryBackoffConfig, ScriptedModel, no_model_requests from praisonai.eval import Judge def check_policy(text: str) -> tuple[bool, str]: if 'sk-' in text: return False, 'Secret detected' if len(text.strip()) < 10: return False, 'Reply too short' return True, text guard = GuardrailConfig(validator=check_policy, max_retries=2, on_fail=GuardrailAction.RETRY) backoff = RetryBackoffConfig(base_delay=0.5, max_delay=10.0, jitter_ratio=0.2, max_retries=3) judge = Judge(criteria='Accurate, concise, and follows refund policy.') with no_model_requests(): agent = Agent( name='ReleaseCandidate', instructions='Answer refund questions concisely.', model=ScriptedModel([ScriptedModel.text('Refunds are issued within 30 days of purchase.')]), output='silent', ) reply = agent.start('What is your refund window?') ok, msg = guard.validator(reply) assert ok, msg print('Guardrail:', ok, '| Backoff retries:', backoff.max_retries, '| Judge ready:', bool(judge.criteria)) print('Release gate PASSED ->', reply)
Press Run. The result appears here.
Esc
Search in
All
Docs
University