jack 1 週間 前
コミット
4657b8f645
2 ファイル変更12 行追加2 行削除
  1. 10 0
      app/providers/r2r.py
  2. 2 2
      app/services/file/impl/r2r_file.py

+ 10 - 0
app/providers/r2r.py

@@ -93,6 +93,16 @@ class R2R:
         print(search_response.results)
         return search_response.results.chunk_search_results
 
+    def ingest_file_sync(self, file_path: str, metadata: Optional[dict]):
+        client = self._check_login_sync()
+        return client.documents.create(
+            file_path=file_path,
+            metadata=metadata if metadata else None,
+            ingestion_mode="fast",
+            id=None,
+            run_with_orchestration=False,
+        )
+
     def list_chunks(self, ids: list[str] = []):
         client = self._check_login_sync()
         print(

+ 2 - 2
app/services/file/impl/r2r_file.py

@@ -50,8 +50,8 @@ class R2RFileService(OSSFileService):
 
             # storage.save_from_path(filename=file_key, local_file_path=tmp_file_path)
             r2r = R2R()
-            await r2r.init()
-            fileinfo = await r2r.ingest_file(
+            # await r2r.init()
+            fileinfo = r2r.ingest_file_sync(
                 file_path=tmp_file_path,
                 metadata={"file_key": file_key, "title": file.filename},
             )