diff --git a/public/scripts/openai.js b/public/scripts/openai.js index d636ca36a..852994f5a 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -183,6 +183,13 @@ function setOpenAIMessageExamples(mesExamplesArray) { // remove {Example Dialogue:} and replace \r\n with just \n let replaced = item.replace(//i, "{Example Dialogue:}").replace(/\r/gm, ''); let parsed = parseExampleIntoIndividual(replaced); + + // Discard example dialogue if there's not a single bot message in it + if (parsed.findIndex(x => x.name == "example_assistant") === -1) { + console.warn('Example dialogue without bot reply discarded:', replaced); + parsed = []; + } + // add to the example message blocks array openai_msgs_example.push(parsed); }