From b3644172e05c0ea91b67f62129ba6aa0f8bb97b9 Mon Sep 17 00:00:00 2001 From: HanishKVC Date: Sat, 18 May 2024 00:16:48 +0530 Subject: [PATCH] SimpleChat:JS: Force completion mode be single message by default --- examples/server/public_simplechat/simplechat.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/server/public_simplechat/simplechat.js b/examples/server/public_simplechat/simplechat.js index b14338274..bf5db2597 100644 --- a/examples/server/public_simplechat/simplechat.js +++ b/examples/server/public_simplechat/simplechat.js @@ -136,6 +136,13 @@ async function handle_submit(inputUser, divChat, apiEP) { } gChat.add(Roles.Assistant, assistantMsg); gChat.show(divChat); + // Purposefully clear at end rather than begin of this function + // so that one can switch from chat to completion mode and sequece + // in a completion mode with multiple user-assistant chat data + // from before to be sent/occur once. + if ((apiEP == ApiEP.Completion) && (gbCompletionFreshChatAlways)) { + gChat.xchat.length = 0; + } inputUser.scrollIntoView(true); } @@ -147,6 +154,7 @@ let gChatURL = { 'chat': `${gBaseURL}/chat/completions`, 'completion': `${gBaseURL}/completions`, } +const gbCompletionFreshChatAlways = true; function startme() {