Shun Miyazawa 1 год назад
Родитель
Сommit
d7a2667d19
1 измененных файлов с 8 добавлено и 3 удалено
  1. 8 3
      apps/app/src/features/openai/server/services/openai.ts

+ 8 - 3
apps/app/src/features/openai/server/services/openai.ts

@@ -140,9 +140,14 @@ class OpenaiService implements IOpenaiService {
   private async uploadFileByChunks(pageId: Types.ObjectId, body: string, vectorStoreFileRelationsMap: VectorStoreFileRelationsMap) {
   private async uploadFileByChunks(pageId: Types.ObjectId, body: string, vectorStoreFileRelationsMap: VectorStoreFileRelationsMap) {
     const chunks = await splitMarkdownIntoChunks(body, 'gpt-4o');
     const chunks = await splitMarkdownIntoChunks(body, 'gpt-4o');
     for await (const [index, chunk] of chunks.entries()) {
     for await (const [index, chunk] of chunks.entries()) {
-      const file = await toFile(Readable.from(chunk), `${pageId}-chunk-${index}.md`);
-      const uploadedFile = await this.client.uploadFile(file);
-      prepareVectorStoreFileRelations(pageId, uploadedFile.id, vectorStoreFileRelationsMap);
+      try {
+        const file = await toFile(Readable.from(chunk), `${pageId}-chunk-${index}.md`);
+        const uploadedFile = await this.client.uploadFile(file);
+        prepareVectorStoreFileRelations(pageId, uploadedFile.id, vectorStoreFileRelationsMap);
+      }
+      catch (err) {
+        logger.error(err);
+      }
     }
     }
   }
   }