MCPcopy Create free account
hub / github.com/apache/burr / python_repl

Function python_repl

examples/multi-agent-collaboration/lcel/application.py:53–61  ·  view source on GitHub ↗

Use this to execute python code. If you want to see the output of a value, you should print it out with `print(...)`. This is visible to the user.

(code: Annotated[str, "The python code to execute to generate your chart."])

Source from the content-addressed store, hash-verified

51
52@tool
53def python_repl(code: Annotated[str, "The python code to execute to generate your chart."]):
54 """Use this to execute python code. If you want to see the output of a value,
55 you should print it out with `print(...)`. This is visible to the user."""
56 try:
57 # Warning: This executes code locally, which can be unsafe when not sandboxed
58 result = repl.run(code)
59 except BaseException as e:
60 return f"Failed to execute. Error: {repr(e)}"
61 return f"Succesfully executed:\n```python\n{code}\n```\nStdout: {result}"
62
63
64tools = [tavily_tool, python_repl]

Callers

nothing calls this directly

Calls 1

runMethod · 0.45

Tested by

no test coverage detected