mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add shallow character load mode
This commit is contained in:
@@ -1781,7 +1781,7 @@ export async function getCharacters() {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify({
|
||||
'': '',
|
||||
shallow: power_user.shallow_characters,
|
||||
}),
|
||||
});
|
||||
if (response.ok === true) {
|
||||
@@ -3658,6 +3658,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
setGenerationProgress(0);
|
||||
generation_started = new Date();
|
||||
|
||||
// Prevent generation from shallow characters
|
||||
await unshallowCharacter(this_chid);
|
||||
|
||||
// Occurs every time, even if the generation is aborted due to slash commands execution
|
||||
await eventSource.emit(event_types.GENERATION_STARTED, type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage }, dryRun);
|
||||
|
||||
@@ -6704,9 +6707,42 @@ export function buildAvatarList(block, entities, { templateId = 'inline_avatar_t
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all the data of a shallow character.
|
||||
* @param {string|undefined} characterId Array index
|
||||
* @returns {Promise<void>} Promise that resolves when the character is unshallowed
|
||||
*/
|
||||
export async function unshallowCharacter(characterId) {
|
||||
if (characterId === undefined) {
|
||||
console.warn('Undefined character cannot be unshallowed');
|
||||
return;
|
||||
}
|
||||
|
||||
const character = characters[characterId];
|
||||
if (!character) {
|
||||
console.warn('Character not found:', characterId);
|
||||
return;
|
||||
}
|
||||
|
||||
// Character is not shallow
|
||||
if (!character.shallow) {
|
||||
return;
|
||||
}
|
||||
|
||||
const avatar = character.avatar;
|
||||
if (!avatar) {
|
||||
console.warn('Character has no avatar field:', characterId);
|
||||
return;
|
||||
}
|
||||
|
||||
await getOneCharacter(avatar);
|
||||
}
|
||||
|
||||
export async function getChat() {
|
||||
//console.log('/api/chats/get -- entered for -- ' + characters[this_chid].name);
|
||||
try {
|
||||
await unshallowCharacter(this_chid);
|
||||
|
||||
const response = await $.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/chats/get',
|
||||
|
Reference in New Issue
Block a user