mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
add async for python repl (#9080)
This commit is contained in:
parent
105c787e5a
commit
45f0f9460a
@ -131,3 +131,15 @@ class PythonAstREPLTool(BaseTool):
|
|||||||
return io_buffer.getvalue()
|
return io_buffer.getvalue()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return "{}: {}".format(type(e).__name__, str(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
|
||||||
|
Loading…
Reference in New Issue
Block a user