@@ -4178,6 +4178,25 @@ def concat(self, delimiter, text1, text2, text3, text4, text5):
4178
4178
text = delimiter .join (texts )
4179
4179
return (text ,)
4180
4180
4181
+ class RemoveTextBetween :
4182
+ # removes text between two strings
4183
+ # default start is <think> and end is </think>
4184
+ @classmethod
4185
+ def INPUT_TYPES (cls ):
4186
+ return {'required' : {'text' : ('STRING' , {'multiline' : True , 'default' : 'Input Text Here' , 'dynamicPrompts' : False })},
4187
+ 'optional' : {'start' : ('STRING' , {'default' : '<think>' }),
4188
+ 'end' : ('STRING' , {'default' : '</think>' })}}
4189
+
4190
+ RETURN_TYPES = ('STRING' ,)
4191
+ FUNCTION = 'remove'
4192
+ CATEGORY = 'Mikey/Text'
4193
+
4194
+ def remove (self , text , start , end ):
4195
+ # search and replace
4196
+ # remove text between start and end
4197
+ text = re .sub (re .escape (start ) + '.*?' + re .escape (end ), '' , text , flags = re .DOTALL ).lstrip ().rstrip ()
4198
+ return (text ,)
4199
+
4181
4200
class OobaPrompt :
4182
4201
@classmethod
4183
4202
def INPUT_TYPES (s ):
@@ -5390,6 +5409,7 @@ def save(self, model, vae, filename_prefix, clip=None, prompt=None, extra_pnginf
5390
5409
'SRFloatPromptInput' : SRFloatPromptInput ,
5391
5410
'TextPreserve' : TextPreserve ,
5392
5411
'TextConcat' : TextConcat ,
5412
+ 'RemoveTextBetween' : RemoveTextBetween ,
5393
5413
'OobaPrompt' : OobaPrompt ,
5394
5414
'WildcardOobaPrompt' : WildcardOobaPrompt ,
5395
5415
'LMStudioPrompt' : LMStudioPrompt ,
@@ -5465,6 +5485,7 @@ def save(self, model, vae, filename_prefix, clip=None, prompt=None, extra_pnginf
5465
5485
'SRFloatPromptInput' : 'SR Float Prompt Input (Mikey)' ,
5466
5486
'TextPreserve' : 'Text Preserve (Mikey)' ,
5467
5487
'TextConcat' : 'Text Concat (Mikey)' ,
5488
+ 'RemoveTextBetween' : 'Remove Text Between (Mikey)' ,
5468
5489
'OobaPrompt' : 'OobaPrompt (Mikey)' ,
5469
5490
'WildcardOobaPrompt' : 'Wildcard OobaPrompt (Mikey)' ,
5470
5491
'LMStudioPrompt' : 'LM Studio Prompt (Mikey)' ,
0 commit comments