{ "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": "fun", "method": "img-bounding-box-location", "inVars": ["ScreenShot.jpg","ChatArea.png"], "outVars": ["{chatArea}"] }, { "type": "echo", "value": "坐标: {{chatArea}}" } ] }, { "type": "fun", "method": "ocr-chat", "inVars": ["(242,242,242)","(114,220,106)","{chatArea}"], "outVars": ["{currentChatMessage}"] }, { "type": "log", "value": "当前聊天内容:{{currentChatMessage}}" }, { "type": "fun", "method": "read-txt", "inVars": ["history/chat-history.txt"], "outVars": ["{chatHistoryMessage}"] }, { "type": "fun", "method": "read-txt", "inVars": ["history/bg.txt"], "outVars": ["{relationBg}"] }, { "type": "log", "value": "背景内容:{{relationBg}}" }, { "type": "if", "condition": "{relationBg}==\"\"", "ture": [ { "type": "if", "condition": "{chatHistoryMessage}==\"\"", "ture": [ { "type": "fun", "method": "ai-generate", "prompt": "根据聊天记录:{{currentChatMessage}},推理出我与聊天好友的关系背景,用一句话描述出来", "inVars": [], "outVars": ["{relationBg}","{aiCallBack}"] } ], "false": [ { "type": "fun", "method": "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": "fun", "method": "save-txt", "inVars": ["{relationBg}","history/bg.txt"], "outVars": [] } ] }, { "type": "fun", "method": "read-last-message", "inVars": ["{currentChatMessage}"], "outVars": ["{lastChatMessage}","{lastChatRole}"] }, { "type": "log", "value": "当前最后一条消息:{{lastChatMessage}}({{lastChatRole}})" }, { "type": "fun", "method": "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": "fun", "method": "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": "fun", "method": "img-center-point-location", "inVars": ["微信聊天界面的发送按钮定位图.png"], "outVars": ["{sendBtnPos}"] } ] }, { "type": "adb", "method": "click", "inVars": ["{sendBtnPos}"] } ] }, { "type": "fun", "method": "smart-chat-append", "inVars": ["{chatHistoryMessage}","{currentChatMessage}"], "outVars": ["{newChatMessage}"] }, { "type": "fun", "method": "save-txt", "inVars": ["{newChatMessage}","history/chat-history.txt"], "outVars": [] } ] } ] } ] }