🛡️ Text Prompt Blocker:
The TextPromptBlocker is a security-focused node designed for ComfyUI that helps filter or block prompts containing prohibited words or their variations. Its primary purpose is to ensure that any text input adheres to specified content guidelines by detecting and managing the presence of undesirable terms. This node is particularly beneficial for maintaining content safety and compliance, as it can automatically identify and handle prompts that include sensitive or inappropriate language. By offering both hard and soft blocking modes, it provides flexibility in how detected issues are managed, either by halting the workflow or by allowing it to continue with modifications. The TextPromptBlocker is an essential tool for users who need to enforce strict content policies in their AI-generated outputs.
🛡️ Text Prompt Blocker Input Parameters:
prompt
The prompt parameter is the text input that you want to validate against the list of blocked words. It is a multiline string, allowing for comprehensive text entries. This parameter is crucial as it is the primary content being analyzed for prohibited terms. There is no specific minimum or maximum length, but it defaults to an empty string.
blocked_words
The blocked_words parameter is a multiline string that contains a comma-separated list of words that are considered prohibited. This list serves as the basis for filtering the prompt. By default, it includes terms like "child," "kid," "baby," and others related to underage themes. This parameter is essential for defining what constitutes inappropriate content.
case_sensitive
The case_sensitive parameter is a boolean that determines whether the word detection should consider case differences. If set to True, the node will differentiate between uppercase and lowercase letters, while False (the default) will treat them as equivalent. This setting impacts the sensitivity of the word detection process.
hard_block
The hard_block parameter is a boolean that specifies the blocking mode. When True, the node will raise an exception and stop the workflow if a prohibited word is detected, ensuring strict enforcement. If False, it will return an empty string but allow the workflow to continue, providing a softer approach. The default is True.
detect_contained
The detect_contained parameter is a boolean that indicates whether the node should detect prohibited words within compound words. When True (the default), it will identify words even if they are part of larger terms. If False, only exact matches will be detected, which can reduce false positives.
expand_variations
The expand_variations parameter is a boolean that controls whether the node should automatically expand the list of blocked words to include variations. When True (the default), it increases the likelihood of detecting prohibited content by considering different forms of the words. If False, only the exact words in the list are checked.
🛡️ Text Prompt Blocker Output Parameters:
original_prompt
The original_prompt output returns the initial text input provided to the node. This output is useful for reference and comparison, especially when analyzing the results of the prompt validation process.
status
The status output provides a string indicating the result of the prompt analysis. It will either confirm that no prohibited words were detected or specify the number of such words found. This output is crucial for understanding the outcome of the validation and any necessary actions.
detected_words
The detected_words output lists the prohibited words that were found in the prompt, limited to the first ten to avoid overwhelming the user. This output helps identify specific issues within the text and guides any required modifications.
🛡️ Text Prompt Blocker Usage Tips:
- Use the
hard_blockmode for strict content enforcement when you need to ensure that no prohibited words are present in the final output. - Enable
expand_variationsto catch more variations of prohibited words, which is useful for comprehensive content filtering. - Utilize the
TextPromptBlockerPreviewnode for testing and debugging purposes to see what words would be detected without actually blocking the prompt.
🛡️ Text Prompt Blocker Common Errors and Solutions:
🚫 PROMPT BLOQUEADO
- Explanation: This error occurs when a prohibited word is detected in the prompt while the
hard_blockmode is enabled, causing the workflow to stop. - Solution: Review the prompt and remove or replace the detected prohibited words. Alternatively, switch to
soft_blockmode if stopping the workflow is not desired.
No se detectaron palabras prohibidas
- Explanation: This message indicates that no prohibited words were found in the prompt, and it is considered clean.
- Solution: No action is needed as the prompt meets the content guidelines.
