mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Idle Response / Continuous Generation (#1132)
* Initial idle stuff * Much closer, can now quietly send as user to get a char response. * Tweaks * Better, reset the count of getting a message back, don't send while prompt is waiting. * Allow selecting who is being prompted * Comments and cleaup * Remove char name for the moment (needs something here probably) * Add random time period and "Always add character's name to prompt" respect * Tooltips * Load/unload listeners * Reduce log spam * Add inline prompt inclusion * Add full loud prompting * Comments * Fix instruct newline (I think) * Don't reset count on continue * add quietToLoud for script.js * add quietToLoud for slashcommands.js * Keep instruct directives * Removed some logging, don't do the Novel formatting if Q2L * Logspam begone. * Removed a bit more logging * Add alignment style * Reformat files. Add comments * Reorder extensions * Fix repeat logic to prompt once then only repeat the number specified * Make repeat count more clear --------- Co-authored-by: RossAscends <124905043+RossAscends@users.noreply.github.com> Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
@ -20,12 +20,14 @@ import {
|
||||
generateQuietPrompt,
|
||||
reloadCurrentChat,
|
||||
sendMessageAsUser,
|
||||
name1,
|
||||
} from "../script.js";
|
||||
import { getMessageTimeStamp } from "./RossAscends-mods.js";
|
||||
import { resetSelectedGroup } from "./group-chats.js";
|
||||
import { getRegexedString, regex_placement } from "./extensions/regex/engine.js";
|
||||
import { chat_styles, power_user } from "./power-user.js";
|
||||
import { autoSelectPersona } from "./personas.js";
|
||||
import { getContext } from "./extensions.js";
|
||||
export {
|
||||
executeSlashCommands,
|
||||
registerSlashCommand,
|
||||
@ -225,7 +227,7 @@ function continueChatCallback() {
|
||||
$('#option_continue').trigger('click', { fromSlashCommand: true });
|
||||
}
|
||||
|
||||
async function generateSystemMessage(_, prompt) {
|
||||
export async function generateSystemMessage(_, prompt) {
|
||||
$('#send_textarea').val('');
|
||||
|
||||
if (!prompt) {
|
||||
@ -289,7 +291,7 @@ async function setNarratorName(_, text) {
|
||||
await saveChatConditional();
|
||||
}
|
||||
|
||||
async function sendMessageAs(_, text) {
|
||||
export async function sendMessageAs(_, text) {
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
@ -343,7 +345,7 @@ async function sendMessageAs(_, text) {
|
||||
await saveChatConditional();
|
||||
}
|
||||
|
||||
async function sendNarratorMessage(_, text) {
|
||||
export async function sendNarratorMessage(_, text) {
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
@ -374,6 +376,45 @@ async function sendNarratorMessage(_, text) {
|
||||
await saveChatConditional();
|
||||
}
|
||||
|
||||
export async function promptQuietForLoudResponse(who, text) {
|
||||
|
||||
let character_id = getContext().characterId;
|
||||
if (who === 'sys') {
|
||||
text = "System: " + text;
|
||||
} else if (who === 'user') {
|
||||
text = name1 + ": " + text;
|
||||
} else if (who === 'char') {
|
||||
text = characters[character_id].name + ": " + text;
|
||||
} else if (who === 'raw') {
|
||||
text = text;
|
||||
}
|
||||
|
||||
//text = `${text}${power_user.instruct.enabled ? '' : '\n'}${(power_user.always_force_name2 && who != 'raw') ? characters[character_id].name + ":" : ""}`
|
||||
|
||||
let reply = await generateQuietPrompt(text, true);
|
||||
text = await getRegexedString(reply, regex_placement.SLASH_COMMAND);
|
||||
|
||||
const message = {
|
||||
name: characters[character_id].name,
|
||||
is_user: false,
|
||||
is_name: true,
|
||||
is_system: false,
|
||||
send_date: getMessageTimeStamp(),
|
||||
mes: substituteParams(text.trim()),
|
||||
extra: {
|
||||
type: system_message_types.COMMENT,
|
||||
gen_id: Date.now(),
|
||||
},
|
||||
};
|
||||
|
||||
chat.push(message);
|
||||
await eventSource.emit(event_types.MESSAGE_SENT, (chat.length - 1));
|
||||
addOneMessage(message);
|
||||
await eventSource.emit(event_types.USER_MESSAGE_RENDERED, (chat.length - 1));
|
||||
await saveChatConditional();
|
||||
|
||||
}
|
||||
|
||||
async function sendCommentMessage(_, text) {
|
||||
if (!text) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user