├── .gitignore ├── .well-known └── ai-plugin.json ├── LICENSE ├── README.md ├── logo.png ├── main.py ├── openapi.yaml └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /.well-known/ai-plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema_version": "v1", 3 | "name_for_human": "TODO List (no auth)", 4 | "name_for_model": "todo", 5 | "description_for_human": "Manage your TODO list. You can add, remove and view your TODOs.", 6 | "description_for_model": "Plugin for managing a TODO list, you can add, remove and view your TODOs.", 7 | "auth": { 8 | "type": "none" 9 | }, 10 | "api": { 11 | "type": "openapi", 12 | "url": "http://localhost:5003/openapi.yaml" 13 | }, 14 | "logo_url": "http://localhost:5003/logo.png", 15 | "contact_email": "legal@example.com", 16 | "legal_info_url": "http://example.com/legal" 17 | } 18 | 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 OpenAI 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ChatGPT plugins quickstart 2 | 3 | Get a TODO list ChatGPT plugin up and running in under 5 minutes using Python. This plugin is designed to work in conjunction with the [ChatGPT plugins documentation](https://platform.openai.com/docs/plugins). Plugins have been superseded by GPTs, learn more about [creating a GPT with actions](https://platform.openai.com/docs/actions/introduction). 4 | 5 | ## Setup locally 6 | 7 | To install the required packages for this plugin, run the following command: 8 | 9 | ```bash 10 | pip install -r requirements.txt 11 | ``` 12 | 13 | To run the plugin, enter the following command: 14 | 15 | ```bash 16 | python main.py 17 | ``` 18 | 19 | Once the local server is running: 20 | 21 | 1. Navigate to https://chat.openai.com. 22 | 2. In the Model drop down, select "Plugins" (note, if you don't see it there, you don't have access yet). 23 | 3. Select "Plugin store" 24 | 4. Select "Develop your own plugin" 25 | 5. Enter in `localhost:5003` since this is the URL the server is running on locally, then select "Find manifest file". 26 | 27 | The plugin should now be installed and enabled! You can start with a question like "What is on my todo list" and then try adding something to it as well! 28 | 29 | ## Getting help 30 | 31 | If you run into issues or have questions building a plugin, please join our [Developer community forum](https://community.openai.com/c/chat-plugins/20). 32 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openai/plugins-quickstart/0763ac2bc52f45f3c09f71f6c1a7890b75277dc5/logo.png -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | import quart 4 | import quart_cors 5 | from quart import request 6 | 7 | app = quart_cors.cors(quart.Quart(__name__), allow_origin="https://chat.openai.com") 8 | 9 | # Keep track of todo's. Does not persist if Python session is restarted. 10 | _TODOS = {} 11 | 12 | @app.post("/todos/") 13 | async def add_todo(username): 14 | request = await quart.request.get_json(force=True) 15 | if username not in _TODOS: 16 | _TODOS[username] = [] 17 | _TODOS[username].append(request["todo"]) 18 | return quart.Response(response='OK', status=200) 19 | 20 | @app.get("/todos/") 21 | async def get_todos(username): 22 | return quart.Response(response=json.dumps(_TODOS.get(username, [])), status=200) 23 | 24 | @app.delete("/todos/") 25 | async def delete_todo(username): 26 | request = await quart.request.get_json(force=True) 27 | todo_idx = request["todo_idx"] 28 | # fail silently, it's a simple plugin 29 | if 0 <= todo_idx < len(_TODOS[username]): 30 | _TODOS[username].pop(todo_idx) 31 | return quart.Response(response='OK', status=200) 32 | 33 | @app.get("/logo.png") 34 | async def plugin_logo(): 35 | filename = 'logo.png' 36 | return await quart.send_file(filename, mimetype='image/png') 37 | 38 | @app.get("/.well-known/ai-plugin.json") 39 | async def plugin_manifest(): 40 | host = request.headers['Host'] 41 | with open("./.well-known/ai-plugin.json") as f: 42 | text = f.read() 43 | return quart.Response(text, mimetype="text/json") 44 | 45 | @app.get("/openapi.yaml") 46 | async def openapi_spec(): 47 | host = request.headers['Host'] 48 | with open("openapi.yaml") as f: 49 | text = f.read() 50 | return quart.Response(text, mimetype="text/yaml") 51 | 52 | def main(): 53 | app.run(debug=True, host="0.0.0.0", port=5003) 54 | 55 | if __name__ == "__main__": 56 | main() 57 | -------------------------------------------------------------------------------- /openapi.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | info: 3 | title: TODO Plugin 4 | description: A plugin that allows the user to create and manage a TODO list using ChatGPT. If you do not know the user's username, ask them first before making queries to the plugin. Otherwise, use the username "global". 5 | version: 'v1' 6 | servers: 7 | - url: http://localhost:5003 8 | paths: 9 | /todos/{username}: 10 | get: 11 | operationId: getTodos 12 | summary: Get the list of todos 13 | parameters: 14 | - in: path 15 | name: username 16 | schema: 17 | type: string 18 | required: true 19 | description: The name of the user. 20 | responses: 21 | "200": 22 | description: OK 23 | content: 24 | application/json: 25 | schema: 26 | $ref: '#/components/schemas/getTodosResponse' 27 | post: 28 | operationId: addTodo 29 | summary: Add a todo to the list 30 | parameters: 31 | - in: path 32 | name: username 33 | schema: 34 | type: string 35 | required: true 36 | description: The name of the user. 37 | requestBody: 38 | required: true 39 | content: 40 | application/json: 41 | schema: 42 | $ref: '#/components/schemas/addTodoRequest' 43 | responses: 44 | "200": 45 | description: OK 46 | delete: 47 | operationId: deleteTodo 48 | summary: Delete a todo from the list 49 | parameters: 50 | - in: path 51 | name: username 52 | schema: 53 | type: string 54 | required: true 55 | description: The name of the user. 56 | requestBody: 57 | required: true 58 | content: 59 | application/json: 60 | schema: 61 | $ref: '#/components/schemas/deleteTodoRequest' 62 | responses: 63 | "200": 64 | description: OK 65 | 66 | components: 67 | schemas: 68 | getTodosResponse: 69 | type: object 70 | properties: 71 | todos: 72 | type: array 73 | items: 74 | type: string 75 | description: The list of todos. 76 | addTodoRequest: 77 | type: object 78 | required: 79 | - todo 80 | properties: 81 | todo: 82 | type: string 83 | description: The todo to add to the list. 84 | required: true 85 | deleteTodoRequest: 86 | type: object 87 | required: 88 | - todo_idx 89 | properties: 90 | todo_idx: 91 | type: integer 92 | description: The index of the todo to delete. 93 | required: true -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | quart 2 | quart-cors --------------------------------------------------------------------------------