PythonExecutorToolkit
PythonExecutorToolkit
Bases: AsyncBaseToolkit
A tool for executing Python code in a sandboxed environment.
Source code in utu/tools/python_executor_toolkit.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
execute_python_code
async
execute_python_code(
code: str,
workdir: str = "./run_workdir",
timeout: int = 30,
) -> dict
Executes Python code and returns the output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
code
|
str
|
The Python code to execute. |
required |
workdir
|
str
|
The working directory for the execution. Defaults to "./run_workdir". |
'./run_workdir'
|
timeout
|
int
|
The execution timeout in seconds. Defaults to 30. |
30
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the execution results. |
Source code in utu/tools/python_executor_toolkit.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
get_tools_map_func
async
get_tools_map_func() -> dict[str, Callable]
Get tools map. It will filter tools by config.activated_tools if it is not None.
Source code in utu/tools/base.py
58 59 60 61 62 63 64 65 66 67 68 69 |
|
get_tools_in_agents
async
get_tools_in_agents() -> list[FunctionTool]
Get tools in openai-agents format.
Source code in utu/tools/base.py
71 72 73 74 75 76 77 78 79 80 81 82 |
|
get_tools_in_openai
async
get_tools_in_openai() -> list[dict]
Get tools in OpenAI format.
Source code in utu/tools/base.py
84 85 86 87 |
|
get_tools_in_mcp
async
get_tools_in_mcp() -> list[Tool]
Get tools in MCP format.
Source code in utu/tools/base.py
89 90 91 92 |
|
call_tool
async
call_tool(name: str, arguments: dict) -> str
Call a tool by its name.
Source code in utu/tools/base.py
94 95 96 97 98 99 100 |
|