Class PromptInjectionDetector.Builder

java.lang.Object
com.tnsai.quality.security.llm.PromptInjectionDetector.Builder
Enclosing class:
PromptInjectionDetector

public static class PromptInjectionDetector.Builder extends Object
Builder for PromptInjectionDetector.
  • 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 type
      regex - regex pattern
      confidence - confidence score (0.0 - 1.0)
      Returns:
      this builder
    • confidenceThreshold

      public PromptInjectionDetector.Builder confidenceThreshold(double threshold)
      Sets the confidence threshold for blocking.
      Parameters:
      threshold - threshold (0.0 - 1.0)
      Returns:
      this builder
    • throwOnDetection

      public PromptInjectionDetector.Builder throwOnDetection(boolean throwOnDetection)
      Enables throwing SecurityException on detection.
      Parameters:
      throwOnDetection - whether to throw
      Returns:
      this builder
    • build

      public PromptInjectionDetector build()
      Builds the detector.
      Returns:
      configured detector