|
@@ -65,7 +65,7 @@ class R2RFileService(OSSFileService):
|
|
|
return db_file
|
|
|
|
|
|
@staticmethod
|
|
|
- def search_in_files(
|
|
|
+ async def search_in_files(
|
|
|
query: str, file_keys: List[str], folder_keys: List[str] = None
|
|
|
) -> dict:
|
|
|
files = {}
|
|
@@ -88,9 +88,11 @@ class R2RFileService(OSSFileService):
|
|
|
loop = asyncio.get_event_loop() # 获取当前事件循环
|
|
|
loop.run_until_complete(r2r.init()) # 确保 r2r 已初始化
|
|
|
search_results = loop.run_until_complete(r2r.search(query, filters=filters))
|
|
|
- """
|
|
|
asyncio.run(r2r.init())
|
|
|
search_results = asyncio.run(r2r.search(query, filters=filters))
|
|
|
+ """
|
|
|
+ await r2r.init()
|
|
|
+ search_results = await r2r.search(query, filters=filters)
|
|
|
if not search_results:
|
|
|
return files
|
|
|
|
|
@@ -105,7 +107,7 @@ class R2RFileService(OSSFileService):
|
|
|
return files
|
|
|
|
|
|
@staticmethod
|
|
|
- def list_in_files(
|
|
|
+ async def list_in_files(
|
|
|
ids: list[str] = None,
|
|
|
offset: int = 0,
|
|
|
limit: int = 100,
|
|
@@ -116,13 +118,15 @@ class R2RFileService(OSSFileService):
|
|
|
list_results = loop.run_until_complete(
|
|
|
r2r.list(ids=ids, offset=offset, limit=limit)
|
|
|
)
|
|
|
- """
|
|
|
asyncio.run(r2r.init())
|
|
|
list_results = asyncio.run(r2r.list(ids=ids, offset=offset, limit=limit))
|
|
|
+ """
|
|
|
+ await r2r.init()
|
|
|
+ list_results = await r2r.list(ids=ids, offset=offset, limit=limit)
|
|
|
return list_results
|
|
|
|
|
|
@staticmethod
|
|
|
- def list_documents(
|
|
|
+ async def list_documents(
|
|
|
id: str = "",
|
|
|
offset: int = 0,
|
|
|
limit: int = 100,
|
|
@@ -133,11 +137,13 @@ class R2RFileService(OSSFileService):
|
|
|
list_results = loop.run_until_complete(
|
|
|
r2r.list_documents(id=id, offset=offset, limit=limit)
|
|
|
)
|
|
|
- """
|
|
|
asyncio.run(r2r.init())
|
|
|
list_results = asyncio.run(
|
|
|
r2r.list_documents(id=id, offset=offset, limit=limit)
|
|
|
)
|
|
|
+ """
|
|
|
+ await r2r.init()
|
|
|
+ list_results = await r2r.list_documents(id=id, offset=offset, limit=limit)
|
|
|
return list_results
|
|
|
|
|
|
# TODO 删除s3&r2r文件
|