https://github.com/svcvit/dify-sandbox-py
A code executor for Dify that is compatible with the official sandbox API calls and dependency installation.
https://github.com/svcvit/dify-sandbox-py
dify sandbox
Last synced: 5 months ago
JSON representation
A code executor for Dify that is compatible with the official sandbox API calls and dependency installation.
- Host: GitHub
- URL: https://github.com/svcvit/dify-sandbox-py
- Owner: svcvit
- License: mit
- Created: 2024-11-21T08:46:09.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-28T09:00:31.000Z (about 1 year ago)
- Last Synced: 2025-04-28T10:25:11.996Z (about 1 year ago)
- Topics: dify, sandbox
- Language: Python
- Homepage:
- Size: 2.54 MB
- Stars: 233
- Watchers: 5
- Forks: 51
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DIFY-SANDBOX-PY
[English](README.md) | [中文](README_CN.md)
A code executor for Dify that is compatible with the official sandbox API calls and dependency installation.
- Supports Python 3.12
- Supports Node.js 20
## Purpose
While the official sandbox has many permission settings and is a better sandboxing solution, in personal use cases where Dify's code nodes are entirely self-edited, there's no risk of code injection. This project aims to provide broader permissions and support for more dependencies (like numpy>2.0, matplotlib, scikit-learn) to reduce confusing error messages. This code was developed by referencing the official sandbox's API call examples.
## Usage
In the official docker-compose.yaml, locate the sandbox image section and replace it with:
```
sandbox:
# image: langgenius/dify-sandbox:0.2.10
image: svcvit/dify-sandbox-py:0.1.4
```
If you prefer to build the image yourself, you can clone this repository and run:
```
docker build -t dify-sandbox-py:local .
```
Then modify the sandbox image in `docker-compose.yaml` to use `dify-sandbox-py:local`
## Screenshots
Python support

Node.js support

Docker container logs

## Notes
- Network access restrictions have been removed; network access is enabled by default
- Using UV as the dependency manager for faster package installation, allowing millisecond-level dependency installation on restart
- Third-party dependencies can be installed following the official method: simply add required dependencies to `/docker/volumes/sandbox/dependencies/python-requirements.txt` and restart the sandbox
- The image only contains FastAPI-related dependencies. Any additional dependencies you need must be manually added to python-requirements.txt