Code Interpreter API
A LangChain implementation of the ChatGPT Code Interpreter. Using CodeBoxes as backend for sandboxed python code execution. CodeBox is the simplest cloud infrastructure for your LLM Apps. You can run everything local except the LLM using your own OpenAI API Key.
Features
- Dataset Analysis, Stock Charting, Image Manipulation, ....
- Internet access and auto Python package installation
- Input
text + files-> Receivetext + files - Conversation Memory: respond based on previous inputs
- Run everything local except the OpenAI API (OpenOrca or others maybe soon)
- Use CodeBox API for easy scaling in production (coming soon)
Installation
Get your OpenAI API Key here and install the package.
pip install "codeinterpreterapi[all]"
Everything for local experiments are installed with the all extra.
For deployments, you can use pip install codeinterpreterapi instead which does not install the additional dependencies.
Usage
Make sure to set the OPENAI_API_KEY environment variable (or use a .env file)
from codeinterpreterapi import CodeInterpreterSession
async def main():
# create a session
session = CodeInterpreterSession()
await session.astart()
# generate a response based on user input
response = await session.generate_response(
"Plot the bitcoin chart of 2023 YTD"
)
# output the response (text + image)
print("AI: ", response.content)
for file in response.files:
file.show_image()
# terminate the session
await session.astop()
if __name__ == "__main__":
import asyncio
# run the async function
asyncio.run(main())
Bitcoin YTD Chart Output
Dataset Analysis
from codeinterpreterapi import CodeInterpreterSession, File
async def main():
# context manager for auto start/stop of the session
async with CodeInterpreterSession() as session:
# define the user request
user_request = "Analyze this dataset and plot something interesting about it."
files = [
File.from_path("examples/assets/iris.csv"),
]
# generate the response
response = await session.generate_response(
user_request, files=files
)
# output to the user
print("AI: ", response.content)
for file in response.files:
file.show_image()
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Iris Dataset Analysis Output
Production
In case you want to deploy to production, you can utilize the CodeBox API for seamless scalability.
Please contact me if you are interested in this, as it is still in the early stages of development.
Contributing
There are some remaining TODOs in the code. So, if you want to contribute, feel free to do so. You can also suggest new features. Code refactoring is also welcome. Just open an issue or pull request and I will review it.
Please also submit any bugs you find as an issue with a minimal code example or screenshot. This helps me a lot in improving the code.
Thanks!
Streamlit WebApp
To start the web application created with streamlit:
streamlit run frontend/app.py
License
Contact
You can contact me at contact@shroominic.com. But I prefer to use Twitter or Discord DMs.
Support this project
If you would like to help this project with a donation, you can click here. Thanks, this helps a lot! ❤️
Star History
Metadata
Release files for gpt-code-interpreter 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gpt_code_interpreter-0.0.3.tar.gz | 16.2 kB | Without provenance | Details for gpt_code_interpreter-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gpt_code_interpreter-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for gpt_code_interpreter-0.0.3-py3-none-any.whl |
Total release size: 37.1 kB
Release files / gpt_code_interpreter-0.0.3.tar.gz
| Download URL | gpt_code_interpreter-0.0.3.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7382517db9939376be1ce5d92309c84bbee4d0138f12cfc999b819c76026be5f
|
|
BLAKE2b-256 checksum How to use checksums |
1d2f34b9bdac629df147a122ebe1b3bdc11678400d53f78eee45cd42776b5b70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Darwin/22.6.0
|
Release files / gpt_code_interpreter-0.0.3-py3-none-any.whl
| Download URL | gpt_code_interpreter-0.0.3-py3-none-any.whl |
|---|---|
| Size | 20.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be93e3802d0c4be953b9d70f1543a90f6f11f3828fc53f4b941722d83f92834f
|
|
BLAKE2b-256 checksum How to use checksums |
333473f02968289f4d8b612ccd580a5d0f7483c0f892604eef5e39d55081017c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Darwin/22.6.0
|
Security for gpt-code-interpreter 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.