CodeInterpreterAPI is an (unofficial) open source python interface for the ChatGPT CodeInterpreter.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gpt_code_interpreter-0.0.1.tar.gz
.
File metadata
- Download URL: gpt_code_interpreter-0.0.1.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edae640e3b4b5c49ae017a6dc183f8cb5468f95de9a94ca6300c9344b0bd5a75 |
|
MD5 | 7d7304e46409c86901e66f3dd1f6b63f |
|
BLAKE2b-256 | 73488c665961a5ef57975e4a8fc89f5ce9119e5d0aa8f4049f8efaf6dd3eb3e7 |
File details
Details for the file gpt_code_interpreter-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: gpt_code_interpreter-0.0.1-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73e3cddb5ae5e3dc8cbc19e6f7d22fc5903ade76c553eca6f82e1dc5da516d8b |
|
MD5 | d510db6189b124a745b3d3d95d9bcec5 |
|
BLAKE2b-256 | 5040ee2e97c8d8e13cec3b6725c1241c0484f56fdf14a280b744a36fc68c5a64 |