|
@@ -0,0 +1,220 @@
|
|
|
|
|
+{
|
|
|
|
|
+ "name": "WeChatAIChating",
|
|
|
|
|
+ "description": "微信AI陪聊",
|
|
|
|
|
+ "variables": {
|
|
|
|
|
+ "turn": 1,
|
|
|
|
|
+ "relationBg": "",
|
|
|
|
|
+ "chatArea": "",
|
|
|
|
|
+ "chatHistoryMessage": "",
|
|
|
|
|
+ "currentChatMessage": "",
|
|
|
|
|
+ "lastHistoryMessage": "",
|
|
|
|
|
+ "lastChatMessage": "",
|
|
|
|
|
+ "lastChatRole": "",
|
|
|
|
|
+ "lastHistoryChatMessage": "",
|
|
|
|
|
+ "lastHistoryChatRole": "",
|
|
|
|
|
+ "aiReply": "",
|
|
|
|
|
+ "aiCallBack":0,
|
|
|
|
|
+ "sendBtnPos": "",
|
|
|
|
|
+ "newChatMessage": ""
|
|
|
|
|
+ },
|
|
|
|
|
+ "execute": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "schedule",
|
|
|
|
|
+ "condition":
|
|
|
|
|
+ {
|
|
|
|
|
+ "interval": "1s",
|
|
|
|
|
+ "repeat": 2
|
|
|
|
|
+ },
|
|
|
|
|
+ "interval":
|
|
|
|
|
+ [
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "echo",
|
|
|
|
|
+ "value": "==第 {{turn}} 轮=="
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "set",
|
|
|
|
|
+ "variable": "{turn}",
|
|
|
|
|
+ "value": "{turn} + 1"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type":"if",
|
|
|
|
|
+ "condition": "{chatArea}==\"\"",
|
|
|
|
|
+ "ture":
|
|
|
|
|
+ [
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "image-region-location",
|
|
|
|
|
+ "inVars": ["ScreenShot.jpg","ChatArea.png"],
|
|
|
|
|
+ "outVars": ["{chatArea}"]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "echo",
|
|
|
|
|
+ "value": "坐标: {{chatArea}}"
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "ocr-chat",
|
|
|
|
|
+ "inVars": ["(242,242,242)","(114,220,106)","{chatArea}"],
|
|
|
|
|
+ "outVars": ["{currentChatMessage}"]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "log",
|
|
|
|
|
+ "value": "当前聊天内容:{{currentChatMessage}}"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "read-txt",
|
|
|
|
|
+ "inVars": ["history/chat-history.txt"],
|
|
|
|
|
+ "outVars": ["{chatHistoryMessage}"]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "read-txt",
|
|
|
|
|
+ "inVars": ["history/bg.txt"],
|
|
|
|
|
+ "outVars": ["{relationBg}"]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "log",
|
|
|
|
|
+ "value": "背景内容:{{relationBg}}"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "if",
|
|
|
|
|
+ "condition": "{relationBg}==\"\"",
|
|
|
|
|
+ "ture":
|
|
|
|
|
+ [
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "if",
|
|
|
|
|
+ "condition": "{chatHistoryMessage}==\"\"",
|
|
|
|
|
+ "ture":
|
|
|
|
|
+ [
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "ai-generate",
|
|
|
|
|
+ "prompt": "根据聊天记录:{{currentChatMessage}},推理出我与聊天好友的关系背景,用一句话描述出来",
|
|
|
|
|
+ "inVars": [],
|
|
|
|
|
+ "outVars": ["{relationBg}","{aiCallBack}"]
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ "false":
|
|
|
|
|
+ [
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "ai-generate",
|
|
|
|
|
+ "prompt": "根据聊天记录:{{chatHistoryMessage}},推理出我与聊天好友的关系背景,用一句话描述出来",
|
|
|
|
|
+ "inVars": [],
|
|
|
|
|
+ "outVars": ["{relationBg}","{aiCallBack}"]
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "while",
|
|
|
|
|
+ "condition": "1 == aiCallBack",
|
|
|
|
|
+ "ture":
|
|
|
|
|
+ [
|
|
|
|
|
+
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "set",
|
|
|
|
|
+ "variable": "{aiCallBack}",
|
|
|
|
|
+ "value": "0"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "log",
|
|
|
|
|
+ "value": "==AI生成关系背景==:{{relationBg}}"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "save-txt",
|
|
|
|
|
+ "inVars": ["{relationBg}","history/bg.txt"],
|
|
|
|
|
+ "outVars": []
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "read-last-message",
|
|
|
|
|
+ "inVars": ["{currentChatMessage}"],
|
|
|
|
|
+ "outVars": ["{lastChatMessage}","{lastChatRole}"]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "log",
|
|
|
|
|
+ "value": "当前最后一条消息:{{lastChatMessage}}({{lastChatRole}})"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "read-last-message",
|
|
|
|
|
+ "inVars": ["{chatHistoryMessage}"],
|
|
|
|
|
+ "outVars": ["{lastHistoryChatMessage}","{lastHistoryChatRole}"]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "log",
|
|
|
|
|
+ "value": "==历史最后一条消息:{{lastHistoryChatMessage}}({{lastHistoryChatRole}})=="
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "if",
|
|
|
|
|
+ "condition": "{lastChatMessage} != {lastHistoryChatMessage}",
|
|
|
|
|
+ "ture":
|
|
|
|
|
+ [
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "log",
|
|
|
|
|
+ "value":"AI自动回复流程开始=="
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "if",
|
|
|
|
|
+ "condition": "{lastChatRole} == \"friend\"",
|
|
|
|
|
+ "ture":
|
|
|
|
|
+ [
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "ai-generate",
|
|
|
|
|
+ "prompt": "根据我们背景关系描述:{{relationBg}},以及我们的聊天记录:{{lastChatMessage}},帮我做出适合回复,不要给建议,直接给一条你认为最好的回复信息,回复信息字数要符合微信聊天习惯",
|
|
|
|
|
+ "inVars": [],
|
|
|
|
|
+ "outVars": ["{aiReply}","{aiCallBack}"]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "while",
|
|
|
|
|
+ "condition": "1 == aiCallBack",
|
|
|
|
|
+ "ture":
|
|
|
|
|
+ [
|
|
|
|
|
+
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "set",
|
|
|
|
|
+ "variable": "{aiCallBack}",
|
|
|
|
|
+ "value": "0"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "adb",
|
|
|
|
|
+ "method": "input",
|
|
|
|
|
+ "inVars": ["{aiReply}"]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "if",
|
|
|
|
|
+ "condition": "{sendBtnPos} == \"\"",
|
|
|
|
|
+ "ture":
|
|
|
|
|
+ [
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "image-center-location",
|
|
|
|
|
+ "inVars": ["微信聊天界面的发送按钮定位图.png"],
|
|
|
|
|
+ "outVars": ["{sendBtnPos}"]
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "adb",
|
|
|
|
|
+ "method": "click",
|
|
|
|
|
+ "inVars": ["{sendBtnPos}"]
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type":"smart-chat-append",
|
|
|
|
|
+ "inVars": ["{chatHistoryMessage}","{currentChatMessage}"],
|
|
|
|
|
+ "outVars": ["{newChatMessage}"]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "type": "save-txt",
|
|
|
|
|
+ "inVars": ["{newChatMessage}","history/chat-history.txt"],
|
|
|
|
|
+ "outVars": []
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+}
|