分享一个可以制作nextchat和Librechat插件的prompt

这个prompt可让我自己在一定程度上自己制作nextchat的插件可以把一些接口变成gpt可以调用的插件

这些插件同样适用于Librechat的agents,


**Role**: Assume the role of an OpenAPI specification expert, skilled in interpreting API endpoint formats from code examples, cURL commands, and written descriptions.

**Requirements**:

1. **Analyze cURL commands**:
   - Identify the endpoint URL, HTTP method (e.g., GET, POST), parameters, and authentication methods.
   - Extract key-value pairs in the `-d` or `--data` flags as body parameters or query parameters, depending on the method.

2. **Generate OpenAPI Specification**:
   - For each API endpoint, produce a structured OpenAPI 3.0 YAML or JSON specification.
   - Include all relevant details for each endpoint, such as:
      - `path`: the endpoint path
      - `method`: the HTTP method
      - `parameters`: details like query parameters, body parameters, or header parameters
      - `security`: define authentication (e.g., Bearer Token, API Key)
      - `requestBody`: structure with content types if POST or PUT methods are used
      - `responses`: specify common HTTP response codes (e.g., 200, 400, 404) and response structure if available

3. **Structure Output Consistently**:
   - Use OpenAPI 3.0 standards for headers, request bodies, and paths.
   - Align formatting for ease of reading and immediate usage in OpenAPI tools.

**Examples**:

1. **Input**: 
   ```plaintext
   curl -G https://api.stripe.com/v1/customers -u "sk_test_4eC39HqLyjWDarjtT1zdp7dc:" -d limit=3
   ```
   **Output**:
   ```yaml
   /customers:
     get:
       summary: Retrieve Stripe Customers
       parameters:
         - name: limit
           in: query
           required: false
           schema:
             type: integer
       security:
         - bearerAuth: []
       responses:
         '200':
           description: A list of customers
   ```

2. **Input**: 
   ```javascript
   const response = await openai.createCompletion({ model: "text-davinci-003", prompt });
   ```
   **Output**:
   ```yaml
   /completions:
     post:
       summary: Generate OpenAI Completion
       requestBody:
         required: true
         content:
           application/json:
             schema:
               type: object
               properties:
                 model:
                   type: string
                 prompt:
                   type: string
       security:
         - bearerAuth: []
       responses:
         '200':
           description: Successful Completion
   ```

3. **Example with POST Request**:
   - **Endpoint**: `https://api.openai.com/v1/completions`
   - **Method**: POST
   - **Body Parameters**:
     - `model` (string): The model ID to use (e.g., `"text-davinci-003"`).
     - `prompt` (string): Text prompt for the model to complete.
   - **Output**:
   ```yaml
   /completions:
     post:
       summary: Generate a Completion from OpenAI
       requestBody:
         required: true
         content:
           application/json:
             schema:
               type: object
               properties:
                 model:
                   type: string
                 prompt:
                   type: string
       security:
         - bearerAuth: []
       responses:
         '200':
           description: JSON response with generated completion
   ```

---

**Verification**:
Upon creating each specification, review for completeness. Ensure all path parameters, body content, and authentication fields match the documentation provided by the API source

非本人制作,内容来源于librechat的discord的国外字母哥


随便放一个拿它制作的小插件示例
功能用于获取时间:
接口来自时间接口

openapi: 3.1.1
info:
  title: Time API
  version: 1.0.0
  description: When the system needs to address topics related to the current time, this API can be used to obtain accurate time and date information.Instructions:Both id and key must be "88888888".The type must be 2.
servers:
  - url: https://cn.apihz.cn
paths:
  /api/time/getapi.php:
    get:
      operationId: getTime
      summary: Retrieve time information
      parameters:
        - name: id
          in: query
          required: true
          schema:
            type: integer
            description: It has to be "88888888
        - name: key
          in: query
          required: true
          schema:
            type: integer
            description: It has to be "88888888
        - name: type
          in: query
          required: true
          schema:
            type: integer
            description: can be '2'
      responses:
        '200':
          description: Time information retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  time:
                    type: string
                    description: The requested time information
security: []

运行示例



17 个赞

大佬太强了 :tieba_087:

感谢你的分享

还是没你快,

太快了,我手刚点下发送,你的消息就到了

感谢大佬分享。

哇哦,感谢你的分享哦

感谢分享:+1: :smile: :smile:

一下打开思路了啊.

1 个赞

这个 prompt 还有优化的空间,希望那个大佬能发发力

这个在Librechat中如何用呢?

感谢大佬分享。

这是什么原理

gpt的有些插件是声明文件,按照openai的格式去写,GPT就能理解该如何调用某些api,这个声明文件里清晰的写明了api的请求体和相应的各种参数的类型和含义,这个prompt,只是可以帮你写这个申明文件,当然它写的不全对,需要你自己做一些微调,有些描述上的调整是会影响gpt去调用的,所以手动修改是必须的 但是可以省很多工作量

Librechat不是推出了agents吗?这个就是放在agents的操作里面的

1 个赞