Prevent generating bad replacement regex

This commit is contained in:
pythongosssss 2023-04-15 10:29:32 +01:00
parent 0ecef1b4e8
commit 855442e5b1

View File

@ -131,6 +131,7 @@ export async function importA1111(graph, parameters) {
}
function replaceEmbeddings(text) {
if(!embeddings.length) return text;
return text.replaceAll(
new RegExp(
"\\b(" + embeddings.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("\\b|\\b") + ")\\b",