process.json 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. "newChatMessage": ""
  19. },
  20. "execute": [
  21. {
  22. "type": "schedule",
  23. "condition":
  24. {
  25. "interval": "1s",
  26. "repeat": 2
  27. },
  28. "interval":
  29. [
  30. {
  31. "type": "echo",
  32. "value": "==第 {{turn}} 轮=="
  33. },
  34. {
  35. "type": "set",
  36. "variable": "{turn}",
  37. "value": "{turn} + 1"
  38. },
  39. {
  40. "type":"if",
  41. "condition": "{chatArea}==\"\"",
  42. "ture":
  43. [
  44. {
  45. "type": "fun",
  46. "method": "img-bounding-box-location",
  47. "inVars": ["ScreenShot.jpg","ChatArea.png"],
  48. "outVars": ["{chatArea}"]
  49. },
  50. {
  51. "type": "echo",
  52. "value": "坐标: {{chatArea}}"
  53. }
  54. ]
  55. },
  56. {
  57. "type": "fun",
  58. "method": "ocr-chat",
  59. "inVars": ["(242,242,242)","(114,220,106)","{chatArea}"],
  60. "outVars": ["{currentChatMessage}"]
  61. },
  62. {
  63. "type": "log",
  64. "value": "当前聊天内容:{{currentChatMessage}}"
  65. },
  66. {
  67. "type": "fun",
  68. "method": "read-txt",
  69. "inVars": ["history/chat-history.txt"],
  70. "outVars": ["{chatHistoryMessage}"]
  71. },
  72. {
  73. "type": "fun",
  74. "method": "read-txt",
  75. "inVars": ["history/bg.txt"],
  76. "outVars": ["{relationBg}"]
  77. },
  78. {
  79. "type": "log",
  80. "value": "背景内容:{{relationBg}}"
  81. },
  82. {
  83. "type": "if",
  84. "condition": "{relationBg}==\"\"",
  85. "ture":
  86. [
  87. {
  88. "type": "if",
  89. "condition": "{chatHistoryMessage}==\"\"",
  90. "ture":
  91. [
  92. {
  93. "type": "fun",
  94. "method": "ai-generate",
  95. "prompt": "根据聊天记录:{{currentChatMessage}},推理出我与聊天好友的关系背景,用一句话描述出来",
  96. "inVars": [],
  97. "outVars": ["{relationBg}","{aiCallBack}"]
  98. }
  99. ],
  100. "false":
  101. [
  102. {
  103. "type": "fun",
  104. "method": "ai-generate",
  105. "prompt": "根据聊天记录:{{chatHistoryMessage}},推理出我与聊天好友的关系背景,用一句话描述出来",
  106. "inVars": [],
  107. "outVars": ["{relationBg}","{aiCallBack}"]
  108. }
  109. ]
  110. },
  111. {
  112. "type": "while",
  113. "condition": "1 == aiCallBack",
  114. "ture":
  115. [
  116. ]
  117. },
  118. {
  119. "type": "set",
  120. "variable": "{aiCallBack}",
  121. "value": "0"
  122. },
  123. {
  124. "type": "log",
  125. "value": "==AI生成关系背景==:{{relationBg}}"
  126. },
  127. {
  128. "type": "fun",
  129. "method": "save-txt",
  130. "inVars": ["{relationBg}","history/bg.txt"],
  131. "outVars": []
  132. }
  133. ]
  134. },
  135. {
  136. "type": "fun",
  137. "method": "read-last-message",
  138. "inVars": ["{currentChatMessage}"],
  139. "outVars": ["{lastChatMessage}","{lastChatRole}"]
  140. },
  141. {
  142. "type": "log",
  143. "value": "当前最后一条消息:{{lastChatMessage}}({{lastChatRole}})"
  144. },
  145. {
  146. "type": "fun",
  147. "method": "read-last-message",
  148. "inVars": ["{chatHistoryMessage}"],
  149. "outVars": ["{lastHistoryChatMessage}","{lastHistoryChatRole}"]
  150. },
  151. {
  152. "type": "log",
  153. "value": "==历史最后一条消息:{{lastHistoryChatMessage}}({{lastHistoryChatRole}})=="
  154. },
  155. {
  156. "type": "if",
  157. "condition": "{lastChatMessage} != {lastHistoryChatMessage}",
  158. "ture":
  159. [
  160. {
  161. "type": "log",
  162. "value":"AI自动回复流程开始=="
  163. },
  164. {
  165. "type": "if",
  166. "condition": "{lastChatRole} == \"friend\"",
  167. "ture":
  168. [
  169. {
  170. "type": "fun",
  171. "method": "ai-generate",
  172. "prompt": "根据我们背景关系描述:{{relationBg}},以及我们的聊天记录:{{lastChatMessage}},帮我做出适合回复,不要给建议,直接给一条你认为最好的回复信息,回复信息字数要符合微信聊天习惯",
  173. "inVars": [],
  174. "outVars": ["{aiReply}","{aiCallBack}"]
  175. },
  176. {
  177. "type": "while",
  178. "condition": "1 == aiCallBack",
  179. "ture":
  180. [
  181. ]
  182. },
  183. {
  184. "type": "set",
  185. "variable": "{aiCallBack}",
  186. "value": "0"
  187. },
  188. {
  189. "type": "adb",
  190. "method": "input",
  191. "inVars": ["{aiReply}"]
  192. },
  193. {
  194. "type": "if",
  195. "condition": "{sendBtnPos} == \"\"",
  196. "ture":
  197. [
  198. {
  199. "type": "fun",
  200. "method": "img-center-point-location",
  201. "inVars": ["微信聊天界面的发送按钮定位图.png"],
  202. "outVars": ["{sendBtnPos}"]
  203. }
  204. ]
  205. },
  206. {
  207. "type": "adb",
  208. "method": "click",
  209. "inVars": ["{sendBtnPos}"]
  210. }
  211. ]
  212. },
  213. {
  214. "type": "fun",
  215. "method": "smart-chat-append",
  216. "inVars": ["{chatHistoryMessage}","{currentChatMessage}"],
  217. "outVars": ["{newChatMessage}"]
  218. },
  219. {
  220. "type": "fun",
  221. "method": "save-txt",
  222. "inVars": ["{newChatMessage}","history/chat-history.txt"],
  223. "outVars": []
  224. }
  225. ]
  226. }
  227. ]
  228. }
  229. ]
  230. }