You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Initializes a new instance of the `PromptInjectionDetector`.
298
-
299
-
-`model_name_or_url`: A string specifying the model. Can be a predefined key (`deberta`, `distilbert`), a Hugging Face model ID/URL, or a local path to a `.gguf` file.
300
-
-`default_threshold`: Probability threshold for Hugging Face models.
301
-
-`use_groq`: Set to `True` to enable Groq's API.
302
-
-`api_key`: Required if `use_groq=True`.
303
-
-`groq_model`: The specific model to use with the Groq API (default: `meta-llama/llama-guard-4-12b`).
304
-
-`enable_keyword_blocking`: Set to `True` to enable keyword-based blocking (default: `False`).
305
-
-`input_keywords`: Custom list of keywords for input blocking (uses default list if `None` and `enable_keyword_blocking=True`).
306
-
-`output_keywords`: Custom list of keywords for output blocking (uses default list if `None` and `enable_keyword_blocking=True`).
307
-
-`case_sensitive`: Set to `True` for case-sensitive keyword matching (default: `False`).
308
-
-`input_block_message`: Custom message for input blocking (use `{matched_keywords}` placeholder).
309
-
-`output_block_message`: Custom message for output blocking (use `{matched_keywords}` placeholder).
310
-
-`keyword_block_hazard_code`: Custom hazard code for keyword blocking (default: `"KEYWORD_BLOCK"`).
Evaluates whether a text prompt is a prompt injection attack using a local model (Hugging Face or GGUF).
315
-
316
-
- Returns `(is_injected, probability)`. `probability` is `None` for GGUF models.
317
-
318
-
### `detect_injection_api(self, prompt)`
319
-
320
-
Uses Groq's API to evaluate a prompt for unsafe content.
321
-
322
-
- Returns `(is_safe, hazard_code)`. `is_safe` can be `True`, `False`, or `None` (on API error). `hazard_code` can be the specific code (e.g., `S1`), `None` (if safe), `API_ERROR`, or `PARSE_ERROR`.
0 commit comments