mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-01 11:02:37 +00:00
add async for python repl (#9080)
This commit is contained in:
@@ -131,3 +131,15 @@ class PythonAstREPLTool(BaseTool):
|
||||
return io_buffer.getvalue()
|
||||
except Exception as e:
|
||||
return "{}: {}".format(type(e).__name__, str(e))
|
||||
|
||||
async def _arun(
|
||||
self,
|
||||
query: str,
|
||||
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
|
||||
) -> Any:
|
||||
"""Use the tool asynchronously."""
|
||||
|
||||
loop = asyncio.get_running_loop()
|
||||
result = await loop.run_in_executor(None, self._run, query)
|
||||
|
||||
return result
|
||||
|
Reference in New Issue
Block a user