⚙️ fix: File Config Handling (#4664)

* chore: typing

* refactor: create file filter from custom fileConfig, if provided

* refactor: use logger utility to avoid overly verbose axios error logs when using RAG_API

* fix(useFileHandling): use memoization/callbacks to make sure the appropriate fileConfig is used; refactor: move endpoint to first field applied to formdata

* chore: update librechat-data-provider version to 0.7.54

* chore: revert type change
This commit is contained in:
Danny Avila 2024-11-07 11:11:20 -05:00 committed by GitHub
parent d60a0af878
commit 49ee88b6e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 123 additions and 82 deletions

View file

@ -2,6 +2,7 @@ const fs = require('fs');
const axios = require('axios');
const FormData = require('form-data');
const { FileSources } = require('librechat-data-provider');
const { logAxiosError } = require('~/utils');
const { logger } = require('~/config');
/**
@ -32,7 +33,10 @@ const deleteVectors = async (req, file) => {
data: [file.file_id],
});
} catch (error) {
logger.error('Error deleting vectors', error);
logAxiosError({
error,
message: 'Error deleting vectors',
});
throw new Error(error.message || 'An error occurred during file deletion.');
}
};
@ -91,7 +95,10 @@ async function uploadVectors({ req, file, file_id }) {
embedded: Boolean(responseData.known_type),
};
} catch (error) {
logger.error('Error embedding file', error);
logAxiosError({
error,
message: 'Error uploading vectors',
});
throw new Error(error.message || 'An error occurred during file upload.');
}
}