process.json 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. {
  2. "name": "WeChatAIChating",
  3. "description": "微信AI陪聊",
  4. "variables": {
  5. "turn": 1,
  6. "relationBg": "",
  7. "chatArea": "",
  8. "chatHistoryMessage": "",
  9. "currentChatMessage": "",
  10. "lastHistoryMessage": "",
  11. "lastChatMessage": "",
  12. "lastChatRole": "",
  13. "lastHistoryChatMessage": "",
  14. "lastHistoryChatRole": "",
  15. "aiReply": "",
  16. "aiCallBack": 0,
  17. "sendBtnPos": "",
  18. "wx_send_btn_center_pos": "",
  19. "newChatMessage": ""
  20. },
  21. "execute": [
  22. {
  23. "type": "schedule",
  24. "condition": {
  25. "interval": "1s",
  26. "repeat": 2
  27. },
  28. "interval": [
  29. {
  30. "type": "echo",
  31. "inVars": [
  32. "==第 {{turn}} 轮=="
  33. ]
  34. },
  35. {
  36. "type": "set",
  37. "variable": "{turn}",
  38. "value": "{turn} + 1"
  39. },
  40. {
  41. "type": "if",
  42. "condition": "{chatArea}==\"\"",
  43. "then": [
  44. {
  45. "type": "fun",
  46. "method": "img-bounding-box-location",
  47. "inVars": [
  48. "ScreenShot.jpg",
  49. "ChatArea.png"
  50. ],
  51. "outVars": [
  52. "{chatArea}"
  53. ]
  54. },
  55. {
  56. "type": "echo",
  57. "inVars": [
  58. "坐标: {{chatArea}}"
  59. ]
  60. }
  61. ],
  62. "else": []
  63. },
  64. {
  65. "type": "fun",
  66. "method": "ocr-chat",
  67. "inVars": [
  68. "(242,242,242)",
  69. "(114,220,106)",
  70. "{chatArea}"
  71. ],
  72. "outVars": [
  73. "{currentChatMessage}"
  74. ]
  75. },
  76. {
  77. "type": "echo",
  78. "inVars": [
  79. "当前聊天内容:{{currentChatMessage}}"
  80. ]
  81. },
  82. {
  83. "type": "fun",
  84. "method": "read-txt",
  85. "inVars": [
  86. "history/chat-history.txt"
  87. ],
  88. "outVars": [
  89. "{chatHistoryMessage}"
  90. ]
  91. },
  92. {
  93. "type": "fun",
  94. "method": "read-txt",
  95. "inVars": [
  96. "history/bg.txt"
  97. ],
  98. "outVars": [
  99. "{relationBg}"
  100. ]
  101. },
  102. {
  103. "type": "echo",
  104. "inVars": [
  105. "背景内容:{{relationBg}}"
  106. ]
  107. },
  108. {
  109. "type": "if",
  110. "condition": "{relationBg}==\"\"",
  111. "then": [
  112. {
  113. "type": "if",
  114. "condition": "{chatHistoryMessage}==\"\"",
  115. "then": [
  116. {
  117. "type": "fun",
  118. "method": "ai-generate",
  119. "inVars": [
  120. "根据聊天记录:{{currentChatMessage}},推理出我与聊天好友的关系背景,用一句话描述出来"
  121. ],
  122. "outVars": [
  123. "{relationBg}",
  124. "{aiCallBack}"
  125. ]
  126. }
  127. ],
  128. "else": [
  129. {
  130. "type": "fun",
  131. "method": "ai-generate",
  132. "inVars": [
  133. "根据聊天记录:{{chatHistoryMessage}},推理出我与聊天好友的关系背景,用一句话描述出来"
  134. ],
  135. "outVars": [
  136. "{relationBg}",
  137. "{aiCallBack}"
  138. ]
  139. }
  140. ]
  141. },
  142. {
  143. "type": "while",
  144. "condition": "1 == aiCallBack",
  145. "body": []
  146. },
  147. {
  148. "type": "set",
  149. "variable": "{aiCallBack}",
  150. "value": "0"
  151. },
  152. {
  153. "type": "echo",
  154. "inVars": [
  155. "==AI生成关系背景==:{{relationBg}}"
  156. ]
  157. },
  158. {
  159. "type": "fun",
  160. "method": "save-txt",
  161. "inVars": [
  162. "{relationBg}",
  163. "history/bg.txt"
  164. ],
  165. "outVars": []
  166. }
  167. ],
  168. "else": []
  169. },
  170. {
  171. "type": "fun",
  172. "method": "read-last-message",
  173. "inVars": [
  174. "{currentChatMessage}"
  175. ],
  176. "outVars": [
  177. "{lastChatMessage}",
  178. "{lastChatRole}"
  179. ]
  180. },
  181. {
  182. "type": "echo",
  183. "inVars": [
  184. "当前最后一条消息:{{lastChatMessage}}({{lastChatRole}})"
  185. ]
  186. },
  187. {
  188. "type": "fun",
  189. "method": "read-last-message",
  190. "inVars": [
  191. "{chatHistoryMessage}"
  192. ],
  193. "outVars": [
  194. "{lastHistoryChatMessage}",
  195. "{lastHistoryChatRole}"
  196. ]
  197. },
  198. {
  199. "type": "echo",
  200. "inVars": [
  201. "==历史最后一条消息:{{lastHistoryChatMessage}}({{lastHistoryChatRole}})=="
  202. ]
  203. },
  204. {
  205. "type": "if",
  206. "condition": "{lastChatMessage} != {lastHistoryChatMessage}",
  207. "then": [
  208. {
  209. "type": "echo",
  210. "inVars": [
  211. "AI自动回复流程开始=="
  212. ]
  213. },
  214. {
  215. "type": "if",
  216. "condition": "{lastChatRole} == \"friend\"",
  217. "then": [
  218. {
  219. "type": "fun",
  220. "method": "ai-generate",
  221. "inVars": [
  222. "根据我们背景关系描述:{{relationBg}},以及我们的聊天记录:{{lastChatMessage}},帮我做出适合回复,不要给建议,直接给一条你认为最好的回复信息,回复信息字数要符合微信聊天习惯"
  223. ],
  224. "outVars": [
  225. "{aiReply}",
  226. "{aiCallBack}"
  227. ]
  228. },
  229. {
  230. "type": "while",
  231. "condition": "1 == aiCallBack",
  232. "body": []
  233. },
  234. {
  235. "type": "set",
  236. "variable": "{aiCallBack}",
  237. "value": "0"
  238. },
  239. {
  240. "type": "fun",
  241. "method": "adb-input",
  242. "inVars": [
  243. "{aiReply}"
  244. ],
  245. "outVars": []
  246. },
  247. {
  248. "type": "if",
  249. "condition": "{wx_send_btn_center_pos} != \"\"",
  250. "then": [
  251. {
  252. "type": "fun",
  253. "method": "img-center-point-location",
  254. "inVars": [
  255. "微信聊天界面的发送按钮定位图.png"
  256. ],
  257. "outVars": [
  258. "{sendBtnPos}"
  259. ]
  260. },
  261. {
  262. "type": "fun",
  263. "method": "persist-save",
  264. "inVars": [
  265. "wx_send_btn_center",
  266. "{sendBtnPos}"
  267. ],
  268. "outVars": []
  269. }
  270. ],
  271. "else": [
  272. {
  273. "type": "fun",
  274. "method": "persist-read",
  275. "inVars": [
  276. "wx_send_btn_center"
  277. ],
  278. "outVars": [
  279. "{sendBtnPos}"
  280. ]
  281. }
  282. ]
  283. },
  284. {
  285. "type": "fun",
  286. "method": "adb-click",
  287. "inVars": [
  288. "{sendBtnPos}"
  289. ],
  290. "outVars": []
  291. }
  292. ],
  293. "else": []
  294. },
  295. {
  296. "type": "fun",
  297. "method": "smart-chat-append",
  298. "inVars": [
  299. "{chatHistoryMessage}",
  300. "{currentChatMessage}"
  301. ],
  302. "outVars": [
  303. "{newChatMessage}"
  304. ]
  305. },
  306. {
  307. "type": "fun",
  308. "method": "save-txt",
  309. "inVars": [
  310. "{newChatMessage}",
  311. "history/chat-history.txt"
  312. ],
  313. "outVars": []
  314. }
  315. ],
  316. "else": []
  317. }
  318. ]
  319. }
  320. ]
  321. }