mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🔧 fix: Catch deleteVectors Errors & Update RAG API docs (#2299)
* fix(deleteVectors): handle errors gracefully * chore: update docs based on new alternate env vars prefixed with RAG to avoid conflicts with LibreChat keys
This commit is contained in:
parent
e3c236ba3b
commit
e418edd3dc
3 changed files with 13 additions and 22 deletions
|
|
@ -18,9 +18,12 @@ const { logger } = require('~/config');
|
|||
* file path is invalid or if there is an error in deletion.
|
||||
*/
|
||||
const deleteVectors = async (req, file) => {
|
||||
if (file.embedded && process.env.RAG_API_URL) {
|
||||
if (!file.embedded || !process.env.RAG_API_URL) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const jwtToken = req.headers.authorization.split(' ')[1];
|
||||
axios.delete(`${process.env.RAG_API_URL}/documents`, {
|
||||
return await axios.delete(`${process.env.RAG_API_URL}/documents`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${jwtToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
|
|
@ -28,6 +31,9 @@ const deleteVectors = async (req, file) => {
|
|||
},
|
||||
data: [file.file_id],
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error('Error deleting vectors', error);
|
||||
throw new Error(error.message || 'An error occurred during file deletion.');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue