I receive text from response:
const prompt = "Generate something in 1:1 format for `Birthday` in an `cheerful, celebratory` mood. The image should be created in an `Graffiti` style. The text `Happy Birthday!` is at the top. At the bottom is the lettering: `Liam`. Graphic elements should visually reflect the terms `stars, balloons`.";
and have string without values ready:
const sub = "Generate something in 1:1 format for in an mood. The image should be created in an style. The text is at the top. At the bottom is the lettering:. Graphic elements should visually reflect the terms.";
Is there a way to extract marked words (which will be used to prefil some input fields)?
I managed to do that only if the words are quoted like:
const sub = "Generate something in 1:1 format for in an mood. The image should be created in an style. The text is at the top. At the bottom is the lettering:. Graphic elements should visually reflect the terms."
const prompt = "Generate something in 1:1 format for 'Birthday' in an 'cheerful, celebratory' mood. The image should be created in an 'Graffiti' style. The text 'Happy Birthday!' is at the top. At the bottom is the lettering: 'Liam'. Graphic elements should visually reflect the terms 'stars, balloons'."
const resolvePrompt = (prompt, sub) => {
return prompt
.replaceAll(".", "")
.split(" ")
.filter((wd) => !sub.includes(wd))
.join("")
.split("''");
};
console.log(resolvePrompt(prompt, sub))