UNPKG

@sisu-ai/mw-guardrails

Version:

Policy guardrails to short-circuit unsafe input.

9 lines (8 loc) 252 B
export const withGuardrails = (policy) => async (ctx, next) => { const violation = await policy(ctx.input ?? ''); if (violation) { ctx.messages.push({ role: 'assistant', content: violation }); return; } await next(); };