Fix purge extras and mistral vectors
This commit is contained in:
parent
9b34ac1bde
commit
737a0bd3ae
|
@ -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);
|
||||
if (await purgeVectorIndex(chatId)) {
|
||||
toastr.success('Vector index purged', 'Purge successful');
|
||||
} else {
|
||||
toastr.error('Failed to purge vector index', 'Purge failed');
|
||||
}
|
||||
}
|
||||
|
||||
async function onViewStatsClick() {
|
||||
|
|
|
@ -4,6 +4,9 @@ const express = require('express');
|
|||
const sanitize = require('sanitize-filename');
|
||||
const { jsonParser } = require('../express-common');
|
||||
|
||||
// Don't forget to add new sources to the SOURCES array
|
||||
const SOURCES = ['transformers', 'mistral', 'openai', 'extras', 'palm'];
|
||||
|
||||
/**
|
||||
* Gets the vector for the given text from the given source.
|
||||
* @param {string} source - The source of the vector
|
||||
|
@ -261,8 +264,7 @@ router.post('/purge', jsonParser, async (req, res) => {
|
|||
|
||||
const collectionId = String(req.body.collectionId);
|
||||
|
||||
const sources = ['transformers', 'openai', 'palm'];
|
||||
for (const source of sources) {
|
||||
for (const source of SOURCES) {
|
||||
const index = await getIndex(collectionId, source, false);
|
||||
|
||||
const exists = await index.isIndexCreated();
|
||||
|
|
Loading…
Reference in New Issue