mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Merge branch 'staging' into wi-regex-keys
This commit is contained in:
		| @@ -2097,7 +2097,6 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll | |||||||
|  |  | ||||||
|     const newMessage = $(`#chat [mesid="${newMessageId}"]`); |     const newMessage = $(`#chat [mesid="${newMessageId}"]`); | ||||||
|     const isSmallSys = mes?.extra?.isSmallSys; |     const isSmallSys = mes?.extra?.isSmallSys; | ||||||
|     newMessage.data('isSystem', isSystem); |  | ||||||
|  |  | ||||||
|     if (isSmallSys === true) { |     if (isSmallSys === true) { | ||||||
|         newMessage.addClass('smallSysMes'); |         newMessage.addClass('smallSysMes'); | ||||||
| @@ -9351,14 +9350,9 @@ jQuery(async function () { | |||||||
|     else { |     else { | ||||||
|         $(document).on('pointerup', '.mes_copy', function () { |         $(document).on('pointerup', '.mes_copy', function () { | ||||||
|             if (this_chid !== undefined || selected_group) { |             if (this_chid !== undefined || selected_group) { | ||||||
|                 const message = $(this).closest('.mes'); |  | ||||||
|  |  | ||||||
|                 if (message.data('isSystem')) { |  | ||||||
|                     return; |  | ||||||
|                 } |  | ||||||
|                 try { |                 try { | ||||||
|                     var edit_mes_id = $(this).closest('.mes').attr('mesid'); |                     const messageId = $(this).closest('.mes').attr('mesid'); | ||||||
|                     var text = chat[edit_mes_id]['mes']; |                     const text = chat[messageId]['mes']; | ||||||
|                     navigator.clipboard.writeText(text); |                     navigator.clipboard.writeText(text); | ||||||
|                     toastr.info('Copied!', '', { timeOut: 2000 }); |                     toastr.info('Copied!', '', { timeOut: 2000 }); | ||||||
|                 } catch (err) { |                 } catch (err) { | ||||||
| @@ -9617,8 +9611,8 @@ jQuery(async function () { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         hideSwipeButtons(); |         hideSwipeButtons(); | ||||||
|         let oldScroll = $('#chat')[0].scrollTop; |         const oldScroll = chatElement[0].scrollTop; | ||||||
|         const clone = JSON.parse(JSON.stringify(chat[this_edit_mes_id])); // quick and dirty clone |         const clone = structuredClone(chat[this_edit_mes_id]); | ||||||
|         clone.send_date = Date.now(); |         clone.send_date = Date.now(); | ||||||
|         clone.mes = $(this).closest('.mes').find('.edit_textarea').val(); |         clone.mes = $(this).closest('.mes').find('.edit_textarea').val(); | ||||||
|  |  | ||||||
| @@ -9631,7 +9625,7 @@ jQuery(async function () { | |||||||
|  |  | ||||||
|         updateViewMessageIds(); |         updateViewMessageIds(); | ||||||
|         await saveChatConditional(); |         await saveChatConditional(); | ||||||
|         $('#chat')[0].scrollTop = oldScroll; |         chatElement[0].scrollTop = oldScroll; | ||||||
|         showSwipeButtons(); |         showSwipeButtons(); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2581,7 +2581,6 @@ async function checkWorldInfo(chat, maxContext) { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (entry.constant || buffer.isExternallyActivated(entry)) { |             if (entry.constant || buffer.isExternallyActivated(entry)) { | ||||||
|                 entry.content = substituteParams(entry.content); |  | ||||||
|                 activatedNow.add(entry); |                 activatedNow.add(entry); | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
| @@ -2674,7 +2673,9 @@ async function checkWorldInfo(chat, maxContext) { | |||||||
|                 continue; |                 continue; | ||||||
|             } else { console.debug(`uid:${entry.uid} passed probability check, inserting to prompt`); } |             } else { console.debug(`uid:${entry.uid} passed probability check, inserting to prompt`); } | ||||||
|  |  | ||||||
|             newContent += `${substituteParams(entry.content)}\n`; |             // Substitute macros inline, for both this checking and also future processing | ||||||
|  |             entry.content = substituteParams(entry.content); | ||||||
|  |             newContent += `${entry.content}\n`; | ||||||
|  |  | ||||||
|             if ((textToScanTokens + (await getTokenCountAsync(newContent))) >= budget) { |             if ((textToScanTokens + (await getTokenCountAsync(newContent))) >= budget) { | ||||||
|                 console.debug('WI budget reached, stopping'); |                 console.debug('WI budget reached, stopping'); | ||||||
| @@ -2707,7 +2708,7 @@ async function checkWorldInfo(chat, maxContext) { | |||||||
|             const text = newEntries |             const text = newEntries | ||||||
|                 .filter(x => !failedProbabilityChecks.has(x)) |                 .filter(x => !failedProbabilityChecks.has(x)) | ||||||
|                 .filter(x => !x.preventRecursion) |                 .filter(x => !x.preventRecursion) | ||||||
|                 .map(x => substituteParams(x.content)).join('\n'); |                 .map(x => x.content).join('\n'); | ||||||
|             buffer.addRecurse(text); |             buffer.addRecurse(text); | ||||||
|             allActivatedText = (text + '\n' + allActivatedText); |             allActivatedText = (text + '\n' + allActivatedText); | ||||||
|         } |         } | ||||||
| @@ -2742,6 +2743,11 @@ async function checkWorldInfo(chat, maxContext) { | |||||||
|         const regexDepth = entry.position === world_info_position.atDepth ? (entry.depth ?? DEFAULT_DEPTH) : null; |         const regexDepth = entry.position === world_info_position.atDepth ? (entry.depth ?? DEFAULT_DEPTH) : null; | ||||||
|         const content = getRegexedString(entry.content, regex_placement.WORLD_INFO, { depth: regexDepth, isMarkdown: false, isPrompt: true }); |         const content = getRegexedString(entry.content, regex_placement.WORLD_INFO, { depth: regexDepth, isMarkdown: false, isPrompt: true }); | ||||||
|  |  | ||||||
|  |         if (!content) { | ||||||
|  |             console.debug('Skipping adding WI entry to prompt due to empty content:', entry); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         switch (entry.position) { |         switch (entry.position) { | ||||||
|             case world_info_position.before: |             case world_info_position.before: | ||||||
|                 WIBeforeEntries.unshift(substituteParams(content)); |                 WIBeforeEntries.unshift(substituteParams(content)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user