mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-12 09:26:33 +01:00
Merge pull request #1840 from Wolfsblvt/slash-commands-menu-actions-allow-custom-prompts
Extend impersonate/continue/regenerate with possible custom prompts (via slash commands and popup menu)
This commit is contained in:
commit
79ba026486
@ -7873,9 +7873,9 @@ async function importFromURL(items, files) {
|
||||
}
|
||||
}
|
||||
|
||||
async function doImpersonate() {
|
||||
async function doImpersonate(_, prompt) {
|
||||
$('#send_textarea').val('');
|
||||
$('#option_impersonate').trigger('click', { fromSlashCommand: true });
|
||||
$('#option_impersonate').trigger('click', { fromSlashCommand: true, additionalPrompt: prompt });
|
||||
}
|
||||
|
||||
async function doDeleteChat() {
|
||||
@ -8691,6 +8691,13 @@ jQuery(async function () {
|
||||
const fromSlashCommand = customData?.fromSlashCommand || false;
|
||||
var id = $(this).attr('id');
|
||||
|
||||
// Check whether a custom prompt was provided via custom data (for example through a slash command)
|
||||
const additionalPrompt = customData?.additionalPrompt?.trim() || undefined;
|
||||
const buildOrFillAdditionalArgs = (args = {}) => ({
|
||||
...args,
|
||||
...(additionalPrompt !== undefined && { quiet_prompt: additionalPrompt, quietToLoud: true }),
|
||||
});
|
||||
|
||||
if (id == 'option_select_chat') {
|
||||
if ((selected_group && !is_group_generating) || (this_chid !== undefined && !is_send_press) || fromSlashCommand) {
|
||||
await displayPastChats();
|
||||
@ -8726,7 +8733,7 @@ jQuery(async function () {
|
||||
}
|
||||
else {
|
||||
is_send_press = true;
|
||||
Generate('regenerate');
|
||||
Generate('regenerate', buildOrFillAdditionalArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8734,14 +8741,14 @@ jQuery(async function () {
|
||||
else if (id == 'option_impersonate') {
|
||||
if (is_send_press == false || fromSlashCommand) {
|
||||
is_send_press = true;
|
||||
Generate('impersonate');
|
||||
Generate('impersonate', buildOrFillAdditionalArgs());
|
||||
}
|
||||
}
|
||||
|
||||
else if (id == 'option_continue') {
|
||||
if (is_send_press == false || fromSlashCommand) {
|
||||
is_send_press = true;
|
||||
Generate('continue');
|
||||
Generate('continue', buildOrFillAdditionalArgs());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1168,7 +1168,7 @@ async function openChat(id) {
|
||||
await reloadCurrentChat();
|
||||
}
|
||||
|
||||
function continueChatCallback() {
|
||||
function continueChatCallback(_, prompt) {
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100);
|
||||
@ -1179,7 +1179,7 @@ function continueChatCallback() {
|
||||
|
||||
// Prevent infinite recursion
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#option_continue').trigger('click', { fromSlashCommand: true });
|
||||
$('#option_continue').trigger('click', { fromSlashCommand: true, additionalPrompt: prompt });
|
||||
}, 1);
|
||||
|
||||
return '';
|
||||
|
Loading…
Reference in New Issue
Block a user