mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Add user first and last prefixes for instruct
This commit is contained in:
		@@ -3611,6 +3611,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
 | 
			
		||||
    let chat2 = [];
 | 
			
		||||
    let continue_mag = '';
 | 
			
		||||
    const userMessageIndices = [];
 | 
			
		||||
    const lastUserMessageIndex = coreChat.findLastIndex(x => x.is_user);
 | 
			
		||||
 | 
			
		||||
    for (let i = coreChat.length - 1, j = 0; i >= 0; i--, j++) {
 | 
			
		||||
        if (main_api == 'openai') {
 | 
			
		||||
@@ -3629,6 +3630,11 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
 | 
			
		||||
            chat2[i] = formatMessageHistoryItem(coreChat[j], isInstruct, force_output_sequence.FIRST);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (lastUserMessageIndex >= 0 && j === lastUserMessageIndex && isInstruct) {
 | 
			
		||||
            // Reformat with the last input sequence (if any)
 | 
			
		||||
            chat2[i] = formatMessageHistoryItem(coreChat[j], isInstruct, force_output_sequence.LAST);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Do not suffix the message for continuation
 | 
			
		||||
        if (i === 0 && isContinue) {
 | 
			
		||||
            if (isInstruct) {
 | 
			
		||||
@@ -3654,7 +3660,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
 | 
			
		||||
            mes: power_user.instruct.user_alignment_message,
 | 
			
		||||
            is_user: true,
 | 
			
		||||
        };
 | 
			
		||||
        userAlignmentMessage = formatMessageHistoryItem(alignmentMessage, isInstruct, false);
 | 
			
		||||
        userAlignmentMessage = formatMessageHistoryItem(alignmentMessage, isInstruct, force_output_sequence.FIRST);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Call combined AN into Generate
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user