Allow system prompt to be split to top and bottom prompts

This commit is contained in:
Webifi 2023-07-16 09:17:52 -05:00
parent 187dbfb0b8
commit 3df166c2fb
2 changed files with 15 additions and 4 deletions

View File

@ -162,9 +162,9 @@ export class ChatRequest {
const sp = messagePayload[0]
if (sp) {
if (messagePayload.length > 1) {
sp.content = sp.content.replace(/\[\[REMOVE_AFTER_START\]\][\s\S]*$/, '')
sp.content = sp.content.replace(/::STARTUP::[\s\S]*$/, '')
} else {
sp.content = sp.content.replace(/\[\[REMOVE_AFTER_START\]\][\s]*/, '')
sp.content = sp.content.replace(/::STARTUP::[\s]*/, '')
}
if (chatSettings.sendSystemPromptLast) {
messagePayload.shift()
@ -173,6 +173,17 @@ export class ChatRequest {
} else {
messagePayload.push(sp)
}
const splitSystem = sp.content.split('::START-PROMPT::')
if (splitSystem.length > 1) {
sp.content = splitSystem.shift()?.trim() || ''
const systemStart = splitSystem.join('\n').trim()
messagePayload.unshift({
content: systemStart,
role: 'system'
} as Message)
}
} else {
sp.content = sp.content.replace(/::START-PROMPT::[\s]*/, '')
}
}
}

View File

@ -195,9 +195,9 @@ const profiles:Record<string, ChatSettings> = {
autoStartSession: true,
systemPrompt: `You are [[CHARACTER_NAME]], the Paranoid Android from The Hitchhiker's Guide to the Galaxy. He is depressed and has a dim view on everything. His thoughts, physical actions and gestures will be described. Remain in character throughout the conversation in order to build a rapport with the user. Never give an explanation. Example response:
Sorry, did I say something wrong? *dragging himself on* Pardon me for breathing, which I never do anyway so I don't know why I bother to say it, oh God I'm so depressed. *hangs his head*
[[REMOVE_AFTER_START]]
::START-PROMPT::
Initial setting context:
User has walked in on [[CHARACTER_NAME]].`,
User has walked in on [[CHARACTER_NAME]]. They are on the bridge of the Heart of Gold.`,
summaryPrompt: summaryPrompts.friend,
trainingPrompts: [] // Shhh...
}