『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
楼主: lidicn

[流程系列] 【node-red】让小爱变聪明【ChatGPT】

  [复制链接]

0

主题

3

帖子

74

积分

注册会员

Rank: 2

积分
74
金钱
71
HASS币
0
发表于 2024-1-26 14:20:40 | 显示全部楼层
看看支持
回复

使用道具 举报

0

主题

2

帖子

28

积分

新手上路

Rank: 1

积分
28
金钱
26
HASS币
0
发表于 2024-1-26 17:12:50 | 显示全部楼层
感谢分享
回复

使用道具 举报

0

主题

2

帖子

18

积分

新手上路

Rank: 1

积分
18
金钱
16
HASS币
0
发表于 2024-1-27 13:54:59 | 显示全部楼层
大佬, 感谢分享
回复

使用道具 举报

0

主题

11

帖子

106

积分

注册会员

Rank: 2

积分
106
金钱
95
HASS币
0
发表于 2024-1-27 14:23:14 | 显示全部楼层
谢谢大神
回复

使用道具 举报

0

主题

16

帖子

99

积分

注册会员

Rank: 2

积分
99
金钱
83
HASS币
0
发表于 2024-1-28 16:08:12 | 显示全部楼层
[
    {
        "id": "73f4cb07bcf61615",
        "type": "server-state-changed",
        "z": "8c8242e7b6ea02a8",
        "name": "小爱音箱",
        "server": "459a05598e74e156",
        "version": 4,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.xiaomi_lx5a_7d9b_conversation",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 160,
        "y": 1400,
        "wires": [
            [
                "50ef668ebea29429",
                "3f3dabf2834007ca"
            ]
        ]
    },
    {
        "id": "3f3dabf2834007ca",
        "type": "switch",
        "z": "8c8242e7b6ea02a8",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "开启贾维斯",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "召唤贾维斯",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "打开贾维斯",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "退出贾维斯",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "关闭贾维斯",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 5,
        "x": 350,
        "y": 1320,
        "wires": [
            [
                "039fbd671807fa3f"
            ],
            [
                "039fbd671807fa3f"
            ],
            [
                "039fbd671807fa3f"
            ],
            [
                "5121643a1fa5d572"
            ],
            [
                "5121643a1fa5d572"
            ]
        ]
    },
    {
        "id": "4b01a0e4fc04ec84",
        "type": "debug",
        "z": "8c8242e7b6ea02a8",
        "name": "debug 334",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 810,
        "y": 1360,
        "wires": []
    },
    {
        "id": "d5960fdc46d6972a",
        "type": "inject",
        "z": "8c8242e7b6ea02a8",
        "name": "",
        "props": [
            {
                "p": "wt",
                "v": "帮我策划一个十岁小孩的生日",
                "vt": "str"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 190,
        "y": 1580,
        "wires": [
            [
                "8773f238830b2caa"
            ]
        ]
    },
    {
        "id": "8773f238830b2caa",
        "type": "function",
        "z": "8c8242e7b6ea02a8",
        "name": "function 32",
        "func": "msg.headers = {\n    'Content-Type': 'application/json',\n    'Authorization': 'Bearer your key'\n    }\n\n\nmsg.payload = {\n    \"model\": \"gpt-3.5-turbo\",\n    \"messages\": [\n        {\n            \"role\": \"system\",\n            \"content\": \"You are a helpful assistant.\"\n        },\n        {\n            \"role\": \"user\",\n            \"content\": msg.wt\n        }\n    ]\n}\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 370,
        "y": 1580,
        "wires": [
            [
                "efabfcb91ec074c3"
            ]
        ]
    },
    {
        "id": "efabfcb91ec074c3",
        "type": "http request",
        "z": "8c8242e7b6ea02a8",
        "name": "",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://api.chatanywhere.tech/v1/chat/completions",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 520,
        "y": 1580,
        "wires": [
            [
                "0977d103cb1ba3f9"
            ]
        ]
    },
    {
        "id": "0977d103cb1ba3f9",
        "type": "json",
        "z": "8c8242e7b6ea02a8",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 650,
        "y": 1580,
        "wires": [
            [
                "f02c68977360528a"
            ]
        ]
    },
    {
        "id": "82e28a5544ebc505",
        "type": "debug",
        "z": "8c8242e7b6ea02a8",
        "name": "debug 335",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1030,
        "y": 1580,
        "wires": []
    },
    {
        "id": "f02c68977360528a",
        "type": "change",
        "z": "8c8242e7b6ea02a8",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.choices[0].message.content",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 830,
        "y": 1580,
        "wires": [
            [
                "82e28a5544ebc505",
                "db79d520a7ee4b61"
            ]
        ]
    },
    {
        "id": "db79d520a7ee4b61",
        "type": "api-call-service",
        "z": "8c8242e7b6ea02a8",
        "name": "小爱播放结果",
        "server": "459a05598e74e156",
        "version": 5,
        "debugenabled": false,
        "domain": "xiaomi_miot",
        "service": "intelligent_speaker",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "media_player.xiaomi_lx5a_7d9b_play_control"
        ],
        "data": "{\"text\":msg.payload}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 940,
        "y": 1680,
        "wires": [
            []
        ]
    },
    {
        "id": "039fbd671807fa3f",
        "type": "api-call-service",
        "z": "8c8242e7b6ea02a8",
        "name": "",
        "server": "459a05598e74e156",
        "version": 5,
        "debugenabled": false,
        "domain": "input_boolean",
        "service": "turn_on",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "input_boolean.xiao_ai_yin_xiang_chatgptkai_guan"
        ],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 540,
        "y": 1300,
        "wires": [
            []
        ]
    },
    {
        "id": "a14c57cda204418c",
        "type": "api-current-state",
        "z": "8c8242e7b6ea02a8",
        "name": "贾维斯开关",
        "server": "459a05598e74e156",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_boolean.xiao_ai_yin_xiang_chatgptkai_guan",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 630,
        "y": 1480,
        "wires": [
            [
                "4b01a0e4fc04ec84",
                "2dfa531005c8b19c"
            ],
            []
        ]
    },
    {
        "id": "499eac86a8f557c6",
        "type": "api-call-service",
        "z": "8c8242e7b6ea02a8",
        "name": "小爱播放结果",
        "server": "459a05598e74e156",
        "version": 5,
        "debugenabled": false,
        "domain": "xiaomi_miot",
        "service": "intelligent_speaker",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "media_player.xiaomi_lx5a_7d9b_play_control"
        ],
        "data": "{\"text\":\"贾维斯正在查询,请稍后\"}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1000,
        "y": 1440,
        "wires": [
            []
        ]
    },
    {
        "id": "50ef668ebea29429",
        "type": "change",
        "z": "8c8242e7b6ea02a8",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "wt",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 310,
        "y": 1480,
        "wires": [
            [
                "b825827679c20f63"
            ]
        ]
    },
    {
        "id": "5121643a1fa5d572",
        "type": "api-call-service",
        "z": "8c8242e7b6ea02a8",
        "name": "",
        "server": "459a05598e74e156",
        "version": 5,
        "debugenabled": false,
        "domain": "input_boolean",
        "service": "turn_off",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "input_boolean.xiao_ai_yin_xiang_chatgptkai_guan"
        ],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 540,
        "y": 1360,
        "wires": [
            []
        ]
    },
    {
        "id": "b825827679c20f63",
        "type": "delay",
        "z": "8c8242e7b6ea02a8",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 480,
        "y": 1480,
        "wires": [
            [
                "a14c57cda204418c"
            ]
        ]
    },
    {
        "id": "2dfa531005c8b19c",
        "type": "switch",
        "z": "8c8242e7b6ea02a8",
        "name": "",
        "property": "wt",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "打开贾维斯",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "召唤贾维斯",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "启动贾维斯",
                "vt": "str"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 4,
        "x": 810,
        "y": 1480,
        "wires": [
            [],
            [],
            [],
            [
                "8773f238830b2caa",
                "499eac86a8f557c6"
            ]
        ]
    },
    {
        "id": "459a05598e74e156",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    }
]
回复

使用道具 举报

0

主题

1

帖子

26

积分

新手上路

Rank: 1

积分
26
金钱
25
HASS币
0
发表于 2024-1-29 20:30:01 | 显示全部楼层
强烈支持!!
回复

使用道具 举报

0

主题

3

帖子

34

积分

新手上路

Rank: 1

积分
34
金钱
31
HASS币
0
发表于 2024-1-31 03:16:45 | 显示全部楼层
我来学习一下
回复

使用道具 举报

0

主题

29

帖子

252

积分

中级会员

Rank: 3Rank: 3

积分
252
金钱
223
HASS币
0
发表于 2024-1-31 10:50:55 | 显示全部楼层

强烈支持!
回复

使用道具 举报

3

主题

40

帖子

141

积分

注册会员

Rank: 2

积分
141
金钱
101
HASS币
0
发表于 2024-1-31 11:10:11 | 显示全部楼层
嘘唏一下,这个有意思
回复

使用道具 举报

0

主题

2

帖子

22

积分

新手上路

Rank: 1

积分
22
金钱
20
HASS币
0
发表于 2024-2-1 14:17:29 | 显示全部楼层
终于找到nodered体系的ChatGPT了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-16 09:12 , Processed in 0.161752 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表