Class PromptSafetyChecker
Detects common prompt injection patterns and attempts to override system instructions.
public sealed class PromptSafetyChecker
- Inheritance
-
PromptSafetyChecker
- Inherited Members
Constructors
PromptSafetyChecker(IEnumerable<(string Name, string Pattern)>)
Creates a PromptSafetyChecker with a custom set of named patterns.
public PromptSafetyChecker(IEnumerable<(string Name, string Pattern)> rules)
Parameters
rulesIEnumerable<(string Key, string Value)>Named regex patterns that indicate injection attempts.
Properties
Default
Creates a PromptSafetyChecker with the built-in ruleset.
public static PromptSafetyChecker Default { get; }
Property Value
Methods
Check(string)
Checks the given prompt for injection patterns.
public PromptSafetyResult Check(string prompt)
Parameters
promptstring
Returns
- PromptSafetyResult
A PromptSafetyResult indicating safety and any violations found.