openai / plugins-quickstart

Get a ChatGPT plugin up and running in under 5 minutes!
https://platform.openai.com/docs/plugins
MIT License
4.25k stars 736 forks source link

[Bug] Incompatibility issues with Quart and Quart-CORS due to unspecific version requirements #29

Open DjangoPeng opened 1 year ago

DjangoPeng commented 1 year ago

Environment Information:

Current Situation:

The versions are unspecific, leading to issues with Quart and Quart-CORS APIs when used. For instance:

Traceback (most recent call last):
  File "main.py", line 12, in <module>
    @app.post("/todos/<string:username>")
AttributeError: 'Quart' object has no attribute 'post'

Changing all @app HTTP method calls to this style:

@app.route("/todos/<string:username>", methods=["POST"])

allows successful execution of main.py.

However, it's unable to load the sample project "TODO Plugin (no auth)" at https://chat.openai.com/ and the following error is displayed:

[2023-05-17 15:08:42,918] ERROR in app: Exception on request GET /logo.png
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/quart/app.py", line 1451, in handle_request
    return await self.full_dispatch_request(request_context)
  File "/usr/local/lib/python3.6/dist-packages/quart/app.py", line 1473, in full_dispatch_request
    result = await self.handle_user_exception(error)
  File "/usr/local/lib/python3.6/dist-packages/quart/app.py", line 892, in handle_user_exception
    raise error
  File "/usr/local/lib/python3.6/dist-packages/quart/app.py", line 1471, in full_dispatch_request
    result = await self.dispatch_request(request_context)
  File "/usr/local/lib/python3.6/dist-packages/quart/app.py", line 1519, in dispatch_request
    return await handler(**request_.view_args)
  File "main.py", line 36, in plugin_logo
    return await quart.send_file(filename, mimetype='image/png')
TypeError: send_file() got an unexpected keyword argument 'mimetype'

This issue seems to be related to the versioning of Quart and Quart-CORS. Can we specify the versions in the requirements to prevent these issues?

DjangoPeng commented 1 year ago

@logankilpatrick PTAL

evanroyrees commented 1 year ago

Simply cloning, installing dependencies and running python main.py fails.

Pinning dependencies may make this more stable.

(gpt-plugins) ➜  plugins-quickstart git:(main) python main.py 
Traceback (most recent call last):
  File "/Users/rees/plugins-quickstart/main.py", line 4, in <module>
    import quart_cors
  File "/Users/rees/mambaforge/envs/gpt-plugins/lib/python3.11/site-packages/quart_cors/__init__.py", line 6, in <module>
    from quart.datastructures import HeaderSet, RequestAccessControl
ImportError: cannot import name 'HeaderSet' from 'quart.datastructures' (/Users/rees/mambaforge/envs/gpt-plugins/lib/python3.11/site-packages/quart/datastructures.py)
(gpt-plugins) ➜  plugins-quickstart git:(main) mamba list quart    
# packages in environment at /Users/rees/mambaforge/envs/gpt-plugins:
#
# Name                    Version                   Build  Channel
quart                     0.18.3             pyhd8ed1ab_0    conda-forge
quart-cors                0.2.0                      py_0    conda-forge
DjangoPeng commented 1 year ago

@WiscEvan

How about taking a look at #30

evanroyrees commented 1 year ago

I gave your code a try as well and this still resulted in the error.

The error seems to be a result of using quart-cors 0.2.0 rather than quart-cors 0.6.0

The code ran without any issues with these versions:

# packages in environment at /Users/rees/mambaforge/envs/gpt-plugins:
#
# Name                    Version                   Build  Channel
quart                     0.18.4                   pypi_0    pypi
quart-cors                0.6.0                    pypi_0    pypi

The conda-forge channel for quart-cors appears to be out of date. This was resolved by installing with pip rather than mamba

The quart-cors conda-forge package should be bumped from 0.2.0 to the latest version to install using the conda package manager. Otherwise, installation should be performed using pypi

DjangoPeng commented 1 year ago

I see.

Thanks for your explanation.

Let me update the PR( https://github.com/openai/plugins-quickstart/pull/30) to specify version of quart-cors