mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
feat: implement python repl tool arun (#7125)
Description: implement python repl tool arun Tag maintainer: @agola11
This commit is contained in:
parent
9cfb311ecb
commit
bf9e4ef35f
@ -1,6 +1,7 @@
|
||||
"""A tool for running python code in a REPL."""
|
||||
|
||||
import ast
|
||||
import asyncio
|
||||
import re
|
||||
import sys
|
||||
from contextlib import redirect_stdout
|
||||
@ -68,7 +69,13 @@ class PythonREPLTool(BaseTool):
|
||||
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
|
||||
) -> Any:
|
||||
"""Use the tool asynchronously."""
|
||||
raise NotImplementedError("PythonReplTool does not support async")
|
||||
if self.sanitize_input:
|
||||
query = sanitize_input(query)
|
||||
|
||||
loop = asyncio.get_running_loop()
|
||||
result = await loop.run_in_executor(None, self.run, query)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class PythonAstREPLTool(BaseTool):
|
||||
|
Loading…
Reference in New Issue
Block a user