Skip to content

Commit bf27c68

Browse files
committed
add initial version of chatgpt plugins
1 parent 07bb57d commit bf27c68

File tree

14 files changed

+544
-0
lines changed

14 files changed

+544
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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": "[email protected]",
16+
"legal_info_url": "http://example.com/legal"
17+
}
18+

chatgpt-plugins/todo-list/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.

chatgpt-plugins/todo-list/README.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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). If you do not already have plugin developer access, please [join the waitlist](https://openai.com/waitlist/plugins).
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+
## Setup remotely
30+
31+
### Cloudflare workers
32+
33+
### Code Sandbox
34+
35+
### Replit
36+
37+
## Getting help
38+
39+
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).

chatgpt-plugins/todo-list/logo.png

1.24 KB
Loading

chatgpt-plugins/todo-list/main.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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/<string:username>")
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/<string:username>")
21+
async def get_todos(username):
22+
return quart.Response(response=json.dumps(_TODOS.get(username, [])), status=200)
23+
24+
@app.delete("/todos/<string:username>")
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()
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
quart
2+
quart-cors
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"schema_version": "v1",
3+
"name_for_human": "Weather Forecast",
4+
"name_for_model": "weather",
5+
"description_for_human": "Global Weather Forecast. You can ask the current or future weather of any city around the world.",
6+
"description_for_model": "Plugin for managing weather forecasts. Search current weather and future forecasts through provided api.",
7+
"auth": {
8+
"type": "none"
9+
},
10+
"api": {
11+
"type": "openapi",
12+
"url": "http://localhost:5002/openapi.yaml"
13+
},
14+
"logo_url": "http://localhost:5002/logo.png",
15+
"contact_email": "[email protected]",
16+
"legal_info_url": "http://example.com/legal"
17+
}
18+
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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). If you do not already have plugin developer access, please [join the waitlist](https://openai.com/waitlist/plugins).
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+
## Setup remotely
30+
31+
### Cloudflare workers
32+
33+
### Code Sandbox
34+
35+
### Replit
36+
37+
## Getting help
38+
39+
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).

0 commit comments

Comments
 (0)