add Simple Remove Think

This commit is contained in:
KLL535
2025-02-23 18:37:10 +03:00
parent 2ea40de42e
commit 7737691379
2 changed files with 30 additions and 0 deletions
+1
View File
@@ -1,4 +1,5 @@
# nightly
- Add `Simple Remove Think` node
# v1.0.6
- Add `Simple Auto Bypass` node
- Fix "always run" mode for `Simple Lora Loader`
+29
View File
@@ -902,6 +902,33 @@ class AutoBypassNode:
################################
class RemoveThinkNode:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"text": ("STRING", {"multiline": True, "forceInput": True}),
}
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("cleaned_text",)
FUNCTION = "process"
CATEGORY = "📚 SimpleButcher"
DESCRIPTION = "Remove <think>...</think> section in text"
def process(self, text):
# remove <think>...</think>
cleaned = re.sub(r'<think>.*?</think>', '', text, flags=re.DOTALL)
cleaned = '\n'.join([line for line in cleaned.split('\n') if line.strip()])
return (cleaned,)
################################
NODE_CLASS_MAPPINGS = {
"Simple Load Line From Text File": SimpleLoadLineFromTextFile,
"Simple Extract Lora From Text": SimpleExtractLoraFromText,
@@ -910,6 +937,7 @@ NODE_CLASS_MAPPINGS = {
"Simple Load Image With Metadata": SimpleLoadImageWithMetadataString,
"Simple Load Images from Dir": SimpleLoadImagesFromDir,
"Simple Auto Bypass": AutoBypassNode,
"Simple Remove Think": RemoveThinkNode,
}
NODE_DISPLAY_NAME_MAPPINGS = {
@@ -920,5 +948,6 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"Simple Load Image With Metadata": "Simple Load Image With Metadata 📚",
"Simple Load Images From Dir": "Simple Load Images From Dir 📚",
"Simple Auto Bypass": "Simple Auto Bypass 📚",
"Simple Remove Think": "Simple Remove Think 📚",
}