mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-24 06:34:46 +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:
@@ -47,7 +47,15 @@ class RetrieverTool(BaseTool):
|
||||
keywords: str,
|
||||
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
|
||||
) -> list[Document]:
|
||||
return self._run(keywords, run_manager.get_sync())
|
||||
logger.info(
|
||||
f"Retriever tool query: {keywords}", extra={"resources": self.resources}
|
||||
)
|
||||
documents = await self.retriever.query_relevant_documents_async(
|
||||
keywords, self.resources
|
||||
)
|
||||
if not documents:
|
||||
return "No results found from the local knowledge base."
|
||||
return [doc.to_dict() for doc in documents]
|
||||
|
||||
|
||||
def get_retriever_tool(resources: List[Resource]) -> RetrieverTool | None:
|
||||
|
||||
Reference in New Issue
Block a user