diff --git a/examples/server/public_simplechat/simplechat.js b/examples/server/public_simplechat/simplechat.js index 35a74109e..1211628e6 100644 --- a/examples/server/public_simplechat/simplechat.js +++ b/examples/server/public_simplechat/simplechat.js @@ -98,11 +98,21 @@ class SimpleChat { */ async function handle_submit(inputSystem, inputUser, divChat, apiEP) { + let sysPrompt = inputSystem.value; if (gChat.xchat.length == 0) { - let sysPrompt = inputSystem.value; if (sysPrompt.length > 0) { gChat.add(Roles.System, sysPrompt); } + } else { + if (sysPrompt.length > 0) { + if (gChat.xchat[0].role !== Roles.System) { + console.error("ERRR:HandleSubmit:You need to specify system prompt before any user query, ignoring..."); + } else { + if (gChat.xchat[0].content !== sysPrompt) { + console.error("ERRR:HandleSubmit:You cant change system prompt, mid way through, ignoring..."); + } + } + } } let content = inputUser?.value;