Home

Awesome

Code Sandbox

A secure sandbox for running and judging code generated by LLMs.

Please view the complete documentation at https://bytedance.github.io/SandboxFusion/ .

Table of Contents

Features

Code Runner: Run and return the result of a code snippet

Supported languages:

Jupyter mode kernels:

Online Judge: Implementation of Evaluation & RL datasets that requires code running

Contributing

Installation

Docker

Build the image locally:

docker build -f ./scripts/Dockerfile.base -t code_sandbox:base
# change the base image in Dockerfile.server
sed -i '1s/.*/FROM code_sandbox:base/' ./scripts/Dockerfile.server
docker build -f ./scripts/Dockerfile.server -t code_sandbox:server
docker run -d --rm --privileged -p 8080:8080 code_sandbox:server make run-online

Manual

Prerequisites: conda, poetry

To install the sandbox service:

conda create -n sandbox -y python=3.12
conda activate sandbox
poetry install
make run-online

Please refer to scripts/Dockerfile.base for the runtime of each supported language, and scripts/Dockerfile.server for the installation of extra packages for python and nodejs.

Dev & Test

Refer to installation section for the setup of development environment.

Run all unit tests:

make test

Run a specific unit test (allows you to see stdout):

make test-case CASE=test_java_assert

Run a specific unit test with pdb:

make test-case-pdb CASE=test_java_assert

Format the code:

make format

License

Copyright 2024 Bytedance Ltd. and/or its affiliates

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contributors

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/ssine"><img src="https://avatars.githubusercontent.com/u/20841764?v=4?s=100" width="100px;" alt="sine"/><br /><sub><b>sine</b></sub></a><br /><a href="#code-ssine" title="Code">💻</a> <a href="#data-ssine" title="Data">🔣</a> <a href="#design-ssine" title="Design">🎨</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/liuq901"><img src="https://avatars.githubusercontent.com/u/4028828?v=4?s=100" width="100px;" alt="Qi Liu"/><br /><sub><b>Qi Liu</b></sub></a><br /><a href="#code-liuq901" title="Code">💻</a> <a href="#data-liuq901" title="Data">🔣</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/BytedSS0"><img src="https://avatars.githubusercontent.com/u/186129147?v=4?s=100" width="100px;" alt="Shulin.Xin"/><br /><sub><b>Shulin.Xin</b></sub></a><br /><a href="#code-BytedSS0" title="Code">💻</a> <a href="#data-BytedSS0" title="Data">🔣</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/cattaria"><img src="https://avatars.githubusercontent.com/u/10678783?v=4?s=100" width="100px;" alt="可爱猫猫是梓喵"/><br /><sub><b>可爱猫猫是梓喵</b></sub></a><br /><a href="#code-cattaria" title="Code">💻</a> <a href="#data-cattaria" title="Data">🔣</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/lseven-rs"><img src="https://avatars.githubusercontent.com/u/189442484?v=4?s=100" width="100px;" alt="Xingwen Li"/><br /><sub><b>Xingwen Li</b></sub></a><br /><a href="#design-lseven-rs" title="Design">🎨</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/aoyanli"><img src="https://avatars.githubusercontent.com/u/186133689?v=4?s=100" width="100px;" alt="aoyanli"/><br /><sub><b>aoyanli</b></sub></a><br /><a href="#code-aoyanli" title="Code">💻</a> <a href="#data-aoyanli" title="Data">🔣</a></td> <td align="center" valign="top" width="14.28%"><a href="https://magic3007.github.io"><img src="https://avatars.githubusercontent.com/u/30785720?v=4?s=100" width="100px;" alt="Magic Mai"/><br /><sub><b>Magic Mai</b></sub></a><br /><a href="#code-magic3007" title="Code">💻</a> <a href="#data-magic3007" title="Data">🔣</a></td> </tr> </tbody> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->