wechaty-web-panel 1.6.56 → 1.6.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +23 -0
  3. package/dist/cjs/src/botInstance/dify.d.ts +4 -1
  4. package/dist/cjs/src/botInstance/dify.js +6 -6
  5. package/dist/cjs/src/botInstance/officialOpenAi.d.ts +1 -1
  6. package/dist/cjs/src/botInstance/officialOpenAi.js +4 -1
  7. package/dist/cjs/src/botInstance/sdk/chatGPT.js +4 -1
  8. package/dist/cjs/src/botInstance/sdk/difyClient.d.ts +2 -1
  9. package/dist/cjs/src/botInstance/sdk/difyClient.js +4 -2
  10. package/dist/cjs/src/handlers/on-message.js +17 -6
  11. package/dist/cjs/src/package-json.d.ts +11 -1
  12. package/dist/cjs/src/package-json.js +13 -3
  13. package/dist/cjs/src/proxy/bot/chatgpt.d.ts +4 -1
  14. package/dist/cjs/src/proxy/bot/chatgpt.js +2 -2
  15. package/dist/cjs/src/proxy/bot/dify.d.ts +4 -1
  16. package/dist/cjs/src/proxy/bot/dify.js +2 -2
  17. package/dist/cjs/src/proxy/bot/dispatch.d.ts +1 -1
  18. package/dist/cjs/src/proxy/bot/dispatch.js +6 -6
  19. package/dist/cjs/src/proxy/difyAi.d.ts +8 -3
  20. package/dist/cjs/src/proxy/difyAi.js +4 -4
  21. package/dist/cjs/src/proxy/openAi.d.ts +3 -2
  22. package/dist/cjs/src/proxy/openAi.js +4 -4
  23. package/dist/cjs/src/service/event-dispatch-service.d.ts +6 -2
  24. package/dist/cjs/src/service/event-dispatch-service.js +9 -9
  25. package/dist/cjs/src/service/msg-filters.d.ts +2 -1
  26. package/dist/cjs/src/service/msg-filters.js +9 -5
  27. package/dist/cjs/test/wechat.d.ts +2 -0
  28. package/dist/cjs/test/wechat.js +34 -0
  29. package/dist/cjs/test/wework.d.ts +2 -0
  30. package/dist/cjs/test/wework.js +27 -0
  31. package/dist/esm/src/botInstance/dify.d.ts +4 -1
  32. package/dist/esm/src/botInstance/dify.js +6 -6
  33. package/dist/esm/src/botInstance/officialOpenAi.d.ts +1 -1
  34. package/dist/esm/src/botInstance/officialOpenAi.js +4 -1
  35. package/dist/esm/src/botInstance/sdk/chatGPT.js +4 -1
  36. package/dist/esm/src/botInstance/sdk/difyClient.d.ts +2 -1
  37. package/dist/esm/src/botInstance/sdk/difyClient.js +4 -2
  38. package/dist/esm/src/handlers/on-message.js +17 -6
  39. package/dist/esm/src/package-json.d.ts +11 -1
  40. package/dist/esm/src/package-json.js +13 -3
  41. package/dist/esm/src/proxy/bot/chatgpt.d.ts +4 -1
  42. package/dist/esm/src/proxy/bot/chatgpt.js +2 -2
  43. package/dist/esm/src/proxy/bot/dify.d.ts +4 -1
  44. package/dist/esm/src/proxy/bot/dify.js +2 -2
  45. package/dist/esm/src/proxy/bot/dispatch.d.ts +1 -1
  46. package/dist/esm/src/proxy/bot/dispatch.js +6 -6
  47. package/dist/esm/src/proxy/difyAi.d.ts +8 -3
  48. package/dist/esm/src/proxy/difyAi.js +4 -4
  49. package/dist/esm/src/proxy/openAi.d.ts +3 -2
  50. package/dist/esm/src/proxy/openAi.js +4 -4
  51. package/dist/esm/src/service/event-dispatch-service.d.ts +6 -2
  52. package/dist/esm/src/service/event-dispatch-service.js +10 -10
  53. package/dist/esm/src/service/msg-filters.d.ts +2 -1
  54. package/dist/esm/src/service/msg-filters.js +9 -5
  55. package/dist/esm/test/wechat.d.ts +2 -0
  56. package/dist/esm/test/wechat.js +32 -0
  57. package/dist/esm/test/wework.d.ts +2 -0
  58. package/dist/esm/test/wework.js +25 -0
  59. package/package.json +13 -3
  60. package/dist/cjs/test/index.d.ts +0 -2
  61. package/dist/cjs/test/index.js +0 -23
  62. package/dist/esm/test/index.d.ts +0 -2
  63. package/dist/esm/test/index.js +0 -18
package/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  ## 更新日志
2
2
 
3
- ### V1.6.55(2024-06-03)
3
+ ### V1.6.58(2024-07-10)
4
+ 1、Dify 和 FastGPT 每次调用都会携带用户信息和群聊信息,可以使用环境变量获取,实现真正的个性化机器人服务,更像真人
5
+
6
+ ### V1.6.57(2024-06-05)
7
+ 1、添加聊天内容记录到本地
8
+
9
+ ### V1.6.56(2024-06-03)
4
10
  1、添加聊天内容记录到本地
5
11
  2、添加内测功能-聊天总结功能
6
12
 
package/README.md CHANGED
@@ -8,6 +8,29 @@ Wechaty Web Panel 插件,让你的 Wechaty 机器人快速接入 web 控制面
8
8
 
9
9
  本项目为插件源码,非直接运行的项目。如需可直接运行的项目,请直接拉取 [https://github.com/leochen-g/wechat-assistant-pro](https://github.com/leochen-g/wechat-assistant-pro) 即可
10
10
 
11
+ ## 快速测试
12
+
13
+ ### 下载源码并安装依赖
14
+
15
+ ```sh
16
+ git clone https://github.com/leochen-g/wechaty-web-panel.git
17
+ cd wechaty-web-panel
18
+ npm install # 可指定淘宝镜像源加速: --registry=https://registry.npmmirror.com
19
+ ```
20
+
21
+ ### 测试微信
22
+
23
+ 在 test/wechat.js文件中填入apiKey与apiSecret,运行如下命令
24
+ ```sh
25
+ npm run test:wechat
26
+ ```
27
+
28
+ ### 测试企业微信
29
+ 需要有企业微信token,在test/wework.js填入workProToken、apiKey与apiSecret,运行如下命令
30
+ ```sh
31
+ npm run test:wework
32
+ ```
33
+
11
34
  ## 面板主要功能
12
35
 
13
36
  * 定时提醒
@@ -31,7 +31,10 @@ declare class DifyAi {
31
31
  * @return {Promise<void>}
32
32
  */
33
33
  reset(): Promise<void>;
34
- getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<{
34
+ getReply({ content, inputs }: {
35
+ content: any;
36
+ inputs: any;
37
+ }, id: any, adminId?: string, systemMessage?: string): Promise<{
35
38
  type: number;
36
39
  content: any;
37
40
  }[]>;
@@ -59,7 +59,7 @@ class DifyAi {
59
59
  reset() {
60
60
  this.difyChat = null;
61
61
  }
62
- async getReply(content, uid, adminId = '', systemMessage = '') {
62
+ async getReply({ content, inputs }, id, adminId = '', systemMessage = '') {
63
63
  try {
64
64
  if (!this.difyChat) {
65
65
  console.log('启用Dify对话平台');
@@ -74,12 +74,12 @@ class DifyAi {
74
74
  }
75
75
  if (systemMessage || content === 'reset' || content === '重置') {
76
76
  console.log('重新更新上下文对话');
77
- this.chatOption[uid] = {};
77
+ this.chatOption[id] = {};
78
78
  if (content === 'reset' || content === '重置') {
79
79
  return [{ type: 1, content: '上下文已重置' }];
80
80
  }
81
81
  }
82
- const { conversationId, text, files } = systemMessage ? await this.difyChat.sendMessage(content, { ...this.chatOption[uid], systemMessage, timeoutMs: this.config.timeoutMs * 1000 || 80 * 1000, user: uid }) : await this.difyChat.sendMessage(content, { ...this.chatOption[uid], timeoutMs: this.config.timeoutMs * 1000 || 80 * 1000, user: uid });
82
+ const { conversationId, text, files } = systemMessage ? await this.difyChat.sendMessage(content, { ...this.chatOption[id], inputs, systemMessage, timeoutMs: this.config.timeoutMs * 1000 || 80 * 1000, user: id }) : await this.difyChat.sendMessage(content, { ...this.chatOption[id], inputs, timeoutMs: this.config.timeoutMs * 1000 || 80 * 1000, user: id });
83
83
  if (this.config.filter) {
84
84
  const censor = await this.contentCensor.checkText(text);
85
85
  if (!censor) {
@@ -88,11 +88,11 @@ class DifyAi {
88
88
  }
89
89
  }
90
90
  if (this.config.record) {
91
- void (0, aichatDb_js_1.addAichatRecord)({ contactId: uid, adminId, input: content, output: text, time: (0, dayjs_1.default)().format('YYYY-MM-DD HH:mm:ss') });
91
+ void (0, aichatDb_js_1.addAichatRecord)({ contactId: id, adminId, input: content, output: text, time: (0, dayjs_1.default)().format('YYYY-MM-DD HH:mm:ss') });
92
92
  }
93
93
  // 保存对话id 对于同一个用户的对话不更新conversationId
94
- if (!this.chatOption[uid]?.conversationId) {
95
- this.chatOption[uid] = {
94
+ if (!this.chatOption[id]?.conversationId) {
95
+ this.chatOption[id] = {
96
96
  conversationId
97
97
  };
98
98
  }
@@ -66,7 +66,7 @@ declare class OfficialOpenAi {
66
66
  * @return {Promise<void>}
67
67
  */
68
68
  reset(): Promise<void>;
69
- getReply(content: any, uid: any, adminId: string | undefined, systemMessage: string | undefined, isFastGPT: any): Promise<{
69
+ getReply(content: any, uid: any, adminId: string | undefined, systemMessage: string | undefined, isFastGPT: any, variables: any): Promise<{
70
70
  type: number;
71
71
  content: any;
72
72
  }[]>;
@@ -135,7 +135,7 @@ class OfficialOpenAi {
135
135
  reset() {
136
136
  this.chatGPT = null;
137
137
  }
138
- async getReply(content, uid, adminId = '', systemMessage = '', isFastGPT) {
138
+ async getReply(content, uid, adminId = '', systemMessage = '', isFastGPT, variables) {
139
139
  try {
140
140
  if (!this.chatGPT) {
141
141
  console.log(isFastGPT ? '看到此消息说明启用了FastGPT' : '看到此消息说明已启用ChatGPT');
@@ -165,6 +165,9 @@ class OfficialOpenAi {
165
165
  if (systemMessage) {
166
166
  sendParams.systemMessage = systemMessage;
167
167
  }
168
+ if (isFastGPT && variables) {
169
+ sendParams.variables = variables;
170
+ }
168
171
  const { conversationId, text, id } = await this.chatGPT.sendMessage(content, sendParams);
169
172
  if (this.config.filter) {
170
173
  const censor = await this.contentCensor.checkText(text);
@@ -148,7 +148,7 @@ let ChatGPTAPI = class {
148
148
  }
149
149
  }
150
150
  async sendMessage(text, opts = {}) {
151
- const { parentMessageId, messageId = (0, uuid_1.v4)(), timeoutMs, onProgress, stream = !!onProgress, completionParams, conversationId, chatId } = opts;
151
+ const { parentMessageId, messageId = (0, uuid_1.v4)(), timeoutMs, onProgress, stream = !!onProgress, completionParams, conversationId, chatId, variables } = opts;
152
152
  let { abortSignal } = opts;
153
153
  let abortController = null;
154
154
  if (timeoutMs && !abortSignal) {
@@ -187,6 +187,9 @@ let ChatGPTAPI = class {
187
187
  if (chatId) {
188
188
  body.chatId = chatId;
189
189
  }
190
+ if (variables) {
191
+ body.variables = variables;
192
+ }
190
193
  if (this._apiOrg) {
191
194
  headers["OpenAI-Organization"] = this._apiOrg;
192
195
  }
@@ -85,12 +85,13 @@ export class CompletionClient extends DifyClient {
85
85
  createCompletionMessage(inputs: any, user: any, stream?: boolean, files?: null): Promise<import("axios").AxiosResponse<any, any>>;
86
86
  }
87
87
  export class ChatClient extends DifyClient {
88
- sendMessage(query: any, { systemMessage, user, conversationId, timeoutMs, files }: {
88
+ sendMessage(query: any, { systemMessage, user, conversationId, timeoutMs, files, inputs }: {
89
89
  systemMessage: any;
90
90
  user: any;
91
91
  conversationId?: null | undefined;
92
92
  timeoutMs?: number | undefined;
93
93
  files?: null | undefined;
94
+ inputs: any;
94
95
  }): Promise<any>;
95
96
  getConversationMessages(user: any, conversationId?: string, firstId?: null, limit?: null): Promise<import("axios").AxiosResponse<any, any>>;
96
97
  getConversations(user: any, firstId?: null, limit?: null, pinned?: null): Promise<import("axios").AxiosResponse<any, any>>;
@@ -132,9 +132,11 @@ class CompletionClient extends DifyClient {
132
132
  }
133
133
  exports.CompletionClient = CompletionClient;
134
134
  class ChatClient extends DifyClient {
135
- async sendMessage(query, { systemMessage, user, conversationId = null, timeoutMs = 100 * 1000, files = null }) {
135
+ async sendMessage(query, { systemMessage, user, conversationId = null, timeoutMs = 100 * 1000, files = null, inputs }) {
136
136
  const data = {
137
- inputs: {},
137
+ inputs: {
138
+ ...inputs
139
+ },
138
140
  query,
139
141
  user,
140
142
  response_mode: this.stream ? 'streaming' : 'blocking',
@@ -104,9 +104,16 @@ async function dispatchFriendFilterByMsgType(that, msg) {
104
104
  break;
105
105
  case that.Message.Type.Audio:
106
106
  let finalConfig = await (0, msg_filters_js_1.getCustomConfig)({ name, id: contact.id, roomName: '', roomId: '', room: false, type: 'openWhisper' });
107
+ if (!finalConfig && config?.customBot?.openWhisper) {
108
+ finalConfig = {
109
+ botConfig: {
110
+ whisperConfig: config?.customBot?.whisperConfig
111
+ }
112
+ };
113
+ }
107
114
  if (finalConfig) {
108
115
  const audioFileBox = await msg.toFileBox();
109
- const text = await (0, multimodal_js_1.getVoiceText)(audioFileBox, finalConfig.botConfig.whisperConfig);
116
+ const text = msg.text().trim() ? msg.text().trim() : await (0, multimodal_js_1.getVoiceText)(audioFileBox, finalConfig.botConfig.whisperConfig);
110
117
  console.log('语音解析结果', text);
111
118
  const keyword = finalConfig.botConfig.whisperConfig?.keywords?.length ? finalConfig.botConfig?.whisperConfig.keywords?.find((item) => text.includes(item)) : true;
112
119
  const isIgnore = checkIgnore(content.trim(), aibotConfig.ignoreMessages);
@@ -165,9 +172,6 @@ async function dispatchFriendFilterByMsgType(that, msg) {
165
172
  case that.Message.Type.Video:
166
173
  console.log(`发消息人${await contact.name()}:发了一个视频`);
167
174
  break;
168
- case that.Message.Type.Audio:
169
- console.log(`发消息人${await contact.name()}:发了一个视频`);
170
- break;
171
175
  case that.Message.Type.MiniProgram:
172
176
  console.log(`发消息人${await contact.name()}:发了一个小程序`);
173
177
  const miniProgram = await msg.toMiniProgram();
@@ -314,9 +318,16 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
314
318
  case that.Message.Type.Audio:
315
319
  console.log(`群名: ${roomName} 发消息人: ${contactName} 发了一个语音`);
316
320
  let finalConfig = await (0, msg_filters_js_1.getCustomConfig)({ name: contactName, id: contactId, roomName, roomId: room.id, room, type: 'openWhisper' });
321
+ if (!finalConfig && config?.customBot?.openWhisper) {
322
+ finalConfig = {
323
+ botConfig: {
324
+ whisperConfig: config?.customBot?.whisperConfig
325
+ }
326
+ };
327
+ }
317
328
  if (finalConfig) {
318
329
  const audioFileBox = await msg.toFileBox();
319
- const text = await (0, multimodal_js_1.getVoiceText)(audioFileBox, finalConfig.botConfig.whisperConfig);
330
+ const text = msg.text().trim() ? msg.text().trim() : await (0, multimodal_js_1.getVoiceText)(audioFileBox, finalConfig.botConfig.whisperConfig);
320
331
  console.log('语音解析结果', text);
321
332
  const keyword = finalConfig.botConfig.whisperConfig?.keywords?.length ? finalConfig.botConfig?.whisperConfig?.keywords?.find((item) => text.includes(item)) : true;
322
333
  const isIgnore = checkIgnore(content.trim(), aibotConfig.ignoreMessages);
@@ -338,7 +349,7 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
338
349
  }
339
350
  return;
340
351
  }
341
- replys = await await (0, reply_js_1.getRoomTextReply)({
352
+ replys = await (0, reply_js_1.getRoomTextReply)({
342
353
  that,
343
354
  content: text,
344
355
  isFriend,
@@ -14,7 +14,8 @@ export namespace packageJson {
14
14
  clean: string;
15
15
  dist: string;
16
16
  "dist:commonjs": string;
17
- test: string;
17
+ "test:wechat": string;
18
+ "test:wework": string;
18
19
  release: string;
19
20
  "release:dry": string;
20
21
  };
@@ -41,6 +42,15 @@ export namespace packageJson {
41
42
  "eslint-plugin-prettier": string;
42
43
  "npm-run-all": string;
43
44
  prettier: string;
45
+ "@juzi/wechaty": string;
46
+ "@grpc/grpc-js": string;
47
+ "@juzi/wechaty-puppet": string;
48
+ "@juzi/wechaty-puppet-service": string;
49
+ wechaty: string;
50
+ "wechaty-puppet-service": string;
51
+ "wechaty-puppet-wechat4u": string;
52
+ "wechaty-puppet-padlocal": string;
53
+ "wechaty-puppet": string;
44
54
  };
45
55
  const readme: string;
46
56
  namespace engines {
@@ -6,7 +6,7 @@ exports.packageJson = void 0;
6
6
  */
7
7
  exports.packageJson = {
8
8
  "name": "wechaty-web-panel",
9
- "version": "1.6.56",
9
+ "version": "1.6.58",
10
10
  "description": "智能微秘书插件",
11
11
  "exports": {
12
12
  ".": {
@@ -20,7 +20,8 @@ exports.packageJson = {
20
20
  "clean": "shx rm -fr dist/*",
21
21
  "dist": "npm-run-all clean build dist:commonjs",
22
22
  "dist:commonjs": "jq -n \"{ type: \\\"commonjs\\\" }\" > dist/cjs/package.json",
23
- "test": "node test/index.js",
23
+ "test:wechat": "node test/wechat.js",
24
+ "test:wework": "node test/wework.js",
24
25
  "release": "verpub publish",
25
26
  "release:dry": "verpub --dry-run"
26
27
  },
@@ -61,7 +62,16 @@ exports.packageJson = {
61
62
  "eslint-config-prettier": "^6.11.0",
62
63
  "eslint-plugin-prettier": "^3.1.4",
63
64
  "npm-run-all": "^4.1.5",
64
- "prettier": "^2.0.5"
65
+ "prettier": "^2.0.5",
66
+ "@juzi/wechaty": "^1.0.87",
67
+ "@grpc/grpc-js": "1.9.14",
68
+ "@juzi/wechaty-puppet": "^1.0.78",
69
+ "@juzi/wechaty-puppet-service": "^1.0.87",
70
+ "wechaty": "^1.20.2",
71
+ "wechaty-puppet-service": "^1.18.2",
72
+ "wechaty-puppet-wechat4u": "^1.14.12",
73
+ "wechaty-puppet-padlocal": "^1.20.1",
74
+ "wechaty-puppet": "^1.21.1"
65
75
  },
66
76
  "readme": "README.md",
67
77
  "engines": {
@@ -1,6 +1,9 @@
1
1
  export function reset(adminId: any): void;
2
2
  export function resetAll(): void;
3
- export function getChatGPTReply(content: any, uid: any, adminId: any, config: {
3
+ export function getChatGPTReply({ content, variables }: {
4
+ content: any;
5
+ variables: any;
6
+ }, uid: any, adminId: any, config: {
4
7
  token: string;
5
8
  debug: boolean;
6
9
  proxyPass: string;
@@ -23,7 +23,7 @@ function resetAll() {
23
23
  chatGPT = {};
24
24
  }
25
25
  exports.resetAll = resetAll;
26
- async function getChatGPTReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", showQuestion: false, timeoutMs: 80, model: "", systemMessage: "", keywordSystemMessages: [] }, isFastGPT) {
26
+ async function getChatGPTReply({ content, variables }, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", showQuestion: false, timeoutMs: 80, model: "", systemMessage: "", keywordSystemMessages: [] }, isFastGPT) {
27
27
  if (!config.token) {
28
28
  console.log('请到智能微秘书平台配置Openai apikey参数方可使用');
29
29
  return [{ type: 1, content: '请到平台配置Openai apikey参数方可使用' }];
@@ -41,7 +41,7 @@ async function getChatGPTReply(content, uid, adminId, config = { token: "", debu
41
41
  content = content.replace(finalSystemMsg.keyword, '');
42
42
  }
43
43
  }
44
- return await chatGPT[adminId].getReply(content, uid, adminId, systemMessage, isFastGPT);
44
+ return await chatGPT[adminId].getReply(content, uid, adminId, systemMessage, isFastGPT, variables);
45
45
  }
46
46
  exports.getChatGPTReply = getChatGPTReply;
47
47
  //# sourceMappingURL=chatgpt.js.map
@@ -1,6 +1,9 @@
1
1
  export function reset(adminId: any): void;
2
2
  export function resetAll(): void;
3
- export function getDifyAiReply(content: any, uid: any, adminId: any, config?: {
3
+ export function getDifyAiReply({ content, inputs }: {
4
+ content: any;
5
+ inputs: any;
6
+ }, uid: any, adminId: any, config?: {
4
7
  token: string;
5
8
  debug: boolean;
6
9
  proxyPass: string;
@@ -23,7 +23,7 @@ function resetAll() {
23
23
  difyAi = {};
24
24
  }
25
25
  exports.resetAll = resetAll;
26
- async function getDifyAiReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", showQuestion: false, timeoutMs: 80, model: "", systemMessage: "", keywordSystemMessages: [], isAiAgent: false }) {
26
+ async function getDifyAiReply({ content, inputs }, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", showQuestion: false, timeoutMs: 80, model: "", systemMessage: "", keywordSystemMessages: [], isAiAgent: false }) {
27
27
  if (!config.token) {
28
28
  console.log('请到智能微秘书平台配置Dify的 api秘钥方可使用');
29
29
  return [{ type: 1, content: '请到智能微秘书平台配置Dify的 api秘钥方可使用' }];
@@ -41,7 +41,7 @@ async function getDifyAiReply(content, uid, adminId, config = { token: "", debug
41
41
  content = content.replace(finalSystemMsg.keyword, '');
42
42
  }
43
43
  }
44
- return await difyAi[adminId].getReply(content, uid, adminId, systemMessage);
44
+ return await difyAi[adminId].getReply({ content, inputs }, uid, adminId, systemMessage);
45
45
  }
46
46
  exports.getDifyAiReply = getDifyAiReply;
47
47
  //# sourceMappingURL=dify.js.map
@@ -3,5 +3,5 @@
3
3
  * @param {botType: 机器人类别, content: 消息内容, uid: 说话的用户id, updateId: 更新的用户id, adminId: 对话实例id,用于分割不同配置, config: 机器人配置}
4
4
  * @returns
5
5
  */
6
- export function dispatchBot({ botType, content, uid, adminId, config }: any): Promise<any>;
6
+ export function dispatchBot({ botType, content, id, uid, uname, roomId, roomName, adminId, config }: any): Promise<any>;
7
7
  //# sourceMappingURL=dispatch.d.ts.map
@@ -15,7 +15,7 @@ const global_js_1 = __importDefault(require("../../db/global.js"));
15
15
  * @param {botType: 机器人类别, content: 消息内容, uid: 说话的用户id, updateId: 更新的用户id, adminId: 对话实例id,用于分割不同配置, config: 机器人配置}
16
16
  * @returns
17
17
  */
18
- async function dispatchBot({ botType, content, uid, adminId, config }) {
18
+ async function dispatchBot({ botType, content, id, uid, uname, roomId, roomName, adminId, config }) {
19
19
  console.log('进入定制机器人回复');
20
20
  try {
21
21
  const gptConfig = global_js_1.default.getGptConfigById(adminId);
@@ -23,29 +23,29 @@ async function dispatchBot({ botType, content, uid, adminId, config }) {
23
23
  switch (botType) {
24
24
  case 6:
25
25
  // ChatGPT api
26
- res = await (0, chatgpt_js_1.getChatGPTReply)(content, uid, adminId, config, false);
26
+ res = await (0, chatgpt_js_1.getChatGPTReply)({ content }, id, adminId, config, false);
27
27
  replys = res;
28
28
  break;
29
29
  case 7:
30
30
  // ChatGPT web
31
31
  console.log('进入聊天');
32
- res = await (0, chatgpt_web_js_1.getChatGPTWebReply)(content, uid, adminId, config);
32
+ res = await (0, chatgpt_web_js_1.getChatGPTWebReply)(content, id, adminId, config);
33
33
  replys = res;
34
34
  break;
35
35
  case 8:
36
36
  // dify ai
37
37
  console.log('进入Dify聊天');
38
- res = await (0, dify_js_1.getDifyAiReply)(content, uid, adminId, config);
38
+ res = await (0, dify_js_1.getDifyAiReply)({ content, inputs: { uid, uname, roomId, roomName } }, id, adminId, config);
39
39
  replys = res;
40
40
  break;
41
41
  case 9:
42
42
  // fastGPT api
43
- res = await (0, chatgpt_js_1.getChatGPTReply)(content, uid, adminId, config, true);
43
+ res = await (0, chatgpt_js_1.getChatGPTReply)({ content, variables: { uid, uname, roomId, roomName } }, id, adminId, config, true);
44
44
  replys = res;
45
45
  break;
46
46
  case 11:
47
47
  // coze api
48
- res = await (0, coze_js_1.getCozeReply)(content, uid, adminId, config);
48
+ res = await (0, coze_js_1.getCozeReply)(content, id, adminId, config);
49
49
  replys = res;
50
50
  break;
51
51
  default:
@@ -2,10 +2,15 @@
2
2
  * 重置实例
3
3
  */
4
4
  export function reset(): void;
5
- export function getDifyReply(content: any, uid: any): Promise<any>;
6
- export function getDifySimpleReply({ content, uid, config }: {
5
+ export function getDifyReply({ content, id, inputs }: {
7
6
  content: any;
8
- uid: any;
7
+ id: any;
8
+ inputs: any;
9
+ }): Promise<any>;
10
+ export function getDifySimpleReply({ content, id, inputs, config }: {
11
+ content: any;
12
+ id: any;
13
+ inputs: any;
9
14
  config: any;
10
15
  }): Promise<{
11
16
  type: number;
@@ -17,7 +17,7 @@ function reset() {
17
17
  }
18
18
  }
19
19
  exports.reset = reset;
20
- async function getDifyReply(content, uid) {
20
+ async function getDifyReply({ content, id, inputs }) {
21
21
  const config = await (0, configDb_js_1.allConfig)();
22
22
  if (!config.dify_token) {
23
23
  console.log('请到智能微秘书平台配置difyAi apikey参数方可使用');
@@ -42,10 +42,10 @@ async function getDifyReply(content, uid) {
42
42
  if (!difyAi) {
43
43
  difyAi = new dify_js_1.default(chatConfig);
44
44
  }
45
- return await difyAi.getReply(content, uid);
45
+ return await difyAi.getReply({ content, inputs }, id);
46
46
  }
47
47
  exports.getDifyReply = getDifyReply;
48
- async function getDifySimpleReply({ content, uid, config }) {
48
+ async function getDifySimpleReply({ content, id, inputs, config }) {
49
49
  if (!config.token) {
50
50
  console.log('请到智能微秘书平台配置聊天总结API Token参数方可使用');
51
51
  return [{ type: 1, content: '请到平台配置API Token参数方可使用' }];
@@ -59,7 +59,7 @@ async function getDifySimpleReply({ content, uid, config }) {
59
59
  systemMessage: '',
60
60
  isAiAgent: true,
61
61
  };
62
- return await new dify_js_1.default(chatConfig).getReply(content, uid);
62
+ return await new dify_js_1.default(chatConfig).getReply({ content, inputs }, id);
63
63
  }
64
64
  exports.getDifySimpleReply = getDifySimpleReply;
65
65
  //# sourceMappingURL=difyAi.js.map
@@ -2,12 +2,13 @@
2
2
  * 重置实例
3
3
  */
4
4
  export function reset(): void;
5
- export function getGptOfficialReply(content: any, uid: any, isFastGPT: any): Promise<any>;
6
- export function getSimpleGptReply({ content, uid, config, isFastGPT }: {
5
+ export function getGptOfficialReply(content: any, uid: any, isFastGPT: any, variables: any): Promise<any>;
6
+ export function getSimpleGptReply({ content, uid, config, isFastGPT, variables }: {
7
7
  content: any;
8
8
  uid: any;
9
9
  config: any;
10
10
  isFastGPT: any;
11
+ variables: any;
11
12
  }): Promise<{
12
13
  type: number;
13
14
  content: any;
@@ -17,7 +17,7 @@ function reset() {
17
17
  }
18
18
  }
19
19
  exports.reset = reset;
20
- async function getGptOfficialReply(content, uid, isFastGPT) {
20
+ async function getGptOfficialReply(content, uid, isFastGPT, variables) {
21
21
  const config = await (0, configDb_js_1.allConfig)();
22
22
  if (!config.gpttoken) {
23
23
  console.log('请到智能微秘书平台配置Openai apikey参数方可使用');
@@ -46,10 +46,10 @@ async function getGptOfficialReply(content, uid, isFastGPT) {
46
46
  if (!chatGPT) {
47
47
  chatGPT = new officialOpenAi_js_1.default(chatConfig);
48
48
  }
49
- return await chatGPT.getReply(content, uid, '', '', isFastGPT);
49
+ return await chatGPT.getReply(content, uid, '', '', isFastGPT, variables);
50
50
  }
51
51
  exports.getGptOfficialReply = getGptOfficialReply;
52
- async function getSimpleGptReply({ content, uid, config, isFastGPT }) {
52
+ async function getSimpleGptReply({ content, uid, config, isFastGPT, variables }) {
53
53
  if (!config.token) {
54
54
  console.log('请到智能微秘书平台配置聊天总结的API Token参数方可使用');
55
55
  return [{ type: 1, content: '请到平台配置聊天总结的API Token参数方可使用' }];
@@ -64,7 +64,7 @@ async function getSimpleGptReply({ content, uid, config, isFastGPT }) {
64
64
  model: config.model,
65
65
  systemMessage: config.prompt, // 预设promotion
66
66
  };
67
- return await new officialOpenAi_js_1.default(chatConfig).getReply(content, uid, '', '', isFastGPT);
67
+ return await new officialOpenAi_js_1.default(chatConfig).getReply(content, uid, '', '', isFastGPT, variables);
68
68
  }
69
69
  exports.getSimpleGptReply = getSimpleGptReply;
70
70
  //# sourceMappingURL=openAi.js.map
@@ -21,10 +21,14 @@ export function dispatchEventContent(that: any, eName: string, msg: string, name
21
21
  * @param {*} name 发消息人
22
22
  * @param {*} id 发消息人id
23
23
  */
24
- export function dispatchAiBot(bot: any, msg: any, name: any, id: any): Promise<any>;
25
- export function dispatchSummerBot({ content, uid, config }: {
24
+ export function dispatchAiBot({ bot, msg, name, id, uid, uname, roomId, roomName }: any): Promise<any>;
25
+ export function dispatchSummerBot({ content, id, uid, uname, roomId, roomName, config }: {
26
26
  content: any;
27
+ id: any;
27
28
  uid: any;
29
+ uname: any;
30
+ roomId: any;
31
+ roomName: any;
28
32
  config: any;
29
33
  }): Promise<"" | {
30
34
  type: number;
@@ -147,13 +147,13 @@ exports.dispatchEventContent = dispatchEventContent;
147
147
  * @param {*} name 发消息人
148
148
  * @param {*} id 发消息人id
149
149
  */
150
- async function dispatchAiBot(bot, msg, name, id) {
150
+ async function dispatchAiBot({ bot, msg, name, id, uid, uname, roomId, roomName }) {
151
151
  try {
152
152
  let res, replys;
153
153
  switch (bot) {
154
154
  case 0:
155
155
  // 天行机器人
156
- res = await api.getResByTX(msg, id);
156
+ res = await (0, api_js_1.getResByTX)(msg, id);
157
157
  replys = [{ type: 1, content: res }];
158
158
  break;
159
159
  case 5:
@@ -173,12 +173,12 @@ async function dispatchAiBot(bot, msg, name, id) {
173
173
  break;
174
174
  case 8:
175
175
  // dify ai
176
- res = await (0, difyAi_js_1.getDifyReply)(msg, id);
176
+ res = await (0, difyAi_js_1.getDifyReply)({ content: msg, id, inputs: { uid, uname, roomId, roomName } });
177
177
  replys = res;
178
178
  break;
179
179
  case 9:
180
180
  // fast gpt
181
- res = await (0, openAi_js_1.getGptOfficialReply)(msg, id, true);
181
+ res = await (0, openAi_js_1.getGptOfficialReply)(msg, id, true, { uid, uname, roomId, roomName });
182
182
  replys = res;
183
183
  break;
184
184
  case 11:
@@ -198,28 +198,28 @@ async function dispatchAiBot(bot, msg, name, id) {
198
198
  }
199
199
  }
200
200
  exports.dispatchAiBot = dispatchAiBot;
201
- async function dispatchSummerBot({ content, uid, config }) {
201
+ async function dispatchSummerBot({ content, id, uid, uname, roomId, roomName, config }) {
202
202
  try {
203
203
  let res, replys;
204
204
  switch (config.botType) {
205
205
  case 6:
206
206
  // ChatGPT-api
207
- res = await (0, openAi_js_1.getSimpleGptReply)({ content, uid, config, isFastGPT: false });
207
+ res = await (0, openAi_js_1.getSimpleGptReply)({ content, uid: id, config, isFastGPT: false });
208
208
  replys = res;
209
209
  break;
210
210
  case 8:
211
211
  // dify ai
212
- res = await (0, difyAi_js_1.getDifySimpleReply)({ content, uid, config });
212
+ res = await (0, difyAi_js_1.getDifySimpleReply)({ content, id, inputs: { uid, uname, roomId, roomName }, config });
213
213
  replys = res;
214
214
  break;
215
215
  case 9:
216
216
  // fast gpt
217
- res = await (0, openAi_js_1.getSimpleGptReply)({ content, uid, config, isFastGPT: true });
217
+ res = await (0, openAi_js_1.getSimpleGptReply)({ content, uid: id, config, isFastGPT: true, variables: { uid, uname, roomId, roomName } });
218
218
  replys = res;
219
219
  break;
220
220
  case 11:
221
221
  // coze
222
- res = await (0, cozeAi_js_1.getCozeSimpleReply)({ content, uid, config, isFastGPT: true });
222
+ res = await (0, cozeAi_js_1.getCozeSimpleReply)({ content, uid: id, config, isFastGPT: true });
223
223
  replys = res;
224
224
  break;
225
225
  default:
@@ -126,12 +126,13 @@ export function keywordsMsg({ msg, config, room, isMention }: {
126
126
  room: any;
127
127
  isMention: any;
128
128
  }): Promise<any>;
129
- export function robotMsg({ msg, name, id, config, isMention, room, roomId, isFriend }: {
129
+ export function robotMsg({ msg, name, id, config, isMention, roomName, room, roomId, isFriend }: {
130
130
  msg: any;
131
131
  name: any;
132
132
  id: any;
133
133
  config: any;
134
134
  isMention: any;
135
+ roomName: any;
135
136
  room: any;
136
137
  roomId: any;
137
138
  isFriend: any;