Interface for executing multiple guardrails in sequence or parallel.

const chain = new GuardrailChain({
guardrails: [piiGuardrail, injectionGuardrail, topicGuardrail],
stopOnFirstFailure: true,
parallel: false,
});

const result = await chain.execute({
content: userInput,
contentType: 'input',
userId: '123',
});

if (!result.passed) {
throw new Error(`Guardrail violations: ${result.totalViolations}`);
}
interface GuardrailChain {
    config: GuardrailChainConfig;
    execute(context: GuardrailContext): Promise<GuardrailChainResult>;
    add(guardrail: Guardrail): void;
    remove(name: string): boolean;
    list(): Guardrail[];
}

Methods

Properties

Methods

  • Remove a guardrail from the chain

    Parameters

    • name: string

      Name of guardrail to remove

    Returns boolean

    true if removed

Properties

Configuration for this chain