dify blog 09月19日
ChatGPT插件开发指南与商业应用
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文详细介绍了如何创建ChatGPT插件,包括ai-plugin.json和openapi.json文件的配置,以及如何部署到Serverless平台。文章还探讨了插件在客户支持、电商、项目管理和日历管理等领域的商业应用。此外,Dify平台支持无缝集成自研及第三方插件,简化了AI应用的开发与编排。

💡 **ChatGPT插件的核心是ai-plugin.json文件**:该文件描述了插件的功能和API信息,使AI客户端能够了解插件的用途并将其集成到工具箱中。这类似于Langchain的代理模式,允许AI与外部API进行交互。

🛠️ **创建ChatGPT插件的步骤**:包括选择特定任务(如Google搜索),创建Serverless项目,编写API代码,生成符合OpenAPI规范的openapi.json文件,部署项目获取API URL,最后创建ai-plugin.json文件并更新API URL。此过程实现了AI客户端与外部功能的连接。

🚀 **插件的商业应用场景广泛**:例如,客户支持插件可集成工单系统,电商插件可协助产品推荐和订单处理,项目管理插件可与Trello等工具集成,日历管理插件则能帮助用户安排日程。这些应用能显著提升AI的实用性。

🔗 **Dify平台简化插件集成**:Dify支持无缝集成自研工具和第三方插件。只需提供第三方插件的JSON文件URL,即可将其加载到应用中,极大地便利了AI应用的开发和编排工作。

ChatGPT plugins provide a powerful way to extend the capabilities of AI clients by integrating additional functionalities through APIs. In this blog post, we'll guide you through the process of creating a ChatGPT plugin and discuss some potential business use cases. Finally, we'll touch upon how Dify supports the integration of both in-house and third-party plugins for seamless AI application orchestration.

Creating a ChatGPT Plugin

At its core, a ChatGPT plugin is an ai-plugin.json file that describes the plugin's functionality and API information. Here's an example of what the file might look like:

{  "schema_version": "v1",  "name_for_human": "TODO Manager",  "name_for_model": "todo_manager",  "description_for_human": "Manages your TODOs!",  "description_for_model": "An app for managing a user's TODOs",  "api": { "url": "/openapi.json" },  "auth": { "type": "none" },  "logo_url": "https://example.com/logo.png",  "legal_info_url": "http://example.com",  "contact_email": "hello@example.com"}

By accessing this JSON file, ChatGPT or other AI clients can learn about the plugin's purpose and functionality, allowing them to integrate the plugin into their toolbox for use when needed. This is similar to Langchain's proxy mode, where both public and private APIs can serve as plugins for AI clients, acting as their eyes and hands.

If you're starting from scratch to create a ChatGPT plugin, such as one that performs a Google Search, you can follow these steps to develop and deploy the plugin to a Serverless platform:

  1. First, choose a specific task for your plugin, such as performing a Google Search using the Google Search API.

  2. Create a new Serverless project using your preferred Serverless framework (e.g., AWS Lambda, Google Cloud Functions, or Azure Functions).

  3. Write the necessary code to handle the Google Search functionality using the Google Search API in your Serverless project. Make sure to handle any necessary authentication, input validation, and error handling.

  4. Create an openapi.json file in your Serverless project to define the API endpoints and data structures required for your plugin. This file should follow the OpenAPI Specification (OAS) standard. You can use online tools like the Swagger Editor or the OpenAPI Generator to help create the openapi.json file.

  5. Deploy your Serverless project to your preferred Serverless platform. After deployment, you will receive a public URL for your project, which can be used to access your plugin's API.

  6. Create the ai-plugin.json file for your plugin, as described in my previous response, and update the api.url field with the public URL obtained from your Serverless platform in step 5.

Here's an example of a simple openapi.json file for the Google Search plugin:

{  "openapi": "3.0.0",  "info": {    "title": "Google Search Plugin",    "version": "1.0.0"  },  "paths": {    "/search": {      "get": {        "summary": "Perform a Google Search",        "parameters": [          {            "name": "query",            "in": "query",            "description": "Search query",            "required": true,            "schema": {              "type": "string"            }          }        ],        "responses": {          "200": {            "description": "Successful search",            "content": {              "application/json": {                "schema": {                  "type": "array",                  "items": {                    "type": "object",                    "properties": {                      "title": {                        "type": "string"                      },                      "link": {                        "type": "string"                      },                      "snippet": {                        "type": "string"                      }                    }                  }                }              }            }          }        }      }    }  }}

Here's an example of the ai-plugin.json file for the Google Search plugin:

{  "schema_version": "v1",  "name_for_human": "Google Search",  "name_for_model": "google_search",  "description_for_human": "Perform a Google Search using the Google Search API!",  "description_for_model": "An app for performing Google Searches using the Google Search API",  "api": { "url": "https://your-serverless-function-url.com/openapi.json" },  "auth": { "type": "api_key", "key_name": "google_search_api_key" },  "logo_url": "https://example.com/google_search_logo.png",  "legal_info_url": "http://example.com",  "contact_email": "hello@example.com"}

By following these steps, you can create a custom ChatGPT plugin that performs Google Searches and deploy it to a Serverless platform for easy integration into AI applications.

Business Use Cases

There are numerous potential business scenarios where ChatGPT plugins can provide valuable functionality. Some examples include:

  1. Customer Support: A plugin that integrates a company's customer support ticket system, allowing AI agents to create, update, and close tickets on behalf of users.

  2. E-commerce: A plugin that connects to an e-commerce platform's API, enabling the AI to assist users with product recommendations, order status updates, and even processing returns.

  3. Project Management: A plugin that integrates with popular project management tools, such as Trello or Asana, allowing the AI to create tasks, update progress, and provide project overviews to team members.

  4. Calendar Management: A plugin that connects to a user's calendar, enabling the AI to schedule appointments, send reminders, and help users manage their time more effectively.

Dify Integration

Dify application orchestration supports the seamless integration of both Dify-produced tools and third-party plugins. To integrate a third-party plugin, developers simply need to provide the JSON file URL, and the plugin will be loaded into the application.

Developing ChatGPT plugins can unlock a wealth of new possibilities for AI-driven applications by extending their capabilities through API integrations. By understanding the structure of a ChatGPT plugin and its potential use cases, developers can harness the power of these plugins to create more sophisticated and powerful AI applications. With Dify support for both in-house and third-party plugins, the process of incorporating these plugins into AI applications has never been easier.

via @dify_ai and @goocarlos

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

ChatGPT插件 AI开发 Serverless API集成 Dify 商业应用 ChatGPT plugin AI development Serverless API integration Dify Business applications
相关文章