mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Summarize the chat messages handed to the embedding beforehand
This commit is contained in:
@@ -1,4 +1,15 @@
|
|||||||
import { eventSource, event_types, extension_prompt_types, getCurrentChatId, getRequestHeaders, is_send_press, saveSettingsDebounced, setExtensionPrompt, substituteParams } from '../../../script.js';
|
import {
|
||||||
|
eventSource,
|
||||||
|
event_types,
|
||||||
|
extension_prompt_types,
|
||||||
|
getCurrentChatId,
|
||||||
|
getRequestHeaders,
|
||||||
|
is_send_press,
|
||||||
|
saveSettingsDebounced,
|
||||||
|
setExtensionPrompt,
|
||||||
|
substituteParams,
|
||||||
|
generateRaw,
|
||||||
|
} from '../../../script.js';
|
||||||
import { ModuleWorkerWrapper, extension_settings, getContext, modules, renderExtensionTemplateAsync } from '../../extensions.js';
|
import { ModuleWorkerWrapper, extension_settings, getContext, modules, renderExtensionTemplateAsync } from '../../extensions.js';
|
||||||
import { collapseNewlines } from '../../power-user.js';
|
import { collapseNewlines } from '../../power-user.js';
|
||||||
import { SECRET_KEYS, secret_state, writeSecret } from '../../secrets.js';
|
import { SECRET_KEYS, secret_state, writeSecret } from '../../secrets.js';
|
||||||
@@ -141,6 +152,11 @@ async function synchronizeChat(batchSize = 5) {
|
|||||||
const newVectorItems = hashedMessages.filter(x => !hashesInCollection.includes(x.hash));
|
const newVectorItems = hashedMessages.filter(x => !hashesInCollection.includes(x.hash));
|
||||||
const deletedHashes = hashesInCollection.filter(x => !hashedMessages.some(y => y.hash === x));
|
const deletedHashes = hashesInCollection.filter(x => !hashedMessages.some(y => y.hash === x));
|
||||||
|
|
||||||
|
const sysPrompt = 'Pause your roleplay. Summarize the most important parts of the message. Your response should include nothing but the summary.';
|
||||||
|
for (let i = 0; i < hashedMessages.length; i++) {
|
||||||
|
hashedMessages[i].text = await generateRaw(hashedMessages[i].text, '', false, false, sysPrompt);
|
||||||
|
}
|
||||||
|
|
||||||
if (newVectorItems.length > 0) {
|
if (newVectorItems.length > 0) {
|
||||||
const chunkedBatch = splitByChunks(newVectorItems.slice(0, batchSize));
|
const chunkedBatch = splitByChunks(newVectorItems.slice(0, batchSize));
|
||||||
console.log(`Vectors: Found ${newVectorItems.length} new items. Processing ${batchSize}...`);
|
console.log(`Vectors: Found ${newVectorItems.length} new items. Processing ${batchSize}...`);
|
||||||
|
Reference in New Issue
Block a user