Skip to content

Instantly share code, notes, and snippets.

@vndee
Last active July 11, 2024 14:54
Show Gist options
  • Save vndee/1725c06e7df15001d5fc5fa321e38e50 to your computer and use it in GitHub Desktop.
Save vndee/1725c06e7df15001d5fc5fa321e38e50 to your computer and use it in GitHub Desktop.
from llm_sandbox import SandboxSession
with SandboxSession(lang="python", keep_template=True) as session:
# Copy a file from the host to the sandbox
session.copy_to_runtime("test.py", "/sandbox/test.py")
# Run the copied Python code in the sandbox
result = session.run("python /sandbox/test.py")
print(result)
# Copy a file from the sandbox to the host
session.copy_from_runtime("/sandbox/output.txt", "output.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment