mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/BlipRanger/SillyTavern into dev
This commit is contained in:
@@ -2200,10 +2200,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
// Determine token limit
|
// Determine token limit
|
||||||
let this_max_context = getMaxContextSize();
|
let this_max_context = getMaxContextSize();
|
||||||
|
|
||||||
if (extension_settings.chromadb.n_results !== 0) {
|
// Always run the extension interceptors.
|
||||||
await runGenerationInterceptors(coreChat, this_max_context);
|
await runGenerationInterceptors(coreChat, this_max_context);
|
||||||
console.log(`Core/all messages: ${coreChat.length}/${chat.length}`);
|
console.log(`Core/all messages: ${coreChat.length}/${chat.length}`);
|
||||||
}
|
|
||||||
|
|
||||||
let storyString = "";
|
let storyString = "";
|
||||||
|
|
||||||
@@ -6701,6 +6700,28 @@ function importCharacter(file) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function importFromURL(items, files) {
|
||||||
|
for (const item of items) {
|
||||||
|
if (item.type === 'text/uri-list') {
|
||||||
|
const uriList = await new Promise((resolve) => {
|
||||||
|
item.getAsString((uriList) => { resolve(uriList); });
|
||||||
|
});
|
||||||
|
const uris = uriList.split('\n').filter(uri => uri.trim() !== '');
|
||||||
|
try {
|
||||||
|
for (const uri of uris) {
|
||||||
|
const request = await fetch(uri);
|
||||||
|
const data = await request.blob();
|
||||||
|
const fileName = request.headers.get('Content-Disposition')?.split('filename=')[1]?.replace(/"/g, '') || uri.split('/').pop() || 'file.png';
|
||||||
|
const file = new File([data], fileName, { type: data.type });
|
||||||
|
files.push(file);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to import from URL', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const isPwaMode = window.navigator.standalone;
|
const isPwaMode = window.navigator.standalone;
|
||||||
if (isPwaMode) { $("body").addClass('PWA') }
|
if (isPwaMode) { $("body").addClass('PWA') }
|
||||||
|
|
||||||
@@ -8447,12 +8468,13 @@ $(document).ready(function () {
|
|||||||
$dropzone.removeClass('dragover');
|
$dropzone.removeClass('dragover');
|
||||||
});
|
});
|
||||||
|
|
||||||
$dropzone.on('drop', (event) => {
|
$dropzone.on('drop', async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
$dropzone.removeClass('dragover');
|
$dropzone.removeClass('dragover');
|
||||||
|
|
||||||
const files = event.originalEvent.dataTransfer.files;
|
const files = Array.from(event.originalEvent.dataTransfer.files);
|
||||||
|
await importFromURL(event.originalEvent.dataTransfer.items, files);
|
||||||
processDroppedFiles(files);
|
processDroppedFiles(files);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -622,11 +622,11 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
|||||||
queryBlob = lastMessage.mes;
|
queryBlob = lastMessage.mes;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (let msg of chat) {
|
for (let msg of chat.slice(-extension_settings.chromadb.keep_context)) {
|
||||||
queryBlob += `${msg.mes}\n`
|
queryBlob += `${msg.mes}\n`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("ChromDB Query text:", queryBlob);
|
console.log("CHROMADB: Query text:", queryBlob);
|
||||||
|
|
||||||
if (recallStrategy === 'multichat') {
|
if (recallStrategy === 'multichat') {
|
||||||
console.log("Utilizing multichat")
|
console.log("Utilizing multichat")
|
||||||
@@ -642,7 +642,7 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
|||||||
else {
|
else {
|
||||||
queriedMessages.sort((a, b) => b.distance - a.distance);
|
queriedMessages.sort((a, b) => b.distance - a.distance);
|
||||||
}
|
}
|
||||||
console.log(queriedMessages);
|
console.debug("CHROMADB: Query results: %o", queriedMessages);
|
||||||
|
|
||||||
|
|
||||||
let newChat = [];
|
let newChat = [];
|
||||||
@@ -702,6 +702,7 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const promptBlob = wrapperMsg.replace('{{memories}}', allMemoryBlob);
|
const promptBlob = wrapperMsg.replace('{{memories}}', allMemoryBlob);
|
||||||
|
console.debug("CHROMADB: prompt blob: %o", promptBlob);
|
||||||
context.setExtensionPrompt(MODULE_NAME, promptBlob, extension_prompt_types.AFTER_SCENARIO);
|
context.setExtensionPrompt(MODULE_NAME, promptBlob, extension_prompt_types.AFTER_SCENARIO);
|
||||||
}
|
}
|
||||||
if (selectedStrategy === 'custom') {
|
if (selectedStrategy === 'custom') {
|
||||||
|
Reference in New Issue
Block a user