mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-26 23:34:47 +08:00
refactor: Refactors the retriever function to use async/await (#821)
* refactor: Refactors the retriever function to use async/await
This commit is contained in:
@@ -67,7 +67,18 @@ class Retriever(abc.ABC):
|
||||
@abc.abstractmethod
|
||||
def list_resources(self, query: str | None = None) -> list[Resource]:
|
||||
"""
|
||||
List resources from the rag provider.
|
||||
List resources from the rag provider (synchronous version).
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
async def list_resources_async(self, query: str | None = None) -> list[Resource]:
|
||||
"""
|
||||
List resources from the rag provider (asynchronous version).
|
||||
|
||||
Implementations should choose between:
|
||||
- Providing native async I/O operations for true non-blocking behavior
|
||||
- Using asyncio.to_thread() to wrap the synchronous version if async I/O is not available
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -76,7 +87,20 @@ class Retriever(abc.ABC):
|
||||
self, query: str, resources: list[Resource] = []
|
||||
) -> list[Document]:
|
||||
"""
|
||||
Query relevant documents from the resources.
|
||||
Query relevant documents from the resources (synchronous version).
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
async def query_relevant_documents_async(
|
||||
self, query: str, resources: list[Resource] = []
|
||||
) -> list[Document]:
|
||||
"""
|
||||
Query relevant documents from the resources (asynchronous version).
|
||||
|
||||
Implementations should choose between:
|
||||
- Providing native async I/O operations for true non-blocking behavior
|
||||
- Using asyncio.to_thread() to wrap the synchronous version if async I/O is not available
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user