mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-08 02:45:22 +03:00
2.5 KiB
2.5 KiB
In [1]:
from langchain.agents import Tool
from langchain.utilities import PythonREPLIn [2]:
python_repl = PythonREPL()In [3]:
python_repl.run("print(1+1)")Out [3]:
Python REPL can execute arbitrary code. Use with caution.
'2\n'
In [4]:
# You can create the tool to pass to an agent
repl_tool = Tool(
name="python_repl",
description="A Python shell. Use this to execute python commands. Input should be a valid python command. If you want to see the output of a value, you should print it out with `print(...)`.",
func=python_repl.run,
)