Files
Gili Ben Shahar 09a3a40d6e fix: resolve ComfyUI Nodes 2.0 compatibility issues
- Fix MRO conflict in SaveAudioPlus by removing multiple inheritance
- Convert nodes from comfy_api to traditional ComfyUI structure
- Update nano_banana_multi_input.py to use instance methods instead of class methods
- Convert concat_string.py and filter_string.py to traditional INPUT_TYPES pattern
- Replace __init__.py extension system with traditional NODE_CLASS_MAPPINGS
- Remove comfy_api imports that were causing compatibility issues with Nodes 2.0
- All nodes now work with both legacy and Nodes 2.0 systems

Resolves: Cannot create consistent method resolution order (MRO) error
Resolves: comfy_api import issues causing node loading failures
2025-12-07 12:28:17 +07:00

53 lines
1.7 KiB
Python

"""Node for filtering strings based on a wordlist in ComfyUI."""
class FilterString:
"""Node for checking if a given string appears in a list of strings and returning a filter word if true."""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"in_question": ("STRING", {"default": "", "multiline": False}),
"wordlist": ("STRING", {"default": "", "multiline": True}),
"safeword": ("STRING", {"default": "", "multiline": True}),
}
}
RETURN_TYPES = ("STRING",)
FUNCTION = "filter_string"
CATEGORY = "klinter"
def filter_string(self, in_question: str, wordlist: str, safeword: str):
"""Check if a string exists in a wordlist and return either the safeword or original string.
Args:
in_question: The string to search for
wordlist: Space-separated list of words to search in
safeword: Word to return if in_question is found in wordlist
Returns:
tuple: Either safeword or in_question depending on if in_question is in wordlist
"""
try:
# Convert the wordlist string into a list of words
words = wordlist.split()
# Check if in_question is in the list of words
result = safeword if in_question in words else in_question
return (result,)
except Exception as e:
print(f"Error in filter_string: {str(e)}")
return (in_question,)
# Register the node
NODE_CLASS_MAPPINGS = {
"filter": FilterString
}
NODE_DISPLAY_NAME_MAPPINGS = {
"filter": "Filter String - klinter"
}
# Export the class
__all__ = ['FilterString']