mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-09 08:38:53 +01:00
Merge branch 'staging' into contentEditablew-AF-Panel
This commit is contained in:
commit
c21f59ca7a
@ -3441,12 +3441,14 @@
|
||||
</div>
|
||||
<div id="WorldInfo" class="drawer-content closedDrawer">
|
||||
<div id="WorldInfoheader" class="fa-solid fa-grip drag-grabber"></div>
|
||||
<div id="WI_panel_pin_div" class="flex-container alignitemscenter gap10px" title="Locked = World Editor will stay open" data-i18n="[title]Locked = World Editor will stay open">
|
||||
<input type="checkbox" id="WI_panel_pin">
|
||||
<label for="WI_panel_pin">
|
||||
<div class="unchecked fa-solid fa-unlock "></div>
|
||||
<div class="checked fa-solid fa-lock "></div>
|
||||
</label>
|
||||
<div class="flex-container alignitemscenter gap10px">
|
||||
<div id="WI_panel_pin_div" title="Locked = World Editor will stay open" data-i18n="[title]Locked = World Editor will stay open">
|
||||
<input type="checkbox" id="WI_panel_pin">
|
||||
<label for="WI_panel_pin">
|
||||
<div class="unchecked fa-solid fa-unlock "></div>
|
||||
<div class="checked fa-solid fa-lock "></div>
|
||||
</label>
|
||||
</div>
|
||||
<h3 class="margin0">
|
||||
<span data-i18n="Worlds/Lorebooks">Worlds/Lorebooks</span>
|
||||
<a href="https://docs.sillytavern.app/usage/core-concepts/worldinfo/" class="notes-link" target="_blank">
|
||||
|
@ -454,7 +454,9 @@ export const event_types = {
|
||||
// TODO: Naming convention is inconsistent with other events
|
||||
CHARACTER_DELETED: 'characterDeleted',
|
||||
CHARACTER_DUPLICATED: 'character_duplicated',
|
||||
SMOOTH_STREAM_TOKEN_RECEIVED: 'smooth_stream_token_received',
|
||||
/** @deprecated The event is aliased to STREAM_TOKEN_RECEIVED. */
|
||||
SMOOTH_STREAM_TOKEN_RECEIVED: 'stream_token_received',
|
||||
STREAM_TOKEN_RECEIVED: 'stream_token_received',
|
||||
FILE_ATTACHMENT_DELETED: 'file_attachment_deleted',
|
||||
WORLDINFO_FORCE_ACTIVATE: 'worldinfo_force_activate',
|
||||
OPEN_CHARACTER_LIBRARY: 'open_character_library',
|
||||
@ -3122,6 +3124,7 @@ class StreamingProcessor {
|
||||
if (logprobs) {
|
||||
this.messageLogprobs.push(...(Array.isArray(logprobs) ? logprobs : [logprobs]));
|
||||
}
|
||||
await eventSource.emit(event_types.STREAM_TOKEN_RECEIVED, text);
|
||||
await sw.tick(() => this.onProgressStreaming(this.messageId, this.continueMessage + text));
|
||||
}
|
||||
const seconds = (timestamps[timestamps.length - 1] - timestamps[0]) / 1000;
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
generateRaw,
|
||||
getMaxContextSize,
|
||||
setExtensionPrompt,
|
||||
streamingProcessor,
|
||||
} from '../../../script.js';
|
||||
import { is_group_generating, selected_group } from '../../group-chats.js';
|
||||
import { loadMovingUIState } from '../../power-user.js';
|
||||
@ -408,8 +409,8 @@ async function onChatEvent() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Generation is in progress, summary prevented
|
||||
if (is_send_press) {
|
||||
// Streaming in-progress
|
||||
if (streamingProcessor && !streamingProcessor.isFinished) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -446,15 +447,9 @@ async function onChatEvent() {
|
||||
delete chat[chat.length - 1].extra.memory;
|
||||
}
|
||||
|
||||
try {
|
||||
await summarizeChat(context);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
finally {
|
||||
saveLastValues();
|
||||
}
|
||||
summarizeChat(context)
|
||||
.catch(console.error)
|
||||
.finally(saveLastValues);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -567,7 +562,7 @@ async function getSummaryPromptForNow(context, force) {
|
||||
await waitUntilCondition(() => is_group_generating === false, 1000, 10);
|
||||
}
|
||||
// Wait for the send button to be released
|
||||
waitUntilCondition(() => is_send_press === false, 30000, 100);
|
||||
await waitUntilCondition(() => is_send_press === false, 30000, 100);
|
||||
} catch {
|
||||
console.debug('Timeout waiting for is_send_press');
|
||||
return '';
|
||||
@ -650,19 +645,29 @@ async function summarizeChatWebLLM(context, force) {
|
||||
params.max_tokens = extension_settings.memory.overrideResponseLength;
|
||||
}
|
||||
|
||||
const summary = await generateWebLlmChatPrompt(messages, params);
|
||||
const newContext = getContext();
|
||||
try {
|
||||
inApiCall = true;
|
||||
const summary = await generateWebLlmChatPrompt(messages, params);
|
||||
const newContext = getContext();
|
||||
|
||||
// something changed during summarization request
|
||||
if (newContext.groupId !== context.groupId ||
|
||||
newContext.chatId !== context.chatId ||
|
||||
(!newContext.groupId && (newContext.characterId !== context.characterId))) {
|
||||
console.log('Context changed, summary discarded');
|
||||
return;
|
||||
if (!summary) {
|
||||
console.warn('Empty summary received');
|
||||
return;
|
||||
}
|
||||
|
||||
// something changed during summarization request
|
||||
if (newContext.groupId !== context.groupId ||
|
||||
newContext.chatId !== context.chatId ||
|
||||
(!newContext.groupId && (newContext.characterId !== context.characterId))) {
|
||||
console.log('Context changed, summary discarded');
|
||||
return;
|
||||
}
|
||||
|
||||
setMemoryContext(summary, true, lastUsedIndex);
|
||||
return summary;
|
||||
} finally {
|
||||
inApiCall = false;
|
||||
}
|
||||
|
||||
setMemoryContext(summary, true, lastUsedIndex);
|
||||
return summary;
|
||||
}
|
||||
|
||||
async function summarizeChatMain(context, force, skipWIAN) {
|
||||
@ -677,12 +682,18 @@ async function summarizeChatMain(context, force, skipWIAN) {
|
||||
let index = null;
|
||||
|
||||
if (prompt_builders.DEFAULT === extension_settings.memory.prompt_builder) {
|
||||
summary = await generateQuietPrompt(prompt, false, skipWIAN, '', '', extension_settings.memory.overrideResponseLength);
|
||||
try {
|
||||
inApiCall = true;
|
||||
summary = await generateQuietPrompt(prompt, false, skipWIAN, '', '', extension_settings.memory.overrideResponseLength);
|
||||
} finally {
|
||||
inApiCall = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ([prompt_builders.RAW_BLOCKING, prompt_builders.RAW_NON_BLOCKING].includes(extension_settings.memory.prompt_builder)) {
|
||||
const lock = extension_settings.memory.prompt_builder === prompt_builders.RAW_BLOCKING;
|
||||
try {
|
||||
inApiCall = true;
|
||||
if (lock) {
|
||||
deactivateSendButtons();
|
||||
}
|
||||
@ -700,12 +711,18 @@ async function summarizeChatMain(context, force, skipWIAN) {
|
||||
summary = await generateRaw(rawPrompt, '', false, false, prompt, extension_settings.memory.overrideResponseLength);
|
||||
index = lastUsedIndex;
|
||||
} finally {
|
||||
inApiCall = false;
|
||||
if (lock) {
|
||||
activateSendButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!summary) {
|
||||
console.warn('Empty summary received');
|
||||
return;
|
||||
}
|
||||
|
||||
const newContext = getContext();
|
||||
|
||||
// something changed during summarization request
|
||||
@ -840,6 +857,11 @@ async function summarizeChatExtras(context) {
|
||||
const summary = await callExtrasSummarizeAPI(resultingString);
|
||||
const newContext = getContext();
|
||||
|
||||
if (!summary) {
|
||||
console.warn('Empty summary received');
|
||||
return;
|
||||
}
|
||||
|
||||
// something changed during summarization request
|
||||
if (newContext.groupId !== context.groupId
|
||||
|| newContext.chatId !== context.chatId
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { eventSource, event_types } from '../script.js';
|
||||
import { power_user } from './power-user.js';
|
||||
import { delay } from './utils.js';
|
||||
|
||||
@ -268,7 +267,6 @@ export class SmoothEventSourceStream extends EventSourceStream {
|
||||
hasFocus && await delay(getDelay(lastStr));
|
||||
controller.enqueue(new MessageEvent(event.type, { data: JSON.stringify(parsed.data) }));
|
||||
lastStr = parsed.chunk;
|
||||
hasFocus && await eventSource.emit(event_types.SMOOTH_STREAM_TOKEN_RECEIVED, parsed.chunk);
|
||||
}
|
||||
} catch (error) {
|
||||
console.debug('Smooth Streaming parsing error', error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user