Shun Miyazawa 11 месяцев назад
Родитель
Сommit
5f9bb97770

+ 3 - 2
apps/app/src/features/openai/server/utils/is-vector-store-compatible.ts

@@ -27,9 +27,9 @@ const supportedFormats = {
 
 type SupportedExtension = keyof typeof supportedFormats;
 
-export const isVectorStoreCompatible = (originalName: string, mimeType: string): boolean => {
+export const isVectorStoreCompatible = (file: Express.Multer.File): boolean => {
   // Get extension
-  const extension = path.extname(originalName);
+  const extension = path.extname(file.originalname);
 
   // Check if the file extension is supported
   if (!(extension in supportedFormats)) {
@@ -40,6 +40,7 @@ export const isVectorStoreCompatible = (originalName: string, mimeType: string):
   const supportedMimeType = supportedFormats[extension as SupportedExtension];
 
   // Check if the mimeType is supported
+  const mimeType = file.mimetype;
   return Array.isArray(supportedMimeType)
     ? supportedMimeType.includes(mimeType)
     : supportedMimeType === mimeType;

+ 1 - 1
apps/app/src/server/routes/apiv3/attachment.js

@@ -369,7 +369,7 @@ module.exports = (crowi) => {
           attachment: attachment.toObject({ virtuals: true }),
         };
 
-        const isVectorStoreCompatible_ = isVectorStoreCompatible(file.originalname, file.mimetype);
+        const isVectorStoreCompatible_ = isVectorStoreCompatible(file);
         if (isVectorStoreCompatible_) {
           // TODO: https://redmine.weseek.co.jp/issues/165326
           // Process for uploading to VectorStore