Standard implementation of guardrail chain.

Executes multiple guardrails in sequence or parallel and aggregates results.

const chain = new StandardGuardrailChain({
guardrails: [
new PIIGuardrail(),
new PromptInjectionGuardrail(),
new TopicFilterGuardrail({ allowedTopics: ['support', 'sales'] })
],
stopOnFirstFailure: true,
parallel: false,
});

const result = await chain.execute({
content: 'My SSN is 123-45-6789',
contentType: 'input',
});

console.log(result.passed); // false
console.log(result.totalViolations); // 1

Implements

  • GuardrailChain

Constructors

Methods

Properties

Constructors

Methods

  • Execute all guardrails against content

    Parameters

    • context: GuardrailContext

      Evaluation context

    Returns Promise<GuardrailChainResult>

    Aggregated result

  • Remove a guardrail from the chain

    Parameters

    • name: string

      Name of guardrail to remove

    Returns boolean

    true if removed

Properties

config: GuardrailChainConfig