admin 管理员组

文章数量: 887019

Chat Plugins Limited Alpha 聊天插件

  • 前言
  • Introduction
  • Plugin flow 插件流
  • 其它资料下载

Learn how to build a plugin that allows ChatGPT to intelligently call your API.
了解如何构建允许ChatGPT智能调用API的插件。

前言

在现代的软件开发环境中,使用第三方插件已成为非常常见的做法。对于ChatGPT这样的大型语言模型而言,OpenAI公司深知在不断满足客户需求、提供更丰富的功能和缩短开发周期之间的平衡是多么重要。因此,OpenAI公司充分支持用户使用OpenAI认证的各种第三方插件,这使得ChatGPT可以充分利用已有的功能来快速推出复杂多变的产品,并大幅提高大型语言模型应用的场景。

然而,OpenAI公司也清楚意识到选择合适的第三方插件以确保系统的可靠性和安全性非常重要。所以OpenAI公司也采取了一系列措施,并对每个想要整合进ChatGPT的第三方插件都进行了细致的评估和审核,只有符合其标准和要求的插件才有可以被集成到ChatGPT语言模型中。

Introduction

OpenAI plugins connect ChatGPT to third-party applications. These plugins enable ChatGPT to interact with APIs defined by developers, enhancing ChatGPT’s capabilities and allowing it to perform a wide range of actions.
OpenAI插件将ChatGPT连接到第三方应用程序。这些插件使ChatGPT能够与开发人员定义的API进行交互,增强ChatGPT的功能并允许其执行广泛的操作。

Plugins can allow ChatGPT to do things like:
插件可以允许ChatGPT执行以下操作:

  • Retrieve real-time information; e.g., sports scores, stock prices, the latest news, etc.
    检索实时信息;例如,体育比分、股票价格、最新消息等。
  • Retrieve knowledge-base information; e.g., company docs, personal notes, etc.
    检索知识库信息;例如,公司文档、个人笔记等。
  • Perform actions on behalf of the user; e.g., booking a flight, ordering food, etc.
    代表用户执行操作;例如,预订航班、订购食物等。

Plugins are in a limited alpha and may not yet be accessible to you. Please join the waitlist to get access. During the alpha, we will be working closely with users and developers to iterate on the plugin system, which may evolve significantly.
插件是在一个限制的alpha版本,可能还没有访问到你。请加入等待列表以获得访问权限。在alpha期间,我们将与用户和开发人员密切合作,迭代插件系统,这可能会发生重大变化。

Plugin developers expose one or more API endpoints, accompanied by a standardized manifest file and an OpenAPI specification. These define the plugin’s functionality, allowing ChatGPT to consume the files and make calls to the developer-defined APIs.
插件开发人员公开一个或多个API端点,并附带一个标准化的清单文件和OpenAPI规范。这些定义了插件的功能,允许ChatGPT使用文件并调用开发人员定义的API。

The AI model acts as an intelligent API caller. Given an API spec and a natural-language description of when to use the API, the model proactively calls the API to perform actions. For instance, if a user asks, “Where should I stay in Paris for a couple nights?”, the model may choose to call a hotel reservation plugin API, receive the API response, and generate a user-facing answer combining the API data and its natural language capabilities.
AI模型充当智能API调用者。给定API规范和何时使用API的自然语言描述,模型会主动调用API来执行操作。例如,如果用户问,“我应该在巴黎的哪里住几晚?””,模型可以选择调用酒店预订插件API,接收API响应,并且生成组合API数据及其自然语言能力的面向用户的回答。

Over time, we anticipate the system will evolve to accommodate more advanced use cases.
随着时间的推移,我们预计系统将发展以适应更高级的用例。

Plugin flow 插件流

To build a plugin, it is important to understand the end-to-end flow.
要构建一个插件,理解端到端的流程是很重要的。

  1. Create a manifest file and host it at yourdomain/.well-known/ai-plugin.json
    创建清单文件并将其托管在 yourdomain/.well-known/ai-plugin.json
  • The file includes metadata about your plugin (name, logo, etc.), details about authentication required (type of auth, OAuth URLs, etc.), and an OpenAPI spec for the endpoints you want to expose.
    该文件包括有关插件的元数据(名称、徽标等),关于所需身份验证的详细信息(auth类型、OAuth URL等),以及要公开的端点的OpenAPI规范。
  • The model will see the OpenAPI description fields, which can be used to provide a natural language description for the different fields.
    模型将看到OpenAPI描述字段,这些字段可用于为不同字段提供自然语言描述。
  • We suggest exposing only 1-2 endpoints in the beginning with a minimum number of parameters to minimize the length of the text. The plugin description, API requests, and API responses are all inserted into the conversation with ChatGPT. This counts against the context limit of the model.
    我们建议在开始时只暴露1-2个端点,并使用最少数量的参数来最小化文本的长度。插件描述、API请求和API响应都被插入到与ChatGPT的对话中。这会影响模型的上下文限制。
  1. Register your plugin in the ChatGPT UI
    在ChatGPT UI中注册插件
  • Select the plugin model from the top drop down, then select “Plugins”, “Plugin Store”, and finally “Install an unverified plugin” or “Develop your own plugin”.
    从顶部下拉菜单中选择插件模型,然后选择“插件”,“插件商店”,最后选择“安装未验证的插件”或“开发自己的插件”。
  • If authentication is required, provide an OAuth 2 client_id and client_secret or an API key
    如果需要身份验证,请提供OAuth2client_id和client_secret或API密钥
  1. Users activate your plugin 用户激活您的插件
  • Users must manually activate your plugin in the ChatGPT UI. (ChatGPT will not use your plugin by default.)
    用户必须在ChatGPT UI中手动激活您的插件。(默认情况下,ChatGPT不会使用您的插件。)
  • During the alpha, plugin developers will be able to share their plugin with 15 additional users (only other developers can install unverified plugins currently). Overtime we will roll out a way to submit your plugin for review to be exposed to all of ChatGPT’s user base.
    在alpha测试期间,插件开发人员将能够与15个额外的用户共享他们的插件(目前只有其他开发人员可以安装未经验证的插件)。超时,我们将推出一种方法来提交您的插件进行审查,以暴露给所有ChatGPT的用户群.
  • If auth is required, users will be redirected via OAuth to your plugin; you can optionally create new accounts here as well.
    如果需要授权,用户将通过OAuth重定向到您的插件;您也可以选择在此处创建新帐户。
  • In the future, we hope to build features to help users discover useful & popular plugins.
    在未来,我们希望构建功能来帮助用户发现有用的和流行的插件。
  1. Users begin a conversation 用户开始对话
  • OpenAI will inject a compact description of your plugin in a message to ChatGPT, invisible to end users. This will include the plugin description, endpoints, and examples.
    OpenAI将在ChatGPT的消息中注入插件的紧凑描述,最终用户不可见。这将包括插件描述、端点和示例。
  • When a user asks a relevant question, the model may choose to invoke an API call from your plugin if it seems relevant; for POST requests, we require that developers build a user confirmation flow.
    当用户问一个相关的问题时,模型可能会选择从你的插件调用一个API调用,如果它看起来相关的话;对于POST请求,我们要求开发人员构建用户确认流。
  • The model will incorporate the API results into its response to the user.
    模型将把API结果合并到对用户的响应中。
  • The model might include links returned from API calls in its response. These will be displayed as rich previews (using the OpenGraph protocol, where we pull the site_name, title, description, image, and url fields)"
    模型可能在其响应中包含从API调用返回的链接。这些将显示为丰富的预览(使用OpenGraph协议,其中我们提取site_name,title,description,image和url字段)

Currently, we will be sending the user’s country and state in the Plugin conversation header (if you are in California for example, it would look like {"openai-subdivision-1-iso-code": "US-CA"}. For further data sources, users will have to opt in via a consent screen. This is useful for shopping, restaurants, weather, and more. You can read more in our developer terms of use.
目前,我们将在插件对话标题中发送用户的国家和州(例如,如果您在加利福尼亚 州,它将看起来像 {"openai-subdivision-1-iso-code": "US-CA"} 。对于其他数据源,用户必须通过同意屏幕选择加入。这对购物、餐馆、天气等都很有用。您可以在我们的开发人员使用条款中阅读更多内容。

其它资料下载

如果大家想继续了解人工智能相关学习路线和知识体系,欢迎大家翻阅我的另外一篇博客《重磅 | 完备的人工智能AI 学习——基础知识学习路线,所有资料免关注免套路直接网盘下载》
这篇博客参考了Github知名开源平台,AI技术平台以及相关领域专家:Datawhale,ApacheCN,AI有道和黄海广博士等约有近100G相关资料,希望能帮助到所有小伙伴们。

本文标签: 插件 引言 中英文 源码 接口