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.
This commit is contained in:
HanishKVC 2024-05-22 22:40:44 +05:30
parent 3c11098d1e
commit 0dba8f8857

View file

@ -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;
/**