wechaty-web-panel 1.6.64 → 1.6.65

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 (43) hide show
  1. package/dist/cjs/src/botInstance/coze.d.ts +1 -4
  2. package/dist/cjs/src/botInstance/coze.js +7 -0
  3. package/dist/cjs/src/botInstance/cozev3.d.ts +1 -4
  4. package/dist/cjs/src/botInstance/cozev3.js +7 -0
  5. package/dist/cjs/src/botInstance/dify.d.ts +1 -4
  6. package/dist/cjs/src/botInstance/dify.js +8 -0
  7. package/dist/cjs/src/botInstance/officialOpenAi.d.ts +1 -4
  8. package/dist/cjs/src/botInstance/officialOpenAi.js +7 -0
  9. package/dist/cjs/src/botInstance/qany.d.ts +1 -4
  10. package/dist/cjs/src/botInstance/qany.js +7 -0
  11. package/dist/cjs/src/handlers/on-scan.js +13 -0
  12. package/dist/cjs/src/package-json.js +1 -1
  13. package/dist/cjs/src/proxy/cozeAi.d.ts +1 -4
  14. package/dist/cjs/src/proxy/cozeV3Ai.d.ts +1 -4
  15. package/dist/cjs/src/proxy/difyAi.d.ts +1 -4
  16. package/dist/cjs/src/proxy/multimodal.d.ts +7 -0
  17. package/dist/cjs/src/proxy/multimodal.js +42 -3
  18. package/dist/cjs/src/proxy/openAi.d.ts +1 -4
  19. package/dist/cjs/src/proxy/qAnyAi.d.ts +1 -4
  20. package/dist/cjs/src/service/event-dispatch-service.d.ts +1 -4
  21. package/dist/cjs/src/service/msg-filters.d.ts +1 -4
  22. package/dist/esm/src/botInstance/coze.d.ts +1 -4
  23. package/dist/esm/src/botInstance/coze.js +7 -0
  24. package/dist/esm/src/botInstance/cozev3.d.ts +1 -4
  25. package/dist/esm/src/botInstance/cozev3.js +7 -0
  26. package/dist/esm/src/botInstance/dify.d.ts +1 -4
  27. package/dist/esm/src/botInstance/dify.js +8 -0
  28. package/dist/esm/src/botInstance/officialOpenAi.d.ts +1 -4
  29. package/dist/esm/src/botInstance/officialOpenAi.js +7 -0
  30. package/dist/esm/src/botInstance/qany.d.ts +1 -4
  31. package/dist/esm/src/botInstance/qany.js +7 -0
  32. package/dist/esm/src/handlers/on-scan.js +13 -0
  33. package/dist/esm/src/package-json.js +1 -1
  34. package/dist/esm/src/proxy/cozeAi.d.ts +1 -4
  35. package/dist/esm/src/proxy/cozeV3Ai.d.ts +1 -4
  36. package/dist/esm/src/proxy/difyAi.d.ts +1 -4
  37. package/dist/esm/src/proxy/multimodal.d.ts +7 -0
  38. package/dist/esm/src/proxy/multimodal.js +40 -2
  39. package/dist/esm/src/proxy/openAi.d.ts +1 -4
  40. package/dist/esm/src/proxy/qAnyAi.d.ts +1 -4
  41. package/dist/esm/src/service/event-dispatch-service.d.ts +1 -4
  42. package/dist/esm/src/service/msg-filters.d.ts +1 -4
  43. package/package.json +1 -1
@@ -54,10 +54,7 @@ declare class CozeAi {
54
54
  * @return {Promise<void>}
55
55
  */
56
56
  reset(): Promise<void>;
57
- getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<{
58
- type: number;
59
- content: any;
60
- }[]>;
57
+ getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<any>;
61
58
  }
62
59
  import { ContentCensor } from "../lib/contentCensor.js";
63
60
  //# sourceMappingURL=coze.d.ts.map
@@ -11,6 +11,7 @@ const puppet_type_js_1 = require("../const/puppet-type.js");
11
11
  const dayjs_1 = __importDefault(require("dayjs"));
12
12
  const index_js_1 = require("../lib/index.js");
13
13
  const node_fetch_1 = __importDefault(require("node-fetch"));
14
+ const multimodal_js_1 = require("../proxy/multimodal.js");
14
15
  class CozeAi {
15
16
  constructor(config = {
16
17
  token: '',
@@ -118,6 +119,12 @@ class CozeAi {
118
119
  parentMessageId: id
119
120
  };
120
121
  let replys = [];
122
+ if (this.config?.openTTS) {
123
+ replys = await (0, multimodal_js_1.getText2Speech)(text, this.config.ttsConfig);
124
+ if (replys.length) {
125
+ return replys;
126
+ }
127
+ }
121
128
  let message;
122
129
  if (this.config.showQuestion) {
123
130
  message = `${content}${this.eol}-----------${this.eol}` + (this.iswindows ? text.replaceAll('\n', this.eol) : text);
@@ -36,10 +36,7 @@ declare class CozeV3Ai {
36
36
  getReply({ content, inputs }: {
37
37
  content: any;
38
38
  inputs: any;
39
- }, id: any, adminId?: string, systemMessage?: string): Promise<{
40
- type: number;
41
- content: any;
42
- }[]>;
39
+ }, id: any, adminId?: string, systemMessage?: string): Promise<any>;
43
40
  }
44
41
  import { CozeV3Api } from "./sdk/cozev3.js";
45
42
  import { ContentCensor } from "../lib/contentCensor.js";
@@ -10,6 +10,7 @@ const contentCensor_js_1 = require("../lib/contentCensor.js");
10
10
  const puppet_type_js_1 = require("../const/puppet-type.js");
11
11
  const dayjs_1 = __importDefault(require("dayjs"));
12
12
  const index_js_1 = require("../lib/index.js");
13
+ const multimodal_js_1 = require("../proxy/multimodal.js");
13
14
  class CozeV3Ai {
14
15
  constructor(config = {
15
16
  botId: '',
@@ -99,6 +100,12 @@ class CozeV3Ai {
99
100
  };
100
101
  }
101
102
  let replys = [];
103
+ if (this.config?.openTTS) {
104
+ replys = await (0, multimodal_js_1.getText2Speech)(text, this.config.ttsConfig);
105
+ if (replys.length) {
106
+ return replys;
107
+ }
108
+ }
102
109
  let message;
103
110
  if (this.config.showQuestion) {
104
111
  message = `${content}${this.eol}-----------${this.eol}` + (this.iswindows ? text.replaceAll('\n', this.eol) : text);
@@ -34,10 +34,7 @@ declare class DifyAi {
34
34
  getReply({ content, inputs }: {
35
35
  content: any;
36
36
  inputs: any;
37
- }, id: any, adminId?: string, systemMessage?: string): Promise<{
38
- type: number;
39
- content: any;
40
- }[]>;
37
+ }, id: any, adminId?: string, systemMessage?: string): Promise<any>;
41
38
  }
42
39
  import { ChatClient } from "./sdk/difyClient.js";
43
40
  import { ContentCensor } from "../lib/contentCensor.js";
@@ -10,6 +10,7 @@ const contentCensor_js_1 = require("../lib/contentCensor.js");
10
10
  const puppet_type_js_1 = require("../const/puppet-type.js");
11
11
  const dayjs_1 = __importDefault(require("dayjs"));
12
12
  const index_js_1 = require("../lib/index.js");
13
+ const multimodal_js_1 = require("../proxy/multimodal.js");
13
14
  class DifyAi {
14
15
  constructor(config = {
15
16
  isAiAgent: false,
@@ -97,6 +98,13 @@ class DifyAi {
97
98
  };
98
99
  }
99
100
  let replys = [];
101
+ console.log('是否开启语音', this.config?.openTTS);
102
+ if (this.config?.openTTS) {
103
+ replys = await (0, multimodal_js_1.getText2Speech)(text, this.config.ttsConfig);
104
+ if (replys.length) {
105
+ return replys;
106
+ }
107
+ }
100
108
  let message;
101
109
  if (this.config.showQuestion) {
102
110
  message = `${content}${this.eol}-----------${this.eol}` + (this.iswindows ? text.replaceAll('\n', this.eol) : text);
@@ -66,10 +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, variables: any): Promise<{
70
- type: number;
71
- content: any;
72
- }[]>;
69
+ getReply(content: any, uid: any, adminId: string | undefined, systemMessage: string | undefined, isFastGPT: any, variables: any): Promise<any>;
73
70
  }
74
71
  import { ContentCensor } from "../lib/contentCensor.js";
75
72
  //# sourceMappingURL=officialOpenAi.d.ts.map
@@ -13,6 +13,7 @@ const puppet_type_js_1 = require("../const/puppet-type.js");
13
13
  const uuid_1 = require("uuid");
14
14
  const dayjs_1 = __importDefault(require("dayjs"));
15
15
  const index_js_1 = require("../lib/index.js");
16
+ const multimodal_js_1 = require("../proxy/multimodal.js");
16
17
  let chatGPT = null;
17
18
  class OfficialOpenAi {
18
19
  constructor(config = {
@@ -191,6 +192,12 @@ class OfficialOpenAi {
191
192
  };
192
193
  }
193
194
  let replys = [];
195
+ if (this.config?.openTTS) {
196
+ replys = await (0, multimodal_js_1.getText2Speech)(text, this.config.ttsConfig);
197
+ if (replys.length) {
198
+ return replys;
199
+ }
200
+ }
194
201
  let message;
195
202
  if (this.config.showQuestion) {
196
203
  message = `${content}${this.eol}-----------${this.eol}` + (this.iswindows ? text.replaceAll('\n', this.eol) : text);
@@ -31,10 +31,7 @@ declare class QAnyAi {
31
31
  * @return {Promise<void>}
32
32
  */
33
33
  reset(): Promise<void>;
34
- getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<{
35
- type: number;
36
- content: any;
37
- }[]>;
34
+ getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<any>;
38
35
  }
39
36
  import { QAnyApi } from "./sdk/qanything.js";
40
37
  import { ContentCensor } from "../lib/contentCensor.js";
@@ -9,6 +9,7 @@ const contentCensor_js_1 = require("../lib/contentCensor.js");
9
9
  const puppet_type_js_1 = require("../const/puppet-type.js");
10
10
  const dayjs_1 = __importDefault(require("dayjs"));
11
11
  const index_js_1 = require("../lib/index.js");
12
+ const multimodal_js_1 = require("../proxy/multimodal.js");
12
13
  class QAnyAi {
13
14
  constructor(config = {
14
15
  token: '',
@@ -99,6 +100,12 @@ class QAnyAi {
99
100
  needHistory: true
100
101
  };
101
102
  let replys = [];
103
+ if (this.config?.openTTS) {
104
+ replys = await (0, multimodal_js_1.getText2Speech)(text, this.config.ttsConfig);
105
+ if (replys.length) {
106
+ return replys;
107
+ }
108
+ }
102
109
  let message;
103
110
  if (this.config.showQuestion) {
104
111
  message = `${content}${this.eol}-----------${this.eol}` + (this.iswindows ? text.replaceAll('\n', this.eol) : text);
@@ -16,6 +16,15 @@ function resetScanTime() {
16
16
  scanTime = 0;
17
17
  }
18
18
  exports.resetScanTime = resetScanTime;
19
+ function extractLastPathWithCheck(url) {
20
+ const parts = url.split('/');
21
+ if (parts[parts.length - 2] === 'x') {
22
+ return parts[parts.length - 1];
23
+ }
24
+ else {
25
+ return null; // 或者可以返回一个错误消息
26
+ }
27
+ }
19
28
  function getQrcodeKey(qrcode) {
20
29
  if (!qrcode || !qrcode.startsWith('http'))
21
30
  return;
@@ -25,6 +34,10 @@ function getQrcodeKey(qrcode) {
25
34
  console.log('获取到二维码信息中的key');
26
35
  global_js_1.default.setQrKey(searchParams.get('key'));
27
36
  }
37
+ else if (extractLastPathWithCheck(qrcode)) {
38
+ console.log('获取到二维码信息中的key');
39
+ global_js_1.default.setQrKey(extractLastPathWithCheck(qrcode));
40
+ }
28
41
  else {
29
42
  global_js_1.default.setQrKey('');
30
43
  }
@@ -6,7 +6,7 @@ exports.packageJson = void 0;
6
6
  */
7
7
  exports.packageJson = {
8
8
  "name": "wechaty-web-panel",
9
- "version": "1.6.64",
9
+ "version": "1.6.65",
10
10
  "description": "智能微秘书插件",
11
11
  "exports": {
12
12
  ".": {
@@ -7,8 +7,5 @@ export function getCozeSimpleReply({ content, uid, config }: {
7
7
  content: any;
8
8
  uid: any;
9
9
  config: any;
10
- }): Promise<{
11
- type: number;
12
- content: any;
13
- }[]>;
10
+ }): Promise<any>;
14
11
  //# sourceMappingURL=cozeAi.d.ts.map
@@ -12,8 +12,5 @@ export function getCozeV3SimpleReply({ content, id, inputs, config }: {
12
12
  id: any;
13
13
  inputs: any;
14
14
  config: any;
15
- }): Promise<{
16
- type: number;
17
- content: any;
18
- }[]>;
15
+ }): Promise<any>;
19
16
  //# sourceMappingURL=cozeV3Ai.d.ts.map
@@ -12,8 +12,5 @@ export function getDifySimpleReply({ content, id, inputs, config }: {
12
12
  id: any;
13
13
  inputs: any;
14
14
  config: any;
15
- }): Promise<{
16
- type: number;
17
- content: any;
18
- }[]>;
15
+ }): Promise<any>;
19
16
  //# sourceMappingURL=difyAi.d.ts.map
@@ -5,6 +5,13 @@
5
5
  * @returns {Promise<*|string>}
6
6
  */
7
7
  export function getVoiceText(file: any, aiConfig: any): Promise<any | string>;
8
+ /**
9
+ * 文字转语音
10
+ * @param text
11
+ * @param aiConfig
12
+ * @returns {Promise<*|string>}
13
+ */
14
+ export function getText2Speech(text: any, aiConfig: any): Promise<any | string>;
8
15
  /**
9
16
  * 识别图像
10
17
  * @param images
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getImageVision = exports.getVoiceText = void 0;
6
+ exports.getImageVision = exports.getText2Speech = exports.getVoiceText = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const form_data_1 = __importDefault(require("form-data"));
9
9
  const config_js_1 = require("./config.js");
@@ -26,7 +26,7 @@ async function getVoiceText(file, aiConfig) {
26
26
  let config = {
27
27
  method: 'post',
28
28
  maxBodyLength: Infinity,
29
- timeout: 30000,
29
+ timeout: 60000,
30
30
  url: config_js_1.AIBOTK_OUTAPI + '/voice/text',
31
31
  headers: {
32
32
  ...formData.getHeaders(),
@@ -49,6 +49,45 @@ async function getVoiceText(file, aiConfig) {
49
49
  }
50
50
  }
51
51
  exports.getVoiceText = getVoiceText;
52
+ /**
53
+ * 文字转语音
54
+ * @param text
55
+ * @param aiConfig
56
+ * @returns {Promise<*|string>}
57
+ */
58
+ async function getText2Speech(text, aiConfig) {
59
+ try {
60
+ const env = await (0, aiDb_js_1.getAibotConfig)();
61
+ const { apiKey } = env;
62
+ let config = {
63
+ method: 'post',
64
+ maxBodyLength: Infinity,
65
+ timeout: 60000,
66
+ url: config_js_1.AIBOTK_OUTAPI + '/text/speech',
67
+ headers: {
68
+ 'Content-Type': 'application/json',
69
+ Authorization: `Bearer ${apiKey}`,
70
+ },
71
+ data: {
72
+ text,
73
+ aiConfig
74
+ }
75
+ };
76
+ const result = await axios_1.default.request(config);
77
+ if (result.data.code === 200) {
78
+ return result.data.data;
79
+ }
80
+ else {
81
+ console.log('语音生成出错', result.data.message);
82
+ return '';
83
+ }
84
+ }
85
+ catch (e) {
86
+ console.log(`语音生成出错: ${e}`);
87
+ return '';
88
+ }
89
+ }
90
+ exports.getText2Speech = getText2Speech;
52
91
  /**
53
92
  * 识别图像
54
93
  * @param images
@@ -63,7 +102,7 @@ async function getImageVision(images, question, config) {
63
102
  const reqConfig = {
64
103
  method: 'post',
65
104
  maxBodyLength: Infinity,
66
- timeout: 30000,
105
+ timeout: 60000,
67
106
  url: config_js_1.AIBOTK_OUTAPI + '/image/vision',
68
107
  headers: {
69
108
  Authorization: `Bearer ${apiKey}`,
@@ -9,8 +9,5 @@ export function getSimpleGptReply({ content, uid, config, isFastGPT, variables }
9
9
  config: any;
10
10
  isFastGPT: any;
11
11
  variables: any;
12
- }): Promise<{
13
- type: number;
14
- content: any;
15
- }[]>;
12
+ }): Promise<any>;
16
13
  //# sourceMappingURL=openAi.d.ts.map
@@ -7,8 +7,5 @@ export function getQAnySimpleReply({ content, uid, config }: {
7
7
  content: any;
8
8
  uid: any;
9
9
  config: any;
10
- }): Promise<{
11
- type: number;
12
- content: any;
13
- }[]>;
10
+ }): Promise<any>;
14
11
  //# sourceMappingURL=qAnyAi.d.ts.map
@@ -31,8 +31,5 @@ export function dispatchSummerBot({ content, id, uid, uname, roomId, roomName, u
31
31
  roomName: any;
32
32
  userAlias: any;
33
33
  config: any;
34
- }): Promise<"" | {
35
- type: number;
36
- content: any;
37
- }[]>;
34
+ }): Promise<any>;
38
35
  //# sourceMappingURL=event-dispatch-service.d.ts.map
@@ -23,10 +23,7 @@ export function summerChat({ that, msg, name, id, config, room, userAlias, isMen
23
23
  isMention: any;
24
24
  roomId: any;
25
25
  roomName: any;
26
- }): Promise<"" | {
27
- type: number;
28
- content: any;
29
- }[]>;
26
+ }): Promise<any>;
30
27
  declare namespace _default {
31
28
  export { getCustomConfig };
32
29
  export { summerChat };
@@ -54,10 +54,7 @@ declare class CozeAi {
54
54
  * @return {Promise<void>}
55
55
  */
56
56
  reset(): Promise<void>;
57
- getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<{
58
- type: number;
59
- content: any;
60
- }[]>;
57
+ getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<any>;
61
58
  }
62
59
  import { ContentCensor } from "../lib/contentCensor.js";
63
60
  //# sourceMappingURL=coze.d.ts.map
@@ -6,6 +6,7 @@ import { getPuppetEol, isWindowsPlatform } from '../const/puppet-type.js';
6
6
  import dayjs from 'dayjs';
7
7
  import { extractImageLinks } from '../lib/index.js';
8
8
  import nodeFetch from 'node-fetch';
9
+ import { getText2Speech } from "../proxy/multimodal.js";
9
10
  class CozeAi {
10
11
  constructor(config = {
11
12
  token: '',
@@ -113,6 +114,12 @@ class CozeAi {
113
114
  parentMessageId: id
114
115
  };
115
116
  let replys = [];
117
+ if (this.config?.openTTS) {
118
+ replys = await getText2Speech(text, this.config.ttsConfig);
119
+ if (replys.length) {
120
+ return replys;
121
+ }
122
+ }
116
123
  let message;
117
124
  if (this.config.showQuestion) {
118
125
  message = `${content}${this.eol}-----------${this.eol}` + (this.iswindows ? text.replaceAll('\n', this.eol) : text);
@@ -36,10 +36,7 @@ declare class CozeV3Ai {
36
36
  getReply({ content, inputs }: {
37
37
  content: any;
38
38
  inputs: any;
39
- }, id: any, adminId?: string, systemMessage?: string): Promise<{
40
- type: number;
41
- content: any;
42
- }[]>;
39
+ }, id: any, adminId?: string, systemMessage?: string): Promise<any>;
43
40
  }
44
41
  import { CozeV3Api } from "./sdk/cozev3.js";
45
42
  import { ContentCensor } from "../lib/contentCensor.js";
@@ -5,6 +5,7 @@ import { ContentCensor } from "../lib/contentCensor.js";
5
5
  import { getPuppetEol, isWindowsPlatform } from '../const/puppet-type.js';
6
6
  import dayjs from "dayjs";
7
7
  import { extractImageLinks } from '../lib/index.js';
8
+ import { getText2Speech } from "../proxy/multimodal.js";
8
9
  class CozeV3Ai {
9
10
  constructor(config = {
10
11
  botId: '',
@@ -94,6 +95,12 @@ class CozeV3Ai {
94
95
  };
95
96
  }
96
97
  let replys = [];
98
+ if (this.config?.openTTS) {
99
+ replys = await getText2Speech(text, this.config.ttsConfig);
100
+ if (replys.length) {
101
+ return replys;
102
+ }
103
+ }
97
104
  let message;
98
105
  if (this.config.showQuestion) {
99
106
  message = `${content}${this.eol}-----------${this.eol}` + (this.iswindows ? text.replaceAll('\n', this.eol) : text);
@@ -34,10 +34,7 @@ declare class DifyAi {
34
34
  getReply({ content, inputs }: {
35
35
  content: any;
36
36
  inputs: any;
37
- }, id: any, adminId?: string, systemMessage?: string): Promise<{
38
- type: number;
39
- content: any;
40
- }[]>;
37
+ }, id: any, adminId?: string, systemMessage?: string): Promise<any>;
41
38
  }
42
39
  import { ChatClient } from "./sdk/difyClient.js";
43
40
  import { ContentCensor } from "../lib/contentCensor.js";
@@ -5,6 +5,7 @@ import { ContentCensor } from "../lib/contentCensor.js";
5
5
  import { getPuppetEol, isWindowsPlatform } from '../const/puppet-type.js';
6
6
  import dayjs from "dayjs";
7
7
  import { extractImageLinks } from '../lib/index.js';
8
+ import { getText2Speech } from "../proxy/multimodal.js";
8
9
  class DifyAi {
9
10
  constructor(config = {
10
11
  isAiAgent: false,
@@ -92,6 +93,13 @@ class DifyAi {
92
93
  };
93
94
  }
94
95
  let replys = [];
96
+ console.log('是否开启语音', this.config?.openTTS);
97
+ if (this.config?.openTTS) {
98
+ replys = await getText2Speech(text, this.config.ttsConfig);
99
+ if (replys.length) {
100
+ return replys;
101
+ }
102
+ }
95
103
  let message;
96
104
  if (this.config.showQuestion) {
97
105
  message = `${content}${this.eol}-----------${this.eol}` + (this.iswindows ? text.replaceAll('\n', this.eol) : text);
@@ -66,10 +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, variables: any): Promise<{
70
- type: number;
71
- content: any;
72
- }[]>;
69
+ getReply(content: any, uid: any, adminId: string | undefined, systemMessage: string | undefined, isFastGPT: any, variables: any): Promise<any>;
73
70
  }
74
71
  import { ContentCensor } from "../lib/contentCensor.js";
75
72
  //# sourceMappingURL=officialOpenAi.d.ts.map
@@ -8,6 +8,7 @@ import { getPuppetEol, isWindowsPlatform } from '../const/puppet-type.js';
8
8
  import { v4 as uuidv4 } from "uuid";
9
9
  import dayjs from "dayjs";
10
10
  import { extractImageLinks } from '../lib/index.js';
11
+ import { getText2Speech } from "../proxy/multimodal.js";
11
12
  let chatGPT = null;
12
13
  class OfficialOpenAi {
13
14
  constructor(config = {
@@ -186,6 +187,12 @@ class OfficialOpenAi {
186
187
  };
187
188
  }
188
189
  let replys = [];
190
+ if (this.config?.openTTS) {
191
+ replys = await getText2Speech(text, this.config.ttsConfig);
192
+ if (replys.length) {
193
+ return replys;
194
+ }
195
+ }
189
196
  let message;
190
197
  if (this.config.showQuestion) {
191
198
  message = `${content}${this.eol}-----------${this.eol}` + (this.iswindows ? text.replaceAll('\n', this.eol) : text);
@@ -31,10 +31,7 @@ declare class QAnyAi {
31
31
  * @return {Promise<void>}
32
32
  */
33
33
  reset(): Promise<void>;
34
- getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<{
35
- type: number;
36
- content: any;
37
- }[]>;
34
+ getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<any>;
38
35
  }
39
36
  import { QAnyApi } from "./sdk/qanything.js";
40
37
  import { ContentCensor } from "../lib/contentCensor.js";
@@ -4,6 +4,7 @@ import { ContentCensor } from '../lib/contentCensor.js';
4
4
  import { getPuppetEol, isWindowsPlatform } from '../const/puppet-type.js';
5
5
  import dayjs from 'dayjs';
6
6
  import { extractImageLinks } from '../lib/index.js';
7
+ import { getText2Speech } from "../proxy/multimodal.js";
7
8
  class QAnyAi {
8
9
  constructor(config = {
9
10
  token: '',
@@ -94,6 +95,12 @@ class QAnyAi {
94
95
  needHistory: true
95
96
  };
96
97
  let replys = [];
98
+ if (this.config?.openTTS) {
99
+ replys = await getText2Speech(text, this.config.ttsConfig);
100
+ if (replys.length) {
101
+ return replys;
102
+ }
103
+ }
97
104
  let message;
98
105
  if (this.config.showQuestion) {
99
106
  message = `${content}${this.eol}-----------${this.eol}` + (this.iswindows ? text.replaceAll('\n', this.eol) : text);
@@ -9,6 +9,15 @@ let scanTime = 0;
9
9
  export function resetScanTime() {
10
10
  scanTime = 0;
11
11
  }
12
+ function extractLastPathWithCheck(url) {
13
+ const parts = url.split('/');
14
+ if (parts[parts.length - 2] === 'x') {
15
+ return parts[parts.length - 1];
16
+ }
17
+ else {
18
+ return null; // 或者可以返回一个错误消息
19
+ }
20
+ }
12
21
  function getQrcodeKey(qrcode) {
13
22
  if (!qrcode || !qrcode.startsWith('http'))
14
23
  return;
@@ -18,6 +27,10 @@ function getQrcodeKey(qrcode) {
18
27
  console.log('获取到二维码信息中的key');
19
28
  globalConfig.setQrKey(searchParams.get('key'));
20
29
  }
30
+ else if (extractLastPathWithCheck(qrcode)) {
31
+ console.log('获取到二维码信息中的key');
32
+ globalConfig.setQrKey(extractLastPathWithCheck(qrcode));
33
+ }
21
34
  else {
22
35
  globalConfig.setQrKey('');
23
36
  }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const packageJson = {
5
5
  "name": "wechaty-web-panel",
6
- "version": "1.6.64",
6
+ "version": "1.6.65",
7
7
  "description": "智能微秘书插件",
8
8
  "exports": {
9
9
  ".": {
@@ -7,8 +7,5 @@ export function getCozeSimpleReply({ content, uid, config }: {
7
7
  content: any;
8
8
  uid: any;
9
9
  config: any;
10
- }): Promise<{
11
- type: number;
12
- content: any;
13
- }[]>;
10
+ }): Promise<any>;
14
11
  //# sourceMappingURL=cozeAi.d.ts.map
@@ -12,8 +12,5 @@ export function getCozeV3SimpleReply({ content, id, inputs, config }: {
12
12
  id: any;
13
13
  inputs: any;
14
14
  config: any;
15
- }): Promise<{
16
- type: number;
17
- content: any;
18
- }[]>;
15
+ }): Promise<any>;
19
16
  //# sourceMappingURL=cozeV3Ai.d.ts.map
@@ -12,8 +12,5 @@ export function getDifySimpleReply({ content, id, inputs, config }: {
12
12
  id: any;
13
13
  inputs: any;
14
14
  config: any;
15
- }): Promise<{
16
- type: number;
17
- content: any;
18
- }[]>;
15
+ }): Promise<any>;
19
16
  //# sourceMappingURL=difyAi.d.ts.map
@@ -5,6 +5,13 @@
5
5
  * @returns {Promise<*|string>}
6
6
  */
7
7
  export function getVoiceText(file: any, aiConfig: any): Promise<any | string>;
8
+ /**
9
+ * 文字转语音
10
+ * @param text
11
+ * @param aiConfig
12
+ * @returns {Promise<*|string>}
13
+ */
14
+ export function getText2Speech(text: any, aiConfig: any): Promise<any | string>;
8
15
  /**
9
16
  * 识别图像
10
17
  * @param images
@@ -20,7 +20,7 @@ export async function getVoiceText(file, aiConfig) {
20
20
  let config = {
21
21
  method: 'post',
22
22
  maxBodyLength: Infinity,
23
- timeout: 30000,
23
+ timeout: 60000,
24
24
  url: AIBOTK_OUTAPI + '/voice/text',
25
25
  headers: {
26
26
  ...formData.getHeaders(),
@@ -42,6 +42,44 @@ export async function getVoiceText(file, aiConfig) {
42
42
  return '';
43
43
  }
44
44
  }
45
+ /**
46
+ * 文字转语音
47
+ * @param text
48
+ * @param aiConfig
49
+ * @returns {Promise<*|string>}
50
+ */
51
+ export async function getText2Speech(text, aiConfig) {
52
+ try {
53
+ const env = await getAibotConfig();
54
+ const { apiKey } = env;
55
+ let config = {
56
+ method: 'post',
57
+ maxBodyLength: Infinity,
58
+ timeout: 60000,
59
+ url: AIBOTK_OUTAPI + '/text/speech',
60
+ headers: {
61
+ 'Content-Type': 'application/json',
62
+ Authorization: `Bearer ${apiKey}`,
63
+ },
64
+ data: {
65
+ text,
66
+ aiConfig
67
+ }
68
+ };
69
+ const result = await axios.request(config);
70
+ if (result.data.code === 200) {
71
+ return result.data.data;
72
+ }
73
+ else {
74
+ console.log('语音生成出错', result.data.message);
75
+ return '';
76
+ }
77
+ }
78
+ catch (e) {
79
+ console.log(`语音生成出错: ${e}`);
80
+ return '';
81
+ }
82
+ }
45
83
  /**
46
84
  * 识别图像
47
85
  * @param images
@@ -56,7 +94,7 @@ export async function getImageVision(images, question, config) {
56
94
  const reqConfig = {
57
95
  method: 'post',
58
96
  maxBodyLength: Infinity,
59
- timeout: 30000,
97
+ timeout: 60000,
60
98
  url: AIBOTK_OUTAPI + '/image/vision',
61
99
  headers: {
62
100
  Authorization: `Bearer ${apiKey}`,
@@ -9,8 +9,5 @@ export function getSimpleGptReply({ content, uid, config, isFastGPT, variables }
9
9
  config: any;
10
10
  isFastGPT: any;
11
11
  variables: any;
12
- }): Promise<{
13
- type: number;
14
- content: any;
15
- }[]>;
12
+ }): Promise<any>;
16
13
  //# sourceMappingURL=openAi.d.ts.map
@@ -7,8 +7,5 @@ export function getQAnySimpleReply({ content, uid, config }: {
7
7
  content: any;
8
8
  uid: any;
9
9
  config: any;
10
- }): Promise<{
11
- type: number;
12
- content: any;
13
- }[]>;
10
+ }): Promise<any>;
14
11
  //# sourceMappingURL=qAnyAi.d.ts.map
@@ -31,8 +31,5 @@ export function dispatchSummerBot({ content, id, uid, uname, roomId, roomName, u
31
31
  roomName: any;
32
32
  userAlias: any;
33
33
  config: any;
34
- }): Promise<"" | {
35
- type: number;
36
- content: any;
37
- }[]>;
34
+ }): Promise<any>;
38
35
  //# sourceMappingURL=event-dispatch-service.d.ts.map
@@ -23,10 +23,7 @@ export function summerChat({ that, msg, name, id, config, room, userAlias, isMen
23
23
  isMention: any;
24
24
  roomId: any;
25
25
  roomName: any;
26
- }): Promise<"" | {
27
- type: number;
28
- content: any;
29
- }[]>;
26
+ }): Promise<any>;
30
27
  declare namespace _default {
31
28
  export { getCustomConfig };
32
29
  export { summerChat };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wechaty-web-panel",
3
- "version": "1.6.64",
3
+ "version": "1.6.65",
4
4
  "description": "智能微秘书插件",
5
5
  "exports": {
6
6
  ".": {