{"id":28190003,"url":"https://github.com/enso-labs/interpreter","last_synced_at":"2025-07-29T21:42:28.495Z","repository":{"id":259773724,"uuid":"824228751","full_name":"enso-labs/interpreter","owner":"enso-labs","description":"🛡️Secure and sandboxed API to execute Python code, upload files, install packages, and manage isolated sessions. Ideal for running untrusted code and ensuring application security.","archived":false,"fork":false,"pushed_at":"2025-06-24T00:08:09.000Z","size":45,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"development","last_synced_at":"2025-06-24T01:25:09.411Z","etag":null,"topics":["code-interpreter","fastapi","langchain","openai","promptengineering","python","sandbox"],"latest_commit_sha":null,"homepage":"https://github.com/promptengineers-ai","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/enso-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-04T16:24:32.000Z","updated_at":"2025-04-12T04:48:49.000Z","dependencies_parsed_at":"2024-10-28T00:05:56.712Z","dependency_job_id":"9b1eb364-ac23-4fec-b27c-27f38a54e24e","html_url":"https://github.com/enso-labs/interpreter","commit_stats":null,"previous_names":["promptengineers-ai/interpreter","enso-labs/interpreter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/enso-labs/interpreter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enso-labs%2Finterpreter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enso-labs%2Finterpreter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enso-labs%2Finterpreter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enso-labs%2Finterpreter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enso-labs","download_url":"https://codeload.github.com/enso-labs/interpreter/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enso-labs%2Finterpreter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267764423,"owners_count":24140850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-interpreter","fastapi","langchain","openai","promptengineering","python","sandbox"],"created_at":"2025-05-16T10:11:55.318Z","updated_at":"2025-07-29T21:42:28.474Z","avatar_url":"https://github.com/enso-labs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  🤖 Prompt Engineers AI - Secure Code Interpreter (Sandboxed) \n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://promptengineers-ai.gitbook.io/documentation/open-source\"\u003e\u003cimg src=\"https://img.shields.io/badge/View%20Documentation-Docs-yellow\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://join.slack.com/t/promptengineersai/shared_invite/zt-21upjsftv-gX~gNjTCU~2HfbeM_ZwTEQ\"\u003e\u003cimg src=\"https://img.shields.io/badge/Join%20our%20community-Slack-blue\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nUnlock the potential of executing Python code safely and efficiently with the Prompt Engineers AI - Secure Code Interpreter. This API provides a robust sandboxed environment where users can execute Python scripts, upload files, install packages, and manage sessions with complete isolation from your main application code. Each session is meticulously separated, ensuring that the code, files, and packages for one session do not interfere with others, thereby enhancing security and preventing potential conflicts.\n\nOur sandbox is designed with security as a top priority. By isolating execution environments, we mitigate risks associated with running untrusted code. This makes it an ideal solution for developers and organizations who need a safe and controlled way to execute scripts, test code snippets, or provide coding functionalities within their applications.\n\nKey Features:\n- 🛡️ **Secure Execution:** Run Python code in a sandboxed environment to ensure the applications remains secure and unaffected.\n- 📁 **File Management:** Upload and manage files within isolated sessions to maintain data integrity and security.\n- 📦 **Package Installation:** Install required Python packages per session without affecting the global environment.\n- 🕹️ **Session Management:** Efficiently create, manage, and terminate sessions to maintain clean and organized execution spaces.\n\n### Start Interpreter\n```bash\ndocker-compose up --build\n```\n\n### Test the Langchain Toolkit\n```bash\n## Change Directory\ncd toolkit\n\n## Create Virtual Env\npython3 -m venv .venv\nsource .venv/bin/activate\n\n## Install Dependencies\npip install -r requirements.txt\n\n## Run Script to view \u0026 test tool\npython interpreter.py\n```\n\n### Example Requests\n\nSimple Example\n\n```bash\ncurl -X POST http://localhost:8001/execute -H \"Content-Type: application/json\" -d '{\n  \"session_id\": \"your_session_id\",\n  \"code\": \"print(\\\"Hello from Interpreter!\\\")\"\n}'\n\n## Result\n# {\"status\":\"success\",\"output\":\"Hello from Interpreter!\\n\",\"errors\":\"\"}\n```\n\nExample curl Request (Verify will error when numpy is not installed):\n\n```bash\ncurl -X POST http://localhost:8001/execute -H \"Content-Type: application/json\" -d '{\n  \"session_id\": \"your_session_id\",\n  \"code\": \"import os\\nimport numpy as np\\na = int(os.getenv(\\\"VAR_A\\\"))\\nb = int(os.getenv(\\\"VAR_B\\\"))\\nc = int(os.getenv(\\\"VAR_C\\\"))\\narray = np.array([a, b, c])\\nresult = np.sum(array)\\nprint(f\\\"Result of summing [{a}, {b}, {c}] is: {result}\\\")\",\n  \"env\": {\n    \"VAR_A\": \"10\",\n    \"VAR_B\": \"20\",\n    \"VAR_C\": \"30\"\n  }\n}'\n\n## Result\n# {\"status\":\"success\",\"output\":\"\",\"errors\":\"Traceback (most recent call last):\\n  File \\\"/tmp/your_session_id/temp_code.py\\\", line 2, in \u003cmodule\u003e\\n    import numpy as np\\nModuleNotFoundError: No module named 'numpy'\\n\"}\n```\n\nExample curl Request (Install numpy and execute the code):\n\n```bash\ncurl -X POST http://localhost:8001/install -H \"Content-Type: application/json\" -d '{\n  \"session_id\": \"your_session_id\",\n  \"packages\": [\"numpy\"]\n}'\n\n## Result\n# {\"status\":\"success\",\"installed_packages\":[\"numpy\"]}\n```\n\nExecute numpy with Env vars\n\n```bash\ncurl -X POST http://localhost:8001/execute -H \"Content-Type: application/json\" -d '{\n  \"session_id\": \"your_session_id\",\n  \"code\": \"import os\\nimport numpy as np\\na = int(os.getenv(\\\"VAR_A\\\"))\\nb = int(os.getenv(\\\"VAR_B\\\"))\\nc = int(os.getenv(\\\"VAR_C\\\"))\\narray = np.array([a, b, c])\\nresult = np.sum(array)\\nprint(f\\\"Result of summing [{a}, {b}, {c}] is: {result}\\\")\",\n  \"env\": {\n    \"VAR_A\": \"10\",\n    \"VAR_B\": \"20\",\n    \"VAR_C\": \"30\"\n  }\n}'\n\n## Result\n# {\"status\":\"success\",\"output\":\"Result of summing [10, 20, 30] is: 60\\n\",\"errors\":\"\"}\n```\n\nExample curl Request (Verify numpy has been uninstalled):\n\n```bash\ncurl -X POST http://localhost:8001/terminate -H \"Content-Type: application/json\" -d '{\n  \"session_id\": \"your_session_id\"\n}'\n\n## Result\n# {\"status\":\"success\",\"message\":\"Session your_session_id terminated successfully.\"}\n\ncurl -X POST http://localhost:8001/execute -H \"Content-Type: application/json\" -d '{\n  \"session_id\": \"your_session_id\",\n  \"code\": \"import os\\nimport numpy as np\\na = int(os.getenv(\\\"VAR_A\\\"))\\nb = int(os.getenv(\\\"VAR_B\\\"))\\nc = int(os.getenv(\\\"VAR_C\\\"))\\narray = np.array([a, b, c])\\nresult = np.sum(array)\\nprint(f\\\"Result of summing [{a}, {b}, {c}] is: {result}\\\")\",\n  \"env\": {\n    \"VAR_A\": \"10\",\n    \"VAR_B\": \"20\",\n    \"VAR_C\": \"30\"\n  }\n}'\n\n## Result\n# {\"status\":\"success\",\"output\":\"\",\"errors\":\"Traceback (most recent call last):\\n  File \\\"/tmp/your_session_id/temp_code.py\\\", line 2, in \u003cmodule\u003e\\n    import numpy as np\\nModuleNotFoundError: No module named 'numpy'\\n\"}\n```\n\n### Execute against files\n\nUpload a file for a specific session.\n\n```bash\ncurl -X POST \"http://localhost:8001/upload\" \\\n  -H \"accept: application/json\" \\\n  -F \"session_id=your_session_id\" \\\n  -F \"file=@data/AAPL.csv\"\n\n## Result\n# {\"filename\":\"AAPL.csv\",\"location\":\"/tmp/your_session_id/AAPL.csv\"}\n```\n\nInstall pandas pacakage for created session to interact with csv.\n\n```bash\ncurl -X POST http://localhost:8001/install -H \"Content-Type: application/json\" -d '{\n  \"session_id\": \"your_session_id\",\n  \"packages\": [\"pandas\"]\n}'\n\n## Result\n# {\"status\":\"success\",\"installed_packages\":[\"pandas\"]}\n```\n\nExecute to interact with csv\n\n```bash\ncurl -X POST http://localhost:8001/execute -H \"Content-Type: application/json\" -d '{\n  \"session_id\": \"your_session_id\",\n  \"code\": \"import pandas as pd\\nfile_path = \\\"/tmp/your_session_id/AAPL.csv\\\"\\ndf = pd.read_csv(file_path)\\nfirst_row = df.iloc[0]\\nprint(first_row.to_json())\"\n}'\n\n## Result\n# {\"status\":\"success\",\"output\":\"{\\\"Date\\\":\\\"2022-03-16\\\",\\\"Open\\\":157.050003,\\\"High\\\":160.0,\\\"Low\\\":154.460007,\\\"Close\\\":159.589996,\\\"Adj Close\\\":158.629059,\\\"Volume\\\":102300200}\\n\",\"errors\":\"\"}\n```\n\nDownload file from session\n\n```bash\ncurl -X GET \"http://localhost:8001/download?session_id=your_session_id\u0026filename=AAPL.csv\" -o AAPL_downloaded.csv\n\n## Result\n# File downloaded to workspace\n```\n\nTerminate session to uninstall pacakges and remove files.\n\n```bash\ncurl -X POST http://localhost:8001/terminate -H \"Content-Type: application/json\" -d '{\n  \"session_id\": \"your_session_id\"\n}'\n\n## Result\n# {\"status\":\"success\",\"message\":\"Session your_session_id terminated successfully.\"}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenso-labs%2Finterpreter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenso-labs%2Finterpreter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenso-labs%2Finterpreter/lists"}