|
|
@ -1,6 +1,15 @@
|
|
|
|
"""Test functionality of Python REPL."""
|
|
|
|
"""Test functionality of Python REPL."""
|
|
|
|
|
|
|
|
|
|
|
|
from langchain.python import PythonREPL
|
|
|
|
from langchain.python import PythonREPL
|
|
|
|
|
|
|
|
from langchain.tools.python.tool import PythonREPLTool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_SAMPLE_CODE = """
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
def multiply():
|
|
|
|
|
|
|
|
print(5*6)
|
|
|
|
|
|
|
|
multiply()
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_python_repl() -> None:
|
|
|
|
def test_python_repl() -> None:
|
|
|
@ -43,6 +52,14 @@ def test_functionality() -> None:
|
|
|
|
assert output == "2\n"
|
|
|
|
assert output == "2\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_functionality_multiline() -> None:
|
|
|
|
|
|
|
|
"""Test correct functionality for ChatGPT multiline commands."""
|
|
|
|
|
|
|
|
chain = PythonREPL()
|
|
|
|
|
|
|
|
tool = PythonREPLTool(python_repl=chain)
|
|
|
|
|
|
|
|
output = tool.run(_SAMPLE_CODE)
|
|
|
|
|
|
|
|
assert output == "30\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_function() -> None:
|
|
|
|
def test_function() -> None:
|
|
|
|
"""Test correct functionality."""
|
|
|
|
"""Test correct functionality."""
|
|
|
|
chain = PythonREPL()
|
|
|
|
chain = PythonREPL()
|
|
|
|