Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: shroominic/codeinterpreter-api
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.12
Choose a base ref
...
head repository: shroominic/codeinterpreter-api
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Aug 23, 2023

  1. Copy the full SHA
    3f92983 View commit details
  2. Merge pull request #98 from tjroamer/main

    Use ProactorEventLoop to run frontend app on Windows
    shroominic authored Aug 23, 2023
    Copy the full SHA
    0feb803 View commit details

Commits on Aug 26, 2023

  1. Copy the full SHA
    d809c35 View commit details

Commits on Aug 28, 2023

  1. Copy the full SHA
    7ef01d8 View commit details
  2. 🧼 cleanup and move vars/config to settings

    + openrouter
    shroominic committed Aug 28, 2023
    Copy the full SHA
    816bfab View commit details
  3. 🅰️ fix typing

    shroominic committed Aug 28, 2023
    Copy the full SHA
    646fb9a View commit details
  4. Copy the full SHA
    59686d7 View commit details
  5. Copy the full SHA
    5cf3a1f View commit details

Commits on Sep 1, 2023

  1. improvements

    shroominic committed Sep 1, 2023
    Copy the full SHA
    2cdb5e2 View commit details

Commits on Sep 3, 2023

  1. ⚙️ settings interface

    shroominic committed Sep 3, 2023
    Copy the full SHA
    dd75880 View commit details
  2. 🔧 update config params

    shroominic committed Sep 3, 2023
    Copy the full SHA
    9ca775b View commit details
  3. 📟 ChatCLI Example

    shroominic committed Sep 3, 2023
    Copy the full SHA
    80cbbab View commit details
  4. 🛠️ improvements

    - package install
    - logging
    - prompt fixes
    - typing
    shroominic committed Sep 3, 2023
    Copy the full SHA
    c11a2f1 View commit details
  5. 📑 add file logging

    shroominic committed Sep 3, 2023
    Copy the full SHA
    b7cdf3a View commit details
  6. 📜 documentation setup

    shroominic committed Sep 3, 2023
    Copy the full SHA
    668fa2c View commit details
  7. ⬆️ update deps

    shroominic committed Sep 3, 2023
    Copy the full SHA
    d3f1a8a View commit details
  8. 🧼 cleanup

    shroominic committed Sep 3, 2023
    Copy the full SHA
    43f0965 View commit details
  9. 🎨 fix formatting

    shroominic committed Sep 3, 2023
    Copy the full SHA
    977b727 View commit details
  10. Copy the full SHA
    75c4edb View commit details
  11. Merge pull request #104 from bitsnaps/main

    fix: frontend module not found
    shroominic authored Sep 3, 2023
    Copy the full SHA
    065470a View commit details
  12. System message improved, added in ability to install packages using s…

    …ession.install_packages (#106)
    
    * Update poetry.lock
    
    * Update system message to be more specific
    
    * Update system message to be even more specific
    
    * System message encourage install missing packages
    
    * Added install_package to add packages after start
    
    * Update install_packages to take in array
    
    ---------
    
    Co-authored-by: Dominic <34897716+shroominic@users.noreply.github.com>
    salvinoto and shroominic authored Sep 3, 2023
    Copy the full SHA
    b408c00 View commit details
  13. Copy the full SHA
    4e2e32e View commit details
  14. ⬆️ update deps

    shroominic committed Sep 3, 2023
    Copy the full SHA
    e4c8159 View commit details
  15. Copy the full SHA
    7c653ba View commit details
  16. 🔖 model_name fix

    shroominic committed Sep 3, 2023
    Copy the full SHA
    2e99626 View commit details

Commits on Sep 4, 2023

  1. Copy the full SHA
    955c06d View commit details
  2. Copy the full SHA
    4e26364 View commit details
  3. expose callbacks param (#110)

    * expose callbacks
    
    * format
    
    * ref
    
    ---------
    
    Co-authored-by: Dominic <34897716+shroominic@users.noreply.github.com>
    kdcokenny and shroominic authored Sep 4, 2023
    Copy the full SHA
    4d0131c View commit details

Commits on Sep 5, 2023

  1. Copy the full SHA
    4386ebe View commit details
  2. Copy the full SHA
    17cbe13 View commit details
  3. Copy the full SHA
    7c2231f View commit details
  4. Copy the full SHA
    c25ab95 View commit details

Commits on Sep 29, 2023

  1. Copy the full SHA
    ba6a40e View commit details
  2. 🧽 cleanup

    shroominic committed Sep 29, 2023
    Copy the full SHA
    63aa5c8 View commit details
  3. ✂️ fix schema

    shroominic committed Sep 29, 2023
    Copy the full SHA
    4f630cd View commit details
  4. 🔨 fix tool error

    shroominic committed Sep 29, 2023
    Copy the full SHA
    c290aa2 View commit details
  5. ⬆️ v0.0.13

    - fix tool bug
    - interface improvements
    - chatcli example
    - cleanup
    shroominic committed Sep 29, 2023
    Copy the full SHA
    e2c9759 View commit details
  6. fixes app.py to make it run (#122)

    Co-authored-by: dgedgafo <daniil.gedgafov@pepperdine.edu>
    Co-authored-by: Dominic <34897716+shroominic@users.noreply.github.com>
    3 people authored Sep 29, 2023
    Copy the full SHA
    5243f69 View commit details
  7. 🛠️ fix isort

    shroominic committed Sep 29, 2023
    Copy the full SHA
    48b5dde View commit details

Commits on Oct 4, 2023

  1. Bump pillow from 9.5.0 to 10.0.1 (#126)

    Bumps [pillow](https://github.com/python-pillow/Pillow) from 9.5.0 to 10.0.1.
    - [Release notes](https://github.com/python-pillow/Pillow/releases)
    - [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
    - [Commits](python-pillow/Pillow@9.5.0...10.0.1)
    
    ---
    updated-dependencies:
    - dependency-name: pillow
      dependency-type: direct:production
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Oct 4, 2023
    Copy the full SHA
    e1ad827 View commit details
  2. Bump urllib3 from 2.0.5 to 2.0.6 (#123)

    Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.0.5 to 2.0.6.
    - [Release notes](https://github.com/urllib3/urllib3/releases)
    - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
    - [Commits](urllib3/urllib3@v2.0.5...2.0.6)
    
    ---
    updated-dependencies:
    - dependency-name: urllib3
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Dominic <34897716+shroominic@users.noreply.github.com>
    dependabot[bot] and shroominic authored Oct 4, 2023
    Copy the full SHA
    4725eb5 View commit details

Commits on Oct 10, 2023

  1. Copy the full SHA
    c7e242f View commit details
  2. made changes in function_agent.py file (#124)

    Co-authored-by: THEAVINASHREDDY <avinashreddy1233@gmail.com>
    Co-authored-by: Dominic <34897716+shroominic@users.noreply.github.com>
    3 people authored Oct 10, 2023
    Copy the full SHA
    147f09a View commit details
  3. ⬆️ update langchain v

    shroominic committed Oct 10, 2023
    Copy the full SHA
    dfda8b7 View commit details
  4. Copy the full SHA
    9dd2e82 View commit details

Commits on Oct 16, 2023

  1. adding docs (#134)

    goudete authored Oct 16, 2023
    Copy the full SHA
    c3c91b4 View commit details

Commits on Oct 18, 2023

  1. Fixed newline SyntaxError (#136)

    * Update session.py
    
    Resolves SyntaxError: unterminated string literal issue where multi-line code strings are not processed correctly if they're not formatted in compliance with Python's string literal rules. Specifically, the interpreter fails when the code string starts with a newline right after the opening quote or doesn't use triple quotes for multi-line code snippets. This leads to an unended string literal error because the interpreter expects a complete string format as per Python syntax rules.
    
    * Fixed newline SyntaxError
    
    Added some prompting to the python tool to resolve SyntaxError: unterminated string literal where multi-line code strings are not processed correctly if they're not formatted in compliance with Python's string literal rules. Specifically, the interpreter fails when the code string starts with a newline right after the opening quote or doesn't use triple quotes for multi-line code snippets. This leads to an unended string literal error because the interpreter expects a complete string format as per Python syntax rules.
    erickfm authored Oct 18, 2023
    Copy the full SHA
    5d3b827 View commit details

Commits on Oct 22, 2023

  1. Copy the full SHA
    2789429 View commit details
  2. 📜 update docs

    shroominic committed Oct 22, 2023
    Copy the full SHA
    2fbd51c View commit details

Commits on Oct 23, 2023

  1. Copy the full SHA
    670e926 View commit details
Showing with 1,932 additions and 4,941 deletions.
  1. +25 −0 .github/workflows/ci.yml
  2. +0 −22 .github/workflows/code-check.yml
  3. +6 −100 .gitignore
  4. +0 −27 .pre-commit-config.yaml
  5. +2 −2 LICENSE
  6. +25 −64 README.md
  7. +0 −4 codeinterpreterapi/__init__.py
  8. +0 −3 codeinterpreterapi/agents/__init__.py
  9. +0 −2 codeinterpreterapi/agents/custom_agent.py
  10. +0 −348 codeinterpreterapi/agents/functions_agent.py
  11. +0 −25 codeinterpreterapi/config.py
  12. +0 −74 codeinterpreterapi/parser.py
  13. +0 −17 codeinterpreterapi/prompts/system_message.py
  14. +0 −13 codeinterpreterapi/schema/__init__.py
  15. +0 −9 codeinterpreterapi/schema/input.py
  16. +0 −36 codeinterpreterapi/schema/response.py
  17. +0 −10 codeinterpreterapi/schema/status.py
  18. +21 −0 dev-setup.sh
  19. +18 −0 docs/bitcoin_chart.md
  20. +9 −0 docs/code_interpreter_response.md
  21. +38 −0 docs/code_interpreter_session.md
  22. +25 −0 docs/codebox.md
  23. +9 −0 docs/concepts_overview.md
  24. +36 −0 docs/deploy.md
  25. +24 −0 docs/file.md
  26. +25 −0 docs/index.md
  27. +34 −0 docs/installation.md
  28. +33 −0 docs/iris_dataset.md
  29. +85 −0 docs/settings.md
  30. +16 −0 docs/streamlit_webapp.md
  31. +20 −0 docs/usage.md
  32. +19 −0 docs/user_request.md
  33. 0 docs/write_docs.todo
  34. +2 −2 examples/analyze_dataset.py
  35. +5 −13 examples/anthropic_claude.py
  36. +14 −0 examples/chat_cli.py
  37. +3 −3 examples/chat_history_backend.py
  38. +12 −20 examples/convert_file.py
  39. 0 { → examples}/frontend/__init__.py
  40. +11 −6 { → examples}/frontend/app.py
  41. +66 −0 examples/frontend/chainlitui.py
  42. +6 −8 { → examples}/frontend/utils.py
  43. +4 −3 examples/plot_sin_wave.py
  44. +2 −2 examples/show_bitcoin_chart.py
  45. +10 −9 examples/use_additional_tools.py
  46. +29 −0 mkdocs.yml
  47. +0 −3,925 poetry.lock
  48. +74 −34 pyproject.toml
  49. +521 −0 requirements-dev.lock
  50. +163 −0 requirements.lock
  51. +11 −0 roadmap.todo
  52. +12 −0 src/codeinterpreterapi/__init__.py
  53. +103 −0 src/codeinterpreterapi/_patch_parser.py
  54. 0 { → src}/codeinterpreterapi/chains/__init__.py
  55. +9 −8 { → src}/codeinterpreterapi/chains/extract_code.py
  56. +21 −10 { → src}/codeinterpreterapi/chains/modifications_check.py
  57. +9 −6 { → src}/codeinterpreterapi/chains/rm_dl_link.py
  58. +3 −4 { → src}/codeinterpreterapi/chat_history.py
  59. +50 −0 src/codeinterpreterapi/config.py
  60. 0 { → src}/codeinterpreterapi/prompts/__init__.py
  61. +1 −1 { → src}/codeinterpreterapi/prompts/modifications_check.py
  62. +2 −2 { → src}/codeinterpreterapi/prompts/remove_dl_link.py
  63. +24 −0 src/codeinterpreterapi/prompts/system_message.py
  64. +68 −14 codeinterpreterapi/schema/file.py → src/codeinterpreterapi/schema.py
  65. +138 −109 { → src}/codeinterpreterapi/session.py
  66. +61 −0 tests/chain_test.py
  67. +28 −6 tests/general_test.py
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: ci
on:
push:
branches:
- master
- main
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
22 changes: 0 additions & 22 deletions .github/workflows/code-check.yml

This file was deleted.

106 changes: 6 additions & 100 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
@@ -23,20 +15,11 @@ wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.pyc
*.egg
MANIFEST
.vscode

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
@@ -52,74 +35,16 @@ coverage.xml
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
# PEP 582
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
@@ -129,34 +54,15 @@ ENV/
env.bak/
venv.bak/
.codebox

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject
.context

# mkdocs documentation
/site

# mypy
.mypy_cache/
.mypy_cache
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.DS_Store
foodb_2020_04_07_json
27 changes: 0 additions & 27 deletions .pre-commit-config.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
# MIT License

Copyright (c) 2023 Dominic
Copyright (c) 2023 Dominic Bäumer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
89 changes: 25 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Code Interpreter API
# 👾 Code Interpreter API

A LangChain implementation of the ChatGPT Code Interpreter.
[![Version](https://badge.fury.io/py/codeinterpreterapi.svg)](https://badge.fury.io/py/codeinterpreterapi)
![Downloads](https://img.shields.io/pypi/dm/codeinterpreterapi)
![License](https://img.shields.io/pypi/l/codeinterpreterapi)
![PyVersion](https://img.shields.io/pypi/pyversions/codeinterpreterapi)

A [LangChain](https://github.com/langchain-ai/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.
@@ -12,7 +17,11 @@ You can run everything local except the LLM using your own OpenAI API Key.
- 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)
- Use CodeBox API for easy scaling in production

## Docs

Checkout the [documentation](https://shroominic.github.io/codeinterpreter-api/) for more information.

## Installation

@@ -30,49 +39,23 @@ For deployments, you can use `pip install codeinterpreterapi` instead which does
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
```bash
export OPENAI_API_KEY=sk-**********
```

Remember to replace the placeholders with your actual API keys and other required information.

```python
from codeinterpreterapi import CodeInterpreterSession
from codeinterpreterapi import CodeInterpreterSession, settings


async def main():
# create a session
session = CodeInterpreterSession()
await session.astart()

# create a session and close it automatically
with CodeInterpreterSession() as session:
# generate a response based on user input
response = await session.generate_response(
"Plot the bitcoin chart of 2023 YTD"
response = session.generate_response(
"Plot the bitcoin chart of year 2023"
)

# 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())

# output the response
response.show()
```

![Bitcoin YTD](https://github.com/shroominic/codeinterpreter-api/blob/main/examples/assets/bitcoin_chart.png?raw=true)
@@ -83,13 +66,14 @@ Bitcoin YTD Chart Output
```python
from codeinterpreterapi import CodeInterpreterSession, File


# this example uses async but normal sync like above works too
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 = [
# attach files to the request
File.from_path("examples/assets/iris.csv"),
]

@@ -101,6 +85,7 @@ async def main():
# output to the user
print("AI: ", response.content)
for file in response.files:
# iterate over the files (display if image)
file.show_image()


@@ -129,36 +114,12 @@ 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.
But I prefer to use [Twitter](https://twitter.com/shroominic) or [Discord](https://discord.gg/Vaq25XJvvW) 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-api&Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=shroominic/codeinterpreter-api&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=shroominic/codeinterpreter-api&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=shroominic/codeinterpreter-api&type=Date" />
</picture>
</a>
4 changes: 0 additions & 4 deletions codeinterpreterapi/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions codeinterpreterapi/agents/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions codeinterpreterapi/agents/custom_agent.py

This file was deleted.

Loading