Table of Contents

Class PromptSafetyChecker

Namespace
JD.AI.Core.Security
Assembly
JD.AI.Core.dll

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

rules IEnumerable<(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

PromptSafetyChecker

Methods

Check(string)

Checks the given prompt for injection patterns.

public PromptSafetyResult Check(string prompt)

Parameters

prompt string

Returns

PromptSafetyResult

A PromptSafetyResult indicating safety and any violations found.