Fix purge extras and mistral vectors

This commit is contained in:
Cohee
2024-02-23 22:37:00 +02:00
parent 9b34ac1bde
commit 737a0bd3ae
2 changed files with 17 additions and 6 deletions

View File

@@ -530,10 +530,15 @@ async function queryCollection(collectionId, searchText, topK) {
return results;
}
/**
* Purges the vector index for a collection.
* @param {string} collectionId Collection ID to purge
* @returns <Promise<boolean>> True if deleted, false if not
*/
async function purgeVectorIndex(collectionId) {
try {
if (!settings.enabled_chats) {
return;
return true;
}
const response = await fetch('/api/vector/purge', {
@@ -549,9 +554,10 @@ async function purgeVectorIndex(collectionId) {
}
console.log(`Vectors: Purged vector index for collection ${collectionId}`);
return true;
} catch (error) {
console.error('Vectors: Failed to purge', error);
return false;
}
}
@@ -566,8 +572,11 @@ async function onPurgeClick() {
toastr.info('No chat selected', 'Purge aborted');
return;
}
await purgeVectorIndex(chatId);
toastr.success('Vector index purged', 'Purge successful');
if (await purgeVectorIndex(chatId)) {
toastr.success('Vector index purged', 'Purge successful');
} else {
toastr.error('Failed to purge vector index', 'Purge failed');
}
}
async function onViewStatsClick() {