Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement to CR_PromptText #141

Open
MokkaBoss1 opened this issue Mar 18, 2024 · 1 comment
Open

Improvement to CR_PromptText #141

MokkaBoss1 opened this issue Mar 18, 2024 · 1 comment

Comments

@MokkaBoss1
Copy link

Hi,

I have a suggestion to make to improve this node. I tested it and it seems to work fine. Basically it lets you put comments into a text box that do not carry forward to the output. Also I removed line breaks

image

The code for this is as follows:

import random
import re

class HashText:

def __init__(self):
    pass

@classmethod
def INPUT_TYPES(s):
    return {"required": {
        "prompt": ("STRING", {"default": "prompt", "multiline": True})
    }}

RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("Text",)
FUNCTION = "test"
CATEGORY = "MokkaBoss1"

def test(self, prompt): 
    pattern = r"#(.*?)#"
    clean_text = re.sub(pattern, '', prompt)
    clean_text2 = clean_text.replace("\n", "")
    prompt = clean_text2
    return (prompt, )

NODE_CLASS_MAPPINGS = {"HashText": HashText}
NODE_DISPLAY_NAME_MAPPINGS = {"HashText": "HashText"}

@MokkaBoss1
Copy link
Author

just realised you don't need the "import random" that was a cut and paste error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant