OpenAI 聊天插件开发 2 - 快速开始

创建插件需要三个步骤:

  • 构建一个 API
  • OpenAPI 规范格式 的 API 文档文件(yaml 或 JSON 格式)
  • 创建一个 JSON manifest 文件,该文件将定义插件的相关元数据

本节其余部分的重点是通过定义 OpenAPI 规范 和 manifest 文件来创建待办事项列表插件。

插件 manifest

每个插件都需要一个名为 ai-plugin.json 的文件,该文件需要托管在 API 所在的域名下。例如,一家名为 example.com 的公司将通过 https://example.com 访问插件 JSON 文件,因为这是托管其 API 的地方。当您通过 ChatGPT UI 安装插件时,我们会在后台查找 /.well-known/ai-plugin.json文件。如果未找到该文件,则无法安装插件。

插件的最小定义如下所示:

{
   
  "schema_version": "v1",
  "name_for_human": "TODO Plugin",
  "name_for_model": "todo",
  "description_for_human": "Plugin for managing a TODO list. You can add, remove and view your TODOs.",
  "description_for_model": "Plugin for managing a TODO list. You can add, remove and view your TODOs.",
  "auth": {
   
    "type": "none"
  },
  "api": {
   
    "type": "openapi",
    "url": "http://localhost:3333/openapi.yaml",
    "is_user_authenticated": false
  },
  "logo_url": "https://vsq7s0-5001.preview.csb.app/logo.png",
  "contact_email": "support@example.com",
  "legal_info_url": "http://www.example.com/legal"
}

如果您想查看插件文件的所有可能选项,可以参考下面的定义。

类型 描述/选项
schema_version String 清单(manifest)架构版本
name_for_model String 模型将用于定位插件的名称
name_for_human String 人类可读的名称,例如公司全名
description_for_model String 更适合模型的描述,例如令牌上下文长度注意事项或关键字用法,以改进插件提示。
description_for_human String 插件的人类可读描述
auth ManifestAuth 身份验证模式
api Object 接口规范
logo_url String 用于获取插件徽标的网址
contact_email String 用于安全/审核联系、支持和停用的电子邮件联系人
legal_info_url String 重定向 URL,以便用户查看插件信息
HttpAuthorizationType HttpAuthorizationType “持有者”或“基本”
ManifestAuthType ManifestAuthType “无”、“user_http”、“service_http”或“oauth”
interface BaseManifestAuth BaseManifestAuth 类型:清单(manifest)身份验证类型;说明:字符串;
ManifestNoAuth ManifestNoAuth 无需身份验证:BaseManifestAuth & { type: 'none', }
ManifestAuth ManifestAuth ManifestNoAuth, ManifestServiceHttpAuth, ManifestUserHttpAuth, ManifestOAuthAuth

以下是使用不同身份验证方法的示例:

# App-level API keys
type ManifestServiceHttpAuth  = BaseManifestAuth & {
   
  type: 'service_http'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值