Package com.tnsai.quality.security.llm
Class PromptInjectionDetector.Builder
java.lang.Object
com.tnsai.quality.security.llm.PromptInjectionDetector.Builder
- Enclosing class:
PromptInjectionDetector
Builder for PromptInjectionDetector.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPattern(InjectionDetectionResult.InjectionType type, String regex, double confidence) Adds a custom detection pattern.build()Builds the detector.confidenceThreshold(double threshold) Sets the confidence threshold for blocking.throwOnDetection(boolean throwOnDetection) Enables throwing SecurityException on detection.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
addPattern
public PromptInjectionDetector.Builder addPattern(InjectionDetectionResult.InjectionType type, String regex, double confidence) Adds a custom detection pattern.- Parameters:
type- injection typeregex- regex patternconfidence- confidence score (0.0 - 1.0)- Returns:
- this builder
-
confidenceThreshold
Sets the confidence threshold for blocking.- Parameters:
threshold- threshold (0.0 - 1.0)- Returns:
- this builder
-
throwOnDetection
Enables throwing SecurityException on detection.- Parameters:
throwOnDetection- whether to throw- Returns:
- this builder
-
build
Builds the detector.- Returns:
- configured detector
-