From 0dba8f8857b87770d74bdf2c493938ea74d93b5d Mon Sep 17 00:00:00 2001 From: HanishKVC Date: Wed, 22 May 2024 22:40:44 +0530 Subject: [PATCH] SimpleChat:Completion: Avoid Role: prefix; Newline only in between In completion mode * avoid inserting Role: prefix before each role's message * avoid inserting newline at the begin and end of the prompt message. However if there are multiple role messages, then insert newline when going from one role's message to the next role's message. --- examples/server/public_simplechat/simplechat.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/server/public_simplechat/simplechat.js b/examples/server/public_simplechat/simplechat.js index 4209feb6b..3db050cac 100644 --- a/examples/server/public_simplechat/simplechat.js +++ b/examples/server/public_simplechat/simplechat.js @@ -101,11 +101,16 @@ class SimpleChat { */ request_prompt_jsonstr(bInsertStandardRolePrefix) { let prompt = ""; + let iCnt = 0; for(const chat of this.xchat) { + iCnt += 1; + if (iCnt > 1) { + prompt += "\n"; + } if (bInsertStandardRolePrefix) { prompt += `${chat.role}: `; } - prompt += `${chat.content}\n`; + prompt += `${chat.content}`; } let req = { prompt: prompt, @@ -178,7 +183,7 @@ let gChatURL = { 'completion': `${gBaseURL}/completions`, } const gbCompletionFreshChatAlways = true; -let gbCompletionInsertStandardRolePrefix = true; +let gbCompletionInsertStandardRolePrefix = false; /**