Make summarization toggleable

This commit is contained in:
Kristan Schlikow 2024-04-10 00:13:27 +02:00
parent 59abee3043
commit a1473dedd0
No known key found for this signature in database
GPG Key ID: B92ED0CBF4AD31EA
2 changed files with 22 additions and 7 deletions

View File

@ -25,6 +25,7 @@ const settings = {
include_wi: false,
togetherai_model: 'togethercomputer/m2-bert-80M-32k-retrieval',
openai_model: 'text-embedding-ada-002',
summarize: false,
// For chats
enabled_chats: false,
@ -152,9 +153,11 @@ async function synchronizeChat(batchSize = 5) {
const newVectorItems = hashedMessages.filter(x => !hashesInCollection.includes(x.hash));
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 (settings.summarize) {
const sysPrompt = 'Pause your roleplay. Summarize the most important parts of the message. Limit yourself to 250 words or less. Your response should include nothing but the summary.';
for (const element of hashedMessages) {
element.text = await generateRaw(element.text, '', false, false, sysPrompt);
}
}
if (newVectorItems.length > 0) {
@ -773,6 +776,12 @@ jQuery(async () => {
saveSettingsDebounced();
});
$('#vectors_summarize').prop('checked', settings.summarize).on('input', () => {
settings.summarize = !!$('#vectors_summarize').prop('checked');
Object.assign(extension_settings.vectors, settings);
saveSettingsDebounced();
});
$('#vectors_message_chunk_size').val(settings.message_chunk_size).on('input', () => {
settings.message_chunk_size = Number($('#vectors_message_chunk_size').val());
Object.assign(extension_settings.vectors, settings);

View File

@ -73,10 +73,16 @@
<input type="number" id="vectors_query" class="text_pole widthUnset" min="1" max="99" />
</div>
<label class="checkbox_label" for="vectors_include_wi" title="Query results can activate World Info entries.">
<input id="vectors_include_wi" type="checkbox" class="checkbox">
Include in World Info Scanning
</label>
<div class="flex-container">
<label class="checkbox_label expander" for="vectors_include_wi" title="Query results can activate World Info entries.">
<input id="vectors_include_wi" type="checkbox" class="checkbox">
Include in World Info Scanning
</label>
<label class="checkbox_label expander" for="vectors_summarize" title="Summarize chat messages before generating embeddings.">
<input id="vectors_summarize" type="checkbox" class="checkbox">
Summarize chat messages
</label>
</div>
<hr>