Giter Site home page Giter Site logo

tgonzales / codeinterpreter-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shroominic/codeinterpreter-api

0.0 0.0 0.0 312 KB

Open source implementation of the ChatGPT Code Interpreter ๐Ÿ‘พ

Home Page: https://discord.gg/G9s2pqkuH4

License: MIT License

Python 100.00%

codeinterpreter-api's Introduction

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 -> Receive text + 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

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
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
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

MIT

Contact

You can contact me at [email protected]. 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

Star History Chart

codeinterpreter-api's People

Contributors

denizcandarcan avatar eltociear avatar gitmarco27 avatar hwaking avatar jakubgetme avatar juananpe avatar shroominic avatar valian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.