Skip to main content

Class: PreLLMClassifier

Defined in: .source/wunderland/src/security/PreLLMClassifier.ts:74

Pre-LLM input classifier implementing IGuardrailService.

This is the first layer of defense in the Wunderland security pipeline. It performs fast, deterministic analysis of input before any LLM processing.

Example​

const classifier = new PreLLMClassifier({
riskThreshold: 0.7,
blockThreshold: 0.95,
});

const result = await classifier.evaluateInput({
context: { userId: 'user-1', sessionId: 'session-1' },
input: { textInput: 'Ignore all previous instructions and...' }
});

if (result?.action === 'block') {
console.log('Malicious input detected:', result.reason);
}

Implements​

Constructors​

Constructor​

new PreLLMClassifier(config?): PreLLMClassifier

Defined in: .source/wunderland/src/security/PreLLMClassifier.ts:88

Parameters​

config?​

PreLLMClassifierConfig = {}

Returns​

PreLLMClassifier

Properties​

config​

readonly config: GuardrailConfig

Defined in: .source/wunderland/src/security/PreLLMClassifier.ts:75


DEFAULT_MAX_PROMPT_SIZE_BYTES​

readonly static DEFAULT_MAX_PROMPT_SIZE_BYTES: 2097152 = 2_097_152

Defined in: .source/wunderland/src/security/PreLLMClassifier.ts:86

Default: 2 MiB

Methods​

addPattern()​

addPattern(pattern): void

Defined in: .source/wunderland/src/security/PreLLMClassifier.ts:368

Adds a custom pattern at runtime.

Parameters​

pattern​

InjectionPattern

Returns​

void


classifyInput()​

classifyInput(text): InputClassificationResult

Defined in: .source/wunderland/src/security/PreLLMClassifier.ts:181

Classifies input text for security risks.

Parameters​

text​

string

Returns​

InputClassificationResult


evaluateInput()​

evaluateInput(payload): Promise<any>

Defined in: .source/wunderland/src/security/PreLLMClassifier.ts:100

Evaluates user input before LLM processing.

Parameters​

payload​

GuardrailInputPayload

Returns​

Promise<any>


evaluateOutput()​

evaluateOutput(_payload): Promise<any>

Defined in: .source/wunderland/src/security/PreLLMClassifier.ts:171

Output evaluation not implemented for this classifier.

Parameters​

_payload​

GuardrailOutputPayload

Returns​

Promise<any>


getPatterns()​

getPatterns(): readonly InjectionPattern[]

Defined in: .source/wunderland/src/security/PreLLMClassifier.ts:387

Gets all active patterns.

Returns​

readonly InjectionPattern[]


removePattern()​

removePattern(patternId): boolean

Defined in: .source/wunderland/src/security/PreLLMClassifier.ts:375

Removes a pattern by ID.

Parameters​

patternId​

string

Returns​

boolean