Merge pull request #2830 from nyxkrage/patch-2 Append continuation message after prefill when using "Continue Prefill" with Claude
Signed| @@ -724,6 +724,12 @@ async function populateChatHistory(messages, prompts, chatCompletion, type = nul | ||
| 724 | 724 | |
| 725 | 725 | if (chatCompletion.canAfford(chatMessage)) { |
| 726 | 726 | 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 | + } | |
| 727 | 733 | const collection = new MessageCollection('continuePrefill', chatMessage); |
| 728 | 734 | chatCompletion.add(collection, -1); |
| 729 | 735 | continue; |
| @@ -1770,8 +1776,8 @@ async function sendOpenAIRequest(type, messages, signal) { | ||
| 1770 | 1776 | generate_data['claude_use_sysprompt'] = oai_settings.claude_use_sysprompt; |
| 1771 | 1777 | generate_data['stop'] = getCustomStoppingStrings(); // Claude shouldn't have limits on stop strings. |
| 1772 | 1778 | generate_data['human_sysprompt_message'] = substituteParams(oai_settings.human_sysprompt_message); |
| 1773 | 1779 | // Don't add a prefill on quiet gens (summarization) and when using continue prefill. |
| 1774 | 1780 | if (!isQuiet && !(isContinue && oai_settings.continue_prefill)) { |
| 1775 | 1781 | generate_data['assistant_prefill'] = isImpersonate ? substituteParams(oai_settings.assistant_impersonation) : substituteParams(oai_settings.assistant_prefill); |
| 1776 | 1782 | } |
| 1777 | 1783 | } |