Ver Fonte

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

Shun Miyazawa há 1 ano atrás
pai
commit
c242ec0e59
1 ficheiros alterados com 6 adições e 0 exclusões
  1. 6 0
      apps/app/src/server/service/openai/openai.ts

+ 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();
     }