codeinterpreterapi-hyperobjekt


Namecodeinterpreterapi-hyperobjekt JSON
Version 0.0.16 PyPI version JSON
download
home_pagehttps://github.com/hyperobjekt/code-interpreter
SummaryCodeInterpreterAPI is an (unofficial) open source python interface for the ChatGPT CodeInterpreter.
upload_time2023-08-22 16:47:33
maintainer
docs_urlNone
authorHyperobjekt
requires_python>=3.9, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*, !=3.8.*
licenseMIT
keywords codeinterpreter_hyperobjekt chatgpt codeinterpreterapi_hyperobjekt api langchain codeboxapi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Code Interpreter API

A LangChain implementation of the ChatGPT Code Interpreter.
Using CodeBoxes as backend for sandboxed python code execution.
[CodeBox](https://github.com/shroominic/codebox-api/tree/main) 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](https://platform.openai.com/account/api-keys) and install the package.

```bash
pip install "codeinterpreterapi_hyperobjekt[all]"
```

Everything for local experiments are installed with the `all` extra.
For deployments, you can use `pip install codeinterpreterapi_hyperobjekt` instead which does not install the additional dependencies.

## Usage

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.

```python
from codeinterpreterapi_hyperobjekt 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](https://github.com/shroominic/codeinterpreter_hyperobjekt-api/blob/main/examples/assets/bitcoin_chart.png?raw=true)
Bitcoin YTD Chart Output

## Dataset Analysis

```python
from codeinterpreterapi_hyperobjekt 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](https://github.com/shroominic/codeinterpreter_hyperobjekt-api/blob/main/examples/assets/iris_analysis.png?raw=true)
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:

```bash
streamlit run frontend/app.py
```

## License

[MIT](https://choosealicense.com/licenses/mit/)

## Contact

You can contact me at [contact@shroominic.com](mailto:contact@shroominic.com).
But I prefer to use [Twitter](https://twitter.com/shroominic) or [Discord](https://discord.gg/QYzBtq37) DMs.

## Support this project

If you would like to help this project with a donation, you can [click here](https://ko-fi.com/shroominic).
Thanks, this helps a lot! ❤️

## Star History

<a href="https://star-history.com/#shroominic/codeinterpreter_hyperobjekt-api&Date">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=shroominic/codeinterpreter_hyperobjekt-api&type=Date&theme=dark" />
    <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=shroominic/codeinterpreter_hyperobjekt-api&type=Date" />
    <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=shroominic/codeinterpreter_hyperobjekt-api&type=Date" />
  </picture>
</a>


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hyperobjekt/code-interpreter",
    "name": "codeinterpreterapi-hyperobjekt",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*, !=3.8.*",
    "maintainer_email": "",
    "keywords": "codeinterpreter_hyperobjekt,chatgpt,codeinterpreterapi_hyperobjekt,api,langchain,codeboxapi",
    "author": "Hyperobjekt",
    "author_email": "info@hyperobjekt.com",
    "download_url": "https://files.pythonhosted.org/packages/6c/d9/1dcad42fcc2e43596460145bf78c8b8747481d023a5d71815a8e328a8ceb/codeinterpreterapi_hyperobjekt-0.0.16.tar.gz",
    "platform": null,
    "description": "# Code Interpreter API\n\nA LangChain implementation of the ChatGPT Code Interpreter.\nUsing CodeBoxes as backend for sandboxed python code execution.\n[CodeBox](https://github.com/shroominic/codebox-api/tree/main) is the simplest cloud infrastructure for your LLM Apps.\nYou can run everything local except the LLM using your own OpenAI API Key.\n\n## Features\n\n- Dataset Analysis, Stock Charting, Image Manipulation, ....\n- Internet access and auto Python package installation\n- Input `text + files` -> Receive `text + files`\n- Conversation Memory: respond based on previous inputs\n- Run everything local except the OpenAI API (OpenOrca or others maybe soon)\n- Use CodeBox API for easy scaling in production (coming soon)\n\n## Installation\n\nGet your OpenAI API Key [here](https://platform.openai.com/account/api-keys) and install the package.\n\n```bash\npip install \"codeinterpreterapi_hyperobjekt[all]\"\n```\n\nEverything for local experiments are installed with the `all` extra.\nFor deployments, you can use `pip install codeinterpreterapi_hyperobjekt` instead which does not install the additional dependencies.\n\n## Usage\n\nTo configure OpenAI and Azure OpenAI, ensure that you set the appropriate environment variables (or use a .env file):\n\nFor OpenAI, set the OPENAI_API_KEY environment variable:\n\n```\nexport OPENAI_API_KEY=your_openai_api_key\n```\n\nFor Azure OpenAI, set the following environment variables:\n\n```\nexport OPENAI_API_TYPE=azure\nexport OPENAI_API_VERSION=your_api_version\nexport OPENAI_API_BASE=your_api_base\nexport OPENAI_API_KEY=your_azure_openai_api_key\nexport DEPLOYMENT_NAME=your_deployment_name\n```\n\nRemember to replace the placeholders with your actual API keys and other required information.\n\n```python\nfrom codeinterpreterapi_hyperobjekt import CodeInterpreterSession\n\n\nasync def main():\n    # create a session\n    session = CodeInterpreterSession()\n    await session.astart()\n\n    # generate a response based on user input\n    response = await session.generate_response(\n        \"Plot the bitcoin chart of 2023 YTD\"\n    )\n\n    # output the response (text + image)\n    print(\"AI: \", response.content)\n    for file in response.files:\n        file.show_image()\n\n    # terminate the session\n    await session.astop()\n\n\nif __name__ == \"__main__\":\n    import asyncio\n    # run the async function\n    asyncio.run(main())\n\n```\n\n![Bitcoin YTD](https://github.com/shroominic/codeinterpreter_hyperobjekt-api/blob/main/examples/assets/bitcoin_chart.png?raw=true)\nBitcoin YTD Chart Output\n\n## Dataset Analysis\n\n```python\nfrom codeinterpreterapi_hyperobjekt import CodeInterpreterSession, File\n\n\nasync def main():\n    # context manager for auto start/stop of the session\n    async with CodeInterpreterSession() as session:\n        # define the user request\n        user_request = \"Analyze this dataset and plot something interesting about it.\"\n        files = [\n            File.from_path(\"examples/assets/iris.csv\"),\n        ]\n\n        # generate the response\n        response = await session.generate_response(\n            user_request, files=files\n        )\n\n        # output to the user\n        print(\"AI: \", response.content)\n        for file in response.files:\n            file.show_image()\n\n\nif __name__ == \"__main__\":\n    import asyncio\n\n    asyncio.run(main())\n```\n\n![Iris Dataset Analysis](https://github.com/shroominic/codeinterpreter_hyperobjekt-api/blob/main/examples/assets/iris_analysis.png?raw=true)\nIris Dataset Analysis Output\n\n## Production\n\nIn case you want to deploy to production, you can utilize the CodeBox API for seamless scalability.\n\nPlease contact me if you are interested in this, as it is still in the early stages of development.\n\n## Contributing\n\nThere are some remaining TODOs in the code.\nSo, if you want to contribute, feel free to do so.\nYou can also suggest new features. Code refactoring is also welcome.\nJust open an issue or pull request and I will review it.\n\nPlease also submit any bugs you find as an issue with a minimal code example or screenshot.\nThis helps me a lot in improving the code.\n\nThanks!\n\n## Streamlit WebApp\n\nTo start the web application created with streamlit:\n\n```bash\nstreamlit run frontend/app.py\n```\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n\n## Contact\n\nYou can contact me at [contact@shroominic.com](mailto:contact@shroominic.com).\nBut I prefer to use [Twitter](https://twitter.com/shroominic) or [Discord](https://discord.gg/QYzBtq37) DMs.\n\n## Support this project\n\nIf you would like to help this project with a donation, you can [click here](https://ko-fi.com/shroominic).\nThanks, this helps a lot! \u2764\ufe0f\n\n## Star History\n\n<a href=\"https://star-history.com/#shroominic/codeinterpreter_hyperobjekt-api&Date\">\n  <picture>\n    <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/svg?repos=shroominic/codeinterpreter_hyperobjekt-api&type=Date&theme=dark\" />\n    <source media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/svg?repos=shroominic/codeinterpreter_hyperobjekt-api&type=Date\" />\n    <img alt=\"Star History Chart\" src=\"https://api.star-history.com/svg?repos=shroominic/codeinterpreter_hyperobjekt-api&type=Date\" />\n  </picture>\n</a>\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "CodeInterpreterAPI is an (unofficial) open source python interface for the ChatGPT CodeInterpreter.",
    "version": "0.0.16",
    "project_urls": {
        "Homepage": "https://github.com/hyperobjekt/code-interpreter",
        "Repository": "https://github.com/hyperobjekt/code-interpreter"
    },
    "split_keywords": [
        "codeinterpreter_hyperobjekt",
        "chatgpt",
        "codeinterpreterapi_hyperobjekt",
        "api",
        "langchain",
        "codeboxapi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dee9ec68259adb1999a3906c926ad0f0d3a23da0fea62e0c85b4ecb47390f9ea",
                "md5": "7a696299572405c656192785f02c0a23",
                "sha256": "c4c3f0efdc3a5d02c6c33aef9efe59305fa3c2690356aabc5d636cdb4ad9b3e6"
            },
            "downloads": -1,
            "filename": "codeinterpreterapi_hyperobjekt-0.0.16-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a696299572405c656192785f02c0a23",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*, !=3.8.*",
            "size": 23148,
            "upload_time": "2023-08-22T16:47:31",
            "upload_time_iso_8601": "2023-08-22T16:47:31.332498Z",
            "url": "https://files.pythonhosted.org/packages/de/e9/ec68259adb1999a3906c926ad0f0d3a23da0fea62e0c85b4ecb47390f9ea/codeinterpreterapi_hyperobjekt-0.0.16-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6cd91dcad42fcc2e43596460145bf78c8b8747481d023a5d71815a8e328a8ceb",
                "md5": "3791207d18ce1431bb7f4ed94e4e1718",
                "sha256": "aa31b84ca0c299ac37d627f6f330eee0a64a6578017f06a156190b16b2777961"
            },
            "downloads": -1,
            "filename": "codeinterpreterapi_hyperobjekt-0.0.16.tar.gz",
            "has_sig": false,
            "md5_digest": "3791207d18ce1431bb7f4ed94e4e1718",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*, !=3.8.*",
            "size": 17939,
            "upload_time": "2023-08-22T16:47:33",
            "upload_time_iso_8601": "2023-08-22T16:47:33.311403Z",
            "url": "https://files.pythonhosted.org/packages/6c/d9/1dcad42fcc2e43596460145bf78c8b8747481d023a5d71815a8e328a8ceb/codeinterpreterapi_hyperobjekt-0.0.16.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-22 16:47:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hyperobjekt",
    "github_project": "code-interpreter",
    "github_not_found": true,
    "lcname": "codeinterpreterapi-hyperobjekt"
}
        
Elapsed time: 0.12187s