Feature/Multer to s3 (#2408)

* add ability to store files from multer to s3

* add check to bypass doc loader
This commit is contained in:
Henry Heng
2024-05-15 19:41:37 +01:00
committed by GitHub
parent c022972cf8
commit b5e502f3b6
6 changed files with 109 additions and 31 deletions
@@ -8,7 +8,7 @@ import { zodToJsonSchema } from 'zod-to-json-schema'
import { AnalyticHandler } from '../../../src/handler'
import { Moderation, checkInputs, streamResponse } from '../../moderation/Moderation'
import { formatResponse } from '../../outputparsers/OutputParserHelpers'
import { addFileToStorage } from '../../../src/storageUtils'
import { addSingleFileToStorage } from '../../../src/storageUtils'
const lenticularBracketRegex = /【[^】]*】/g
const imageRegex = /<img[^>]*\/>/g
@@ -731,7 +731,7 @@ const downloadImg = async (openai: OpenAI, fileId: string, fileName: string, ...
const image_data_buffer = Buffer.from(image_data)
const mime = 'image/png'
await addFileToStorage(mime, image_data_buffer, fileName, ...paths)
await addSingleFileToStorage(mime, image_data_buffer, fileName, ...paths)
return image_data_buffer
}
@@ -754,7 +754,7 @@ const downloadFile = async (openAIApiKey: string, fileObj: any, fileName: string
const data_buffer = Buffer.from(data)
const mime = 'application/octet-stream'
return await addFileToStorage(mime, data_buffer, fileName, ...paths)
return await addSingleFileToStorage(mime, data_buffer, fileName, ...paths)
} catch (error) {
console.error('Error downloading or writing the file:', error)
return ''