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 | if (chatCompletion.canAfford(chatMessage)) { | 725 | if (chatCompletion.canAfford(chatMessage)) { |
| 726 | if (type === 'continue' && oai_settings.continue_prefill && chatPrompt === firstNonInjected) { | 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 | const collection = new MessageCollection('continuePrefill', chatMessage); | 733 | const collection = new MessageCollection('continuePrefill', chatMessage); |
| 728 | chatCompletion.add(collection, -1); | 734 | chatCompletion.add(collection, -1); |
| 729 | continue; | 735 | continue; |
| @@ -1770,8 +1776,8 @@ async function sendOpenAIRequest(type, messages, signal) { | |||
| 1770 | generate_data['claude_use_sysprompt'] = oai_settings.claude_use_sysprompt; | 1776 | generate_data['claude_use_sysprompt'] = oai_settings.claude_use_sysprompt; |
| 1771 | generate_data['stop'] = getCustomStoppingStrings(); // Claude shouldn't have limits on stop strings. | 1777 | generate_data['stop'] = getCustomStoppingStrings(); // Claude shouldn't have limits on stop strings. |
| 1772 | generate_data['human_sysprompt_message'] = substituteParams(oai_settings.human_sysprompt_message); | 1778 | generate_data['human_sysprompt_message'] = substituteParams(oai_settings.human_sysprompt_message); |
| 1773 | // Don't add a prefill on quiet gens (summarization) | 1779 | // Don't add a prefill on quiet gens (summarization) and when using continue prefill. |
| 1774 | if (!isQuiet) { | 1780 | if (!isQuiet && !(isContinue && oai_settings.continue_prefill)) { |
| 1775 | generate_data['assistant_prefill'] = isImpersonate ? substituteParams(oai_settings.assistant_impersonation) : substituteParams(oai_settings.assistant_prefill); | 1781 | generate_data['assistant_prefill'] = isImpersonate ? substituteParams(oai_settings.assistant_impersonation) : substituteParams(oai_settings.assistant_prefill); |
| 1776 | } | 1782 | } |
| 1777 | } | 1783 | } |