mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #1517 from LenAnderson/firstIncludedMessageId
Add macro for first included message in context
This commit is contained in:
@ -2017,6 +2017,20 @@ function getLastMessageId() {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ID of the first message included in the context.
|
||||||
|
* @returns {string} The ID of the first message in the context.
|
||||||
|
*/
|
||||||
|
function getFirstIncludedMessageId() {
|
||||||
|
const index = document.querySelector('.lastInContext')?.getAttribute('mesid');
|
||||||
|
|
||||||
|
if (!isNaN(index) && index >= 0) {
|
||||||
|
return String(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last message in the chat.
|
* Returns the last message in the chat.
|
||||||
* @returns {string} The last message in the chat.
|
* @returns {string} The last message in the chat.
|
||||||
@ -2119,6 +2133,7 @@ function substituteParams(content, _name1, _name2, _original, _group, _replaceCh
|
|||||||
content = content.replace(/{{group}}/gi, _group);
|
content = content.replace(/{{group}}/gi, _group);
|
||||||
content = content.replace(/{{lastMessage}}/gi, getLastMessage());
|
content = content.replace(/{{lastMessage}}/gi, getLastMessage());
|
||||||
content = content.replace(/{{lastMessageId}}/gi, getLastMessageId());
|
content = content.replace(/{{lastMessageId}}/gi, getLastMessageId());
|
||||||
|
content = content.replace(/{{firstIncludedMessageId}}/gi, getFirstIncludedMessageId());
|
||||||
content = content.replace(/{{lastSwipeId}}/gi, getLastSwipeId());
|
content = content.replace(/{{lastSwipeId}}/gi, getLastSwipeId());
|
||||||
content = content.replace(/{{currentSwipeId}}/gi, getCurrentSwipeId());
|
content = content.replace(/{{currentSwipeId}}/gi, getCurrentSwipeId());
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<li><tt>{{char}}</tt> – the Character's name</li>
|
<li><tt>{{char}}</tt> – the Character's name</li>
|
||||||
<li><tt>{{lastMessage}}</tt> - the text of the latest chat message.</li>
|
<li><tt>{{lastMessage}}</tt> - the text of the latest chat message.</li>
|
||||||
<li><tt>{{lastMessageId}}</tt> – index # of the latest chat message. Useful for slash command batching.</li>
|
<li><tt>{{lastMessageId}}</tt> – index # of the latest chat message. Useful for slash command batching.</li>
|
||||||
|
<li><tt>{{firstIncludedMessageId}}</tt> - the ID of the first message included in the context. Requires generation to be ran at least once in the current session.</li>
|
||||||
<li><tt>{{currentSwipeId}}</tt> – the 1-based ID of the current swipe in the last chat message. Empty string if the last message is user or prompt-hidden.</li>
|
<li><tt>{{currentSwipeId}}</tt> – the 1-based ID of the current swipe in the last chat message. Empty string if the last message is user or prompt-hidden.</li>
|
||||||
<li><tt>{{lastSwipeId}}</tt> – the number of swipes in the last chat message. Empty string if the last message is user or prompt-hidden.</li>
|
<li><tt>{{lastSwipeId}}</tt> – the number of swipes in the last chat message. Empty string if the last message is user or prompt-hidden.</li>
|
||||||
<li><tt>{{// (note)}}</tt> – you can leave a note here, and the macro will be replaced with blank content. Not visible for the AI.</li>
|
<li><tt>{{// (note)}}</tt> – you can leave a note here, and the macro will be replaced with blank content. Not visible for the AI.</li>
|
||||||
|
Reference in New Issue
Block a user