Problem in node ‘Basic LLM Chain‘ Single '}' in template. Can't escape

Woohoo! Made it through the bugging output by replacing all curlies with double curlies! Thanks to this stackoverflow → f-string: single '}' is not allowed Python SPARQL Query problem - Stack Overflow. Thx for your help, mate

// Escape curly braces
function replace_braces(text) {
    return text.replace(/{/g, '{{').replace(/}/g, '}}');
}

// Loop over input items and add a new field called 'myNewField' to the JSON of each one
for (const item of $input.all()) { 
  item.json.text = replace_braces(item.json.text);
}

return $input.all();
2 Likes