@@ -4178,6 +4178,25 @@ def concat(self, delimiter, text1, text2, text3, text4, text5):
41784178 text = delimiter .join (texts )
41794179 return (text ,)
41804180
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+
41814200class OobaPrompt :
41824201 @classmethod
41834202 def INPUT_TYPES (s ):
@@ -5390,6 +5409,7 @@ def save(self, model, vae, filename_prefix, clip=None, prompt=None, extra_pnginf
53905409 'SRFloatPromptInput' : SRFloatPromptInput ,
53915410 'TextPreserve' : TextPreserve ,
53925411 'TextConcat' : TextConcat ,
5412+ 'RemoveTextBetween' : RemoveTextBetween ,
53935413 'OobaPrompt' : OobaPrompt ,
53945414 'WildcardOobaPrompt' : WildcardOobaPrompt ,
53955415 'LMStudioPrompt' : LMStudioPrompt ,
@@ -5465,6 +5485,7 @@ def save(self, model, vae, filename_prefix, clip=None, prompt=None, extra_pnginf
54655485 'SRFloatPromptInput' : 'SR Float Prompt Input (Mikey)' ,
54665486 'TextPreserve' : 'Text Preserve (Mikey)' ,
54675487 'TextConcat' : 'Text Concat (Mikey)' ,
5488+ 'RemoveTextBetween' : 'Remove Text Between (Mikey)' ,
54685489 'OobaPrompt' : 'OobaPrompt (Mikey)' ,
54695490 'WildcardOobaPrompt' : 'Wildcard OobaPrompt (Mikey)' ,
54705491 'LMStudioPrompt' : 'LM Studio Prompt (Mikey)' ,
0 commit comments