🔍 feat: Add Entity ID Support for File Search Shared Resources (#5028)

This commit is contained in:
Danny Avila 2024-12-17 22:11:18 -05:00 committed by GitHub
parent 18ad89be2c
commit d3cafeee96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 22 deletions

View file

@ -50,13 +50,14 @@ const deleteVectors = async (req, file) => {
* @param {Express.Multer.File} params.file - The file object, which is part of the request. The file object should
* have a `path` property that points to the location of the uploaded file.
* @param {string} params.file_id - The file ID.
* @param {string} [params.entity_id] - The entity ID for shared resources.
*
* @returns {Promise<{ filepath: string, bytes: number }>}
* A promise that resolves to an object containing:
* - filepath: The path where the file is saved.
* - bytes: The size of the file in bytes.
*/
async function uploadVectors({ req, file, file_id }) {
async function uploadVectors({ req, file, file_id, entity_id }) {
if (!process.env.RAG_API_URL) {
throw new Error('RAG_API_URL not defined');
}
@ -66,8 +67,11 @@ async function uploadVectors({ req, file, file_id }) {
const formData = new FormData();
formData.append('file_id', file_id);
formData.append('file', fs.createReadStream(file.path));
if (entity_id != null && entity_id) {
formData.append('entity_id', entity_id);
}
const formHeaders = formData.getHeaders(); // Automatically sets the correct Content-Type
const formHeaders = formData.getHeaders();
const response = await axios.post(`${process.env.RAG_API_URL}/embed`, formData, {
headers: {