快速搭建自己的机器人

方案

腾讯元器 + qq机器人 不需认证,不需服务器

登录腾讯元器

地址:腾讯元器

1、创建插件

目的:配置自己的api

点击插件–点击创建插件

OB4Ma3nZTWPIeDG.png

授权方式选择server – 选header

第一个参数 填Authorization**,第二个参数填 Bearer 你的key

Ngy187Qot2rGaWk.png

点击下一步,把下面的内容替换原来的描述,注意修改自己的url—点击解析

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
openapi: "3.0.0"
info:
title: "测试API"
version: "1.0.0"
description: "请在此填入插件描述"
servers:
- url: "https://api.example.com/v1"      # 修改url
  description: "请在此填入插件描述"
paths:
"/chat/completions":
  post:
    summary: "聊天对话"
    description: "请在此填入插件下面的API描述"
    operationId: "chatwithu"
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              model:
                type: string
              messages:
                type: array
                items:
                  type: object
                  properties:
                    role:
                      type: string
                    content:
                      type: string

    responses:
      "200":
        description: "成功的响应"
        content:
          application/json:
            schema:

                  type: "object"
                  properties:
                    choices:
                      type: "array"
                      description: "返回状态"
                      items:
                          type: "object"
                          properties:
                              message:
                                  type: "object"
                                  properties:
                                      content:
                                          type: "string"

                   
      "400":
        description: "错误的请求"
      "401":
        description: "未授权"
      "500":
        description: "服务器内部错误"

35pqxz1m7M6oEbu.png

然后点击下一步,发布就行了

2、创建智能体

点击创建智能体–点击使用工作流创建

3MYfkx5QU86yvhX.png

点击添加工作流–点击创建工作流

g9wPHyASCkj3FVm.png

先看看完整版的工作流

MB2TVLgD5ZbyvkN.png

工作流步骤::

  1. 点击添加 代码 节点,–输入参数–input,引用–userprompt

复制下面内容,替换原来内容

1
2
3
4
5
6
async def main(args):
   ret = {
       "messages": [{"role":"user","content":args['input']}]
  }
   print('result is: ', ret)
   return ret

1ONxydpWJnUoafR.png

按照我图片的来改,添加代码后要测试,并且更新节点,那个输入input随便输入什么例如:你好。然后更新节点

  1. 添加刚刚创建的插件

QlXEL9ROMkqgiC5.png

  1. 添加代码块

messages参数选择上一个节点的messages

model自行输入

插入 代码节点,参数名 reply 引用 choice,输入以下内容

1
2
3
4
5
6
async def main(args):
   ret = {
       "content": args["reply"][0]["message"]["content"],
  }
   print("result is: ", ret)
   return ret

3I2tYlP1AhTnyrF.png

测试时候,更新节点,代码测试内容:

1
2
3
4
5
6
7
[
      {
          "message": {
              "content": "根据您的描述,我建议您可以尝试以下方法..."
          }
      }
  ]
  1. 结束

MGbvi4hQ8dJZK2j.png

  1. 最后试运行发布

q8Rz7UAX6KEBb9t.png

3、配置机器人

这个自己去弄就行了

HZMaqNjJPupK9vx.png