2
0
Эх сурвалжийг харах

If all vector store files associated with a page are deleted, the vector store relation is also deleted.

Shun Miyazawa 1 жил өмнө
parent
commit
c242ec0e59

+ 6 - 0
apps/app/src/server/service/openai/openai.ts

@@ -104,6 +104,12 @@ class OpenaiService implements IOpenaiService {
       }
 
       const undeletedFileIds = vectorStoreFileRelation.fileIds.filter(fileId => !deletedFileIds.includes(fileId));
+
+      if (undeletedFileIds.length === 0) {
+        await vectorStoreFileRelation.remove();
+        return;
+      }
+
       vectorStoreFileRelation.fileIds = undeletedFileIds;
       await vectorStoreFileRelation.save();
     }