-
Notifications
You must be signed in to change notification settings - Fork 3
ChatGPT Plugin
A ChatGPT plugin server hosts a set of web-based endpoints that ChatGPT can query to obtain information not in its general knowledge base. This may be customer specific or company specific data. The endpoints may return structured data like JSON or XML. Or the endpoints may return text information in a non-structured format.
The project.yaml file (see below) shows the configuration for two different plugin servers. The first server is called todo-json. It returns responses in JSON format.
The mocked requests are configured with
- path: the relative path of the request.
- method: the HTTP method for the mocked response. This can be get, post, put or delete.
- response: this points to a file containing the mocked content. It will read this file from the filesystem and return to ChatGPT
- contentType: the content-type header returned to the caller. By default, this is "application/json". Use this field if you need to change the default.
---
projectName: plugin-quickstart
projectVersion: '1.0'
projectType: plugin
defaultConfig:
properties:
port: 5003
nameForHuman: TODO Plugin (no auth)
nameForModel: todo
descriptionForHuman: Plugin for managing a TODO list, you can add, remove and view your TODOs.
mockedRequests:
- path: "/todos/global"
method: get
mockedResponse: todos-global.json
- path: "/todos/user"
method: get
mockedResponse: todos-global.json
pluginServers:
- serverId: todo-mike
flavor: mike
# mocked requests
mockedRequests:
- path: "/todos/mike"
method: get
mockedResponse: todos.json # returns the content of this file
# Adds a different user for testing
- serverId: todo-kaleb
flavor: kaleb
mockedRequests:
- path: "/todos/kaleb"
method: get
mockedResponse: todos.json
properties:
showHttpHeaders: true # Show http headers in logs
The Official Plugin documentation states
Just like with prompting other language models,you will want to
test out multiple prompts and descriptions to see what works best.
This tool is designed to allow rapid prototyping and testing of prompts and descriptions.
Let's take a look at how prompts work. Prompts are contained in the description_for_model field of the plugin manifest. ChatGPT UI will use the description_for_model field as a prompt. This instructs ChatGPT on how to use your plugin. You can also include information such as the max number of tokens, temperature or other parameters. These should be considered hints, not strict rules that ChatGPT will follow.
Given the potentially large size of a prompt, it's not convenient to modify the manifest. It's better to use a variable ${manifestPrompt} as the value for the description_for_model field. This also has an advantage of being able to reuse the plugin manifest file, while merely configuring the project to use a different prompt file.
Also note that the defaultConfig properties in the project.yaml file will be substituted into the plugin manifest below.
{
"schema_version": "v1",
"name_for_human": "${nameForHuman}",
"name_for_model": "${nameForModel}",
"description_for_human": "${descriptionForHuman}",
"description_for_model": "${manifestPrompt}",
"auth": {
"type": "none"
},
"api": {
"type": "openapi",
"url": "http://localhost:${port}/openapi.yaml",
"is_user_authenticated": false
},
"logo_url": "http://localhost:${port}/logo.png",
"contact_email": "[email protected]",
"legal_info_url": "http://example.com/legal"
}
If the content of our prompt file is
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
then at runtime, it will return to ChatGPT as
{
"schema_version": "v1",
"name_for_human": "TODO Plugin (no auth)",
"name_for_model": "todo",
"description_for_human": "Plugin for managing a TODO list, you can add, remove and view your TODOs.",
"description_for_model": "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",
"auth": {
"type": "none"
},
"api": {
"type": "openapi",
"url": "http://localhost:5003/openapi.yaml",
"is_user_authenticated": false
},
"logo_url": "http://localhost:5003/logo.png",
"contact_email": "[email protected]",
"legal_info_url": "http://example.com/legal"
}
To start a mocked instance of the plugin server
air plugin
or to start a specific server add the serverId option
air plugin --serverId todo-json
A typical startup will display the locations of the manifest, logo and api spec. It will also give you the mocked registered endpoints.
Setting up plugin server: todo-json
http://localhost:5003
http://localhost:5003/.well-known/ai-plugin.json
http://localhost:5003/openapi.yaml
http://localhost:5003/logo.png
Registering endpoints
GET - http://localhost:5003/todos/mike
GET - http://localhost:5003/todos/global
GET - http://localhost:5003/todos/user
Listening on localhost:5003
The server will also display the requests that are being made by the ChatGPT UI.
2023-05-14 09:11:44.549720 Request: GET - /.well-known/ai-plugin.json
2023-05-14 09:12:01.330307 Request: GET - /openapi.yaml
2023-05-14 09:12:06.046786 Request: GET - /logo.png
2023-05-14 09:12:09.434501 Request: GET - /todos/mike
Using response file responses/todos-mike.json
You can modify any of the mocked response data without restarting the server. For example, you could change todos-mike.json
{
"todos": [
"Clean out a septic tank",
"Repair a broken sewer pipe",
"Collect roadkill for disposal",
"Assist in bee hive relocation",
"Service a grease trap at a restaurant"
]
}
to
{
"todos": [
"Assist in cleaning an old coal mine",
"Help with bat guano collection for fertilizer production",
"Participate in the maintenance of sewage pipes",
"Assist in the demolition and removal of a decommissioned ship",
"Join a crew for the day to clean and maintain a city landfill site"
]
}
You can also modify the following files without shutting down the server. To refresh, just create a new Chat. ChatGPT UI will query your your plugin manifest again
- manifest.prompt
- ai-plugin.json
2023-05-14 10:32:42.873090 Request: OPTIONS - /.well-known/ai-plugin.json
2023-05-14 10:32:42.889322 Request: GET - /.well-known/ai-plugin.json
To refresh the OpenAPI specification, you will need to go to the plugin store and install a new plugin. You will need to do this anytime you change the API endpoints, specifically anytime you change the following files:
- openapi.yaml
- descriptions.txt
You will see the following sequence of calls to your local plugin server.
2023-05-14 10:47:08.654847 Request: OPTIONS - /.well-known/ai-plugin.json
2023-05-14 10:47:08.659211 Request: GET - /.well-known/ai-plugin.json
2023-05-14 10:47:08.668514 Request: OPTIONS - /openapi.yaml
2023-05-14 10:47:08.673227 Request: GET - /openapi.yaml
Go to your ChatGPT UI and start a new chat. You will see that no plugins are installed.

Now click on "No plugins enabled" drop down. You will see a UI element to take you to the "Plugin Store". Press it.

Click "Develop your own plugin"

Enter the domain and port that is specified in your plugin manifest. Now press "Find manifest file"

If everything is ok, you should process to "found plugin" step (see below). Note the checkmarks next to "Validated manifest" and "Validated OpenAPI specs". If you were to receive a failure during this step it could be due to any of the following.
- Failure of manifest or specs validation
- Server is not running
- CORS is not enabled on your server

After installing, you will be re-directed back to the main ChatGPT UI with a notice that the plugin is now enabled.
Remember in the configuration we specified mike's todo list. So I just tell ChatGPT than I'm mike and it will pull the correct list.
