Merge pull request #2830 from nyxkrage/patch-2 Append continuation message after prefill when using "Continue Prefill" with Claude

6ba60e8f60251373c4a07593a09dd99eb16f7d56

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
1 files changed, +8 -2Showing whitespace changes
public/scripts/openai.js+8 -2
@@ -724,6 +724,12 @@ async function populateChatHistory(messages, prompts, chatCompletion, type = nul
724724
725725 if (chatCompletion.canAfford(chatMessage)) {
726726 if (type === 'continue' && oai_settings.continue_prefill && chatPrompt === firstNonInjected) {
727+ // in case we are using continue_prefill and the latest message is an assistant message, we want to prepend the users assistant prefill on the message
728+ if (chatPrompt.role === 'assistant') {
729+ const collection = new MessageCollection('continuePrefill', new Message(chatMessage.role, substituteParams(oai_settings.assistant_prefill + '\n\n') + chatMessage.content, chatMessage.identifier));
730+ chatCompletion.add(collection, -1);
731+ continue;
732+ }
727733 const collection = new MessageCollection('continuePrefill', chatMessage);
728734 chatCompletion.add(collection, -1);
729735 continue;
@@ -1770,8 +1776,8 @@ async function sendOpenAIRequest(type, messages, signal) {
17701776 generate_data['claude_use_sysprompt'] = oai_settings.claude_use_sysprompt;
17711777 generate_data['stop'] = getCustomStoppingStrings(); // Claude shouldn't have limits on stop strings.
17721778 generate_data['human_sysprompt_message'] = substituteParams(oai_settings.human_sysprompt_message);
17731779 // Don't add a prefill on quiet gens (summarization) and when using continue prefill.
17741780 if (!isQuiet && !(isContinue && oai_settings.continue_prefill)) {
17751781 generate_data['assistant_prefill'] = isImpersonate ? substituteParams(oai_settings.assistant_impersonation) : substituteParams(oai_settings.assistant_prefill);
17761782 }
17771783 }