TOC

ChatGPT 插件开发

体验

获得 ChatGPT 4 的资格(购买 Pro)之后,就可以看到左边页面多了一个 Model 选项,选中了 GPT 4
如果 Model 选择 Plugin 那一项,右边又会多出来一个 Plugins 选项


右边的 Plugins 选项一直往下拖,最下面一栏是 Plugin store,点击进入。

上面的插件可以选中体验体验。

安装

可以看到下方有 Install an unverified pluginDevelop your own plugin 两项。

我们开发的插件就是服务器端 API + 相关声明文件,如果就只是放在自己的服务器上,那就算 unverified plugin。
第一选项就是用来安装这样未经验证的插件,可以在 https://www.gptplugins.app/ 找一个试一下。
输入域名,ChatGPT 自动去获取声明文件 https://域名/.well-known/ai-plugin.json

第二项是用来注册插件到 ChatGPT,也可以用来调试本地插件。
如果是注册插件就填域名好了,如果是调试就输入 localhost:3000 这样的地址。
我用局域网 IP,似乎是不行的,可能只支持 localhost 这个主机名。

使用

现阶段最多能够同时勾选三个插件。
聊天过程中,ChatGPT 自动判断是否需要触发插件的使用。

开发

经过我的体验,开发非常简单,除了原本的服务之外,需要的额外工作就两项:清单文件,OpenAPI(如果原本没有的话)。

清单文件:

{
  "schema_version": "v1",
  "name_for_model": "todo",
  "name_for_human": "Todo Plugin",
  "description_for_model": "Simple task management, task description, task date, task completion. Supports adding, deleting, and querying.",
  "description_for_human": "Simple task management.",
  "auth": {
    // 本地测试 Auth Type 必须是 none
    "type": "none"
  },
  "api": {
    "url": "http://localhost:8080/.well-known/openapi.yaml",
    "has_user_authentication": true,
    "type": "openapi"
  },
  "logo_url": "http://localhost:8080/.well-known/logo.png",
  "contact_email": "hello@contact.com",
  "legal_info_url": "hello@legal.com"
}