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.
- 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)
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.
To configure OpenAI and Azure OpenAI, ensure that you set the appropriate environment variables (or use a .env file):
For OpenAI, set the OPENAI_API_KEY environment variable:
export OPENAI_API_KEY=your_openai_api_key
For Azure OpenAI, set the following environment variables:
export OPENAI_API_TYPE=azure
export OPENAI_API_VERSION=your_api_version
export OPENAI_API_BASE=your_api_base
export OPENAI_API_KEY=your_azure_openai_api_key
export DEPLOYMENT_NAME=your_deployment_name
Remember to replace the placeholders with your actual API keys and other required information.
from codeinterpreterapi import CodeInterpreterSession, settings
# set api key (or automatically loads from env vars)
settings.OPENAI_API_KEY = "sk-***************"
# create a session
with CodeInterpreterSession() as session:
# generate a response based on user input
response = session.generate_response(
"Plot the bitcoin chart of year 2023"
)
# output the response
response.show()
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())
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.
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!
To start the web application created with streamlit:
streamlit run frontend/app.py --browser.gatherUsageStats=False
You can contact me at [email protected]. But I prefer to use Twitter or Discord DMs.
If you would like to help this project with a donation, you can click here. Thanks, this helps a lot! โค๏ธ
codeinterpreter-api's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.