Package: codeinterpreterapi-warren
Code Interpreter APIA LangChain implementation of the ChatGPT Code Interpreter.
Using CodeBoxes as backend for sandboxed python code execution.CodeBoxis the simplest cloud infrastructure for your LLM Apps.
You can run everything local except the LLM using your own OpenAI API Key.FeaturesDataset Analysis, Stock Charting, Image Manipulation, ....Internet access and auto Python package installationInputtext + files-> Receivetext + filesConversation Memory: respond based on previous inputsRun everything local except the OpenAI API (OpenOrca or others maybe soon)Use CodeBox API for easy scaling in production (coming soon)InstallationGet your OpenAI API Keyhereand install the package.pipinstall"codeinterpreterapi[all]"Everything for local experiments are installed with theallextra.
For deployments, you can usepip install codeinterpreterapiinstead which does not install the additional dependencies.UsageTo 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_keyFor 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_nameRemember to replace the placeholders with your actual API keys and other required information.fromcodeinterpreterapiimportCodeInterpreterSessionasyncdefmain():# create a sessionsession=CodeInterpreterSession()awaitsession.astart()# generate a response based on user inputresponse=awaitsession.generate_response("Plot the bitcoin chart of 2023 YTD")# output the response (text + image)print("AI: ",response.content)forfileinresponse.files:file.show_image()# terminate the sessionawaitsession.astop()if__name__=="__main__":importasyncio# run the async functionasyncio.run(main())Bitcoin YTD Chart OutputDataset AnalysisfromcodeinterpreterapiimportCodeInterpreterSession,Fileasyncdefmain():# context manager for auto start/stop of the sessionasyncwithCodeInterpreterSession()assession:# define the user requestuser_request="Analyze this dataset and plot something interesting about it."files=[File.from_path("examples/assets/iris.csv"),]# generate the responseresponse=awaitsession.generate_response(user_request,files=files)# output to the userprint("AI: ",response.content)forfileinresponse.files:file.show_image()if__name__=="__main__":importasyncioasyncio.run(main())Iris Dataset Analysis OutputProductionIn 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.ContributingThere 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 WebAppTo start the web application created with streamlit:streamlitrunfrontend/app.pyLicenseMITContactYou can contact me atcontact@shroominic.com.
But I prefer to useTwitterorDiscordDMs.Support this projectIf you would like to help this project with a donation, you canclick here.
Thanks, this helps a lot! ❤️Star History