Skip to content

Safe Python Code Execution Environment for Language Models

License

Notifications You must be signed in to change notification settings

Josh-XT/SafeExecute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SafeExecute

GitHub PayPal Ko-Fi

This module provides a safe way to execute Python code in a container. It is intended to be used with language models to enable them to execute code in a safe environment separate from the host machine (your computer or server).

The container comes preloaded with the following packages:

  • numpy
  • matplotlib
  • seaborn
  • scikit-learn
  • yfinance
  • scipy
  • statsmodels
  • sympy
  • bokeh
  • plotly
  • dash
  • networkx
  • pyvis
  • pandas

Installation

pip install safeexecute

Usage

You can pass an entire message from a langauge model into the code field and it will parse out any Python code blocks and execute them. If anywhere in the code says pip install <package>, it will install the package in the container before executing the code.

from safeexecute import execute_python_code

code = "print('Hello, World!')"
result = execute_python_code(code=code)
print(result)