wechaty-web-panel 1.2.7 → 1.2.8
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.
- package/CHANGELOG.md +4 -0
- package/dist/cjs/src/package-json.d.ts +2 -0
- package/dist/cjs/src/package-json.js +3 -1
- package/dist/cjs/src/proxy/chatgpt.d.ts +9 -0
- package/dist/cjs/src/proxy/chatgpt.js +36 -0
- package/dist/cjs/src/service/event-dispatch-service.d.ts +1 -1
- package/dist/cjs/src/service/event-dispatch-service.js +6 -0
- package/dist/esm/src/package-json.d.ts +2 -0
- package/dist/esm/src/package-json.js +3 -1
- package/dist/esm/src/proxy/chatgpt.d.ts +9 -0
- package/dist/esm/src/proxy/chatgpt.js +30 -0
- package/dist/esm/src/service/event-dispatch-service.d.ts +1 -1
- package/dist/esm/src/service/event-dispatch-service.js +6 -0
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -51,12 +51,14 @@ export namespace packageJson {
|
|
|
51
51
|
}
|
|
52
52
|
const dependencies: {
|
|
53
53
|
axios: string;
|
|
54
|
+
chatgpt: string;
|
|
54
55
|
ix: string;
|
|
55
56
|
jsonwebtoken: string;
|
|
56
57
|
mqtt: string;
|
|
57
58
|
mustache: string;
|
|
58
59
|
nedb: string;
|
|
59
60
|
"node-schedule": string;
|
|
61
|
+
"p-timeout": string;
|
|
60
62
|
puppeteer: string;
|
|
61
63
|
"qrcode-terminal": string;
|
|
62
64
|
superagent: string;
|
|
@@ -6,7 +6,7 @@ exports.packageJson = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
exports.packageJson = {
|
|
8
8
|
"name": "wechaty-web-panel",
|
|
9
|
-
"version": "1.2.
|
|
9
|
+
"version": "1.2.8",
|
|
10
10
|
"description": "",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -65,12 +65,14 @@ exports.packageJson = {
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"axios": "^0.27.2",
|
|
68
|
+
"chatgpt": "^1.4.0",
|
|
68
69
|
"ix": "^4.5.2",
|
|
69
70
|
"jsonwebtoken": "^8.5.1",
|
|
70
71
|
"mqtt": "^4.2.6",
|
|
71
72
|
"mustache": "^4.2.0",
|
|
72
73
|
"nedb": "^1.8.0",
|
|
73
74
|
"node-schedule": "^1.3.2",
|
|
75
|
+
"p-timeout": "^6.0.0",
|
|
74
76
|
"puppeteer": "^13.3.2",
|
|
75
77
|
"qrcode-terminal": "^0.12.0",
|
|
76
78
|
"superagent": "^5.2.2"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.geGPTReply = void 0;
|
|
7
|
+
const chatgpt_1 = require("chatgpt");
|
|
8
|
+
const p_timeout_1 = __importDefault(require("p-timeout"));
|
|
9
|
+
const configDb_js_1 = require("../db/configDb.js");
|
|
10
|
+
async function geGPTReply(content) {
|
|
11
|
+
const config = await (0, configDb_js_1.allConfig)();
|
|
12
|
+
if (!config.gpttoken) {
|
|
13
|
+
console.log('请到智能微秘书平台配置ChatGPT token参数方可使用');
|
|
14
|
+
return [{ type: 1, content: '请到平台配置ChatGPT token参数方可使用' }];
|
|
15
|
+
}
|
|
16
|
+
const api = new chatgpt_1.ChatGPTAPI({ sessionToken: config.gpttoken });
|
|
17
|
+
await api.ensureAuth();
|
|
18
|
+
const threeMinutesMs = 2 * 60 * 1000;
|
|
19
|
+
const response = await (0, p_timeout_1.default)(api.sendMessage(content), {
|
|
20
|
+
milliseconds: threeMinutesMs,
|
|
21
|
+
message: 'ChatGPT返回超时了,用的人太多,太火爆了,等会再试吧'
|
|
22
|
+
});
|
|
23
|
+
let replys = response.match(/.{1,680}/g);
|
|
24
|
+
replys = replys.map(item => {
|
|
25
|
+
return {
|
|
26
|
+
type: 1,
|
|
27
|
+
content: item
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
return replys;
|
|
31
|
+
}
|
|
32
|
+
exports.geGPTReply = geGPTReply;
|
|
33
|
+
exports.default = {
|
|
34
|
+
geGPTReply,
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=chatgpt.js.map
|
|
@@ -20,5 +20,5 @@ export function dispatchEventContent(that: any, eName: string, msg: string, name
|
|
|
20
20
|
* @param {*} name 发消息人
|
|
21
21
|
* @param {*} id 发消息人id
|
|
22
22
|
*/
|
|
23
|
-
export function dispatchAiBot(bot: any, msg: any, name: any, id: any): Promise<any[] | "" | undefined>;
|
|
23
|
+
export function dispatchAiBot(bot: any, msg: any, name: any, id: any): Promise<any[] | "" | null | undefined>;
|
|
24
24
|
//# sourceMappingURL=event-dispatch-service.d.ts.map
|
|
@@ -12,6 +12,7 @@ const index_js_2 = require("../task/index.js");
|
|
|
12
12
|
const index_js_3 = require("../common/index.js");
|
|
13
13
|
const tencent_open_js_1 = require("../proxy/tencent-open.js");
|
|
14
14
|
const roomDb_js_1 = require("../db/roomDb.js");
|
|
15
|
+
const chatgpt_js_1 = require("../proxy/chatgpt.js");
|
|
15
16
|
/**
|
|
16
17
|
* 根据事件名称分配不同的api处理,并获取返回内容
|
|
17
18
|
* @param {string} eName 事件名称
|
|
@@ -223,6 +224,11 @@ async function dispatchAiBot(bot, msg, name, id) {
|
|
|
223
224
|
res = await (0, tencent_open_js_1.getTencentOpenReply)({ msg, id, userInfo: { name } });
|
|
224
225
|
replys = res;
|
|
225
226
|
break;
|
|
227
|
+
case 6:
|
|
228
|
+
// ChatGPT
|
|
229
|
+
res = await (0, chatgpt_js_1.geGPTReply)(msg);
|
|
230
|
+
replys = res;
|
|
231
|
+
break;
|
|
226
232
|
default:
|
|
227
233
|
replys = [{ type: 1, content: '' }];
|
|
228
234
|
break;
|
|
@@ -51,12 +51,14 @@ export namespace packageJson {
|
|
|
51
51
|
}
|
|
52
52
|
const dependencies: {
|
|
53
53
|
axios: string;
|
|
54
|
+
chatgpt: string;
|
|
54
55
|
ix: string;
|
|
55
56
|
jsonwebtoken: string;
|
|
56
57
|
mqtt: string;
|
|
57
58
|
mustache: string;
|
|
58
59
|
nedb: string;
|
|
59
60
|
"node-schedule": string;
|
|
61
|
+
"p-timeout": string;
|
|
60
62
|
puppeteer: string;
|
|
61
63
|
"qrcode-terminal": string;
|
|
62
64
|
superagent: string;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const packageJson = {
|
|
5
5
|
"name": "wechaty-web-panel",
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.8",
|
|
7
7
|
"description": "",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
@@ -62,12 +62,14 @@ export const packageJson = {
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"axios": "^0.27.2",
|
|
65
|
+
"chatgpt": "^1.4.0",
|
|
65
66
|
"ix": "^4.5.2",
|
|
66
67
|
"jsonwebtoken": "^8.5.1",
|
|
67
68
|
"mqtt": "^4.2.6",
|
|
68
69
|
"mustache": "^4.2.0",
|
|
69
70
|
"nedb": "^1.8.0",
|
|
70
71
|
"node-schedule": "^1.3.2",
|
|
72
|
+
"p-timeout": "^6.0.0",
|
|
71
73
|
"puppeteer": "^13.3.2",
|
|
72
74
|
"qrcode-terminal": "^0.12.0",
|
|
73
75
|
"superagent": "^5.2.2"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ChatGPTAPI } from 'chatgpt';
|
|
2
|
+
import pTimeout from 'p-timeout';
|
|
3
|
+
import { allConfig } from "../db/configDb.js";
|
|
4
|
+
async function geGPTReply(content) {
|
|
5
|
+
const config = await allConfig();
|
|
6
|
+
if (!config.gpttoken) {
|
|
7
|
+
console.log('请到智能微秘书平台配置ChatGPT token参数方可使用');
|
|
8
|
+
return [{ type: 1, content: '请到平台配置ChatGPT token参数方可使用' }];
|
|
9
|
+
}
|
|
10
|
+
const api = new ChatGPTAPI({ sessionToken: config.gpttoken });
|
|
11
|
+
await api.ensureAuth();
|
|
12
|
+
const threeMinutesMs = 2 * 60 * 1000;
|
|
13
|
+
const response = await pTimeout(api.sendMessage(content), {
|
|
14
|
+
milliseconds: threeMinutesMs,
|
|
15
|
+
message: 'ChatGPT返回超时了,用的人太多,太火爆了,等会再试吧'
|
|
16
|
+
});
|
|
17
|
+
let replys = response.match(/.{1,680}/g);
|
|
18
|
+
replys = replys.map(item => {
|
|
19
|
+
return {
|
|
20
|
+
type: 1,
|
|
21
|
+
content: item
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return replys;
|
|
25
|
+
}
|
|
26
|
+
export { geGPTReply };
|
|
27
|
+
export default {
|
|
28
|
+
geGPTReply,
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=chatgpt.js.map
|
|
@@ -20,5 +20,5 @@ export function dispatchEventContent(that: any, eName: string, msg: string, name
|
|
|
20
20
|
* @param {*} name 发消息人
|
|
21
21
|
* @param {*} id 发消息人id
|
|
22
22
|
*/
|
|
23
|
-
export function dispatchAiBot(bot: any, msg: any, name: any, id: any): Promise<any[] | "" | undefined>;
|
|
23
|
+
export function dispatchAiBot(bot: any, msg: any, name: any, id: any): Promise<any[] | "" | null | undefined>;
|
|
24
24
|
//# sourceMappingURL=event-dispatch-service.d.ts.map
|
|
@@ -6,6 +6,7 @@ import { initTaskLocalSchedule, initTimeSchedule } from "../task/index.js";
|
|
|
6
6
|
import { updateContactAndRoom, updateContactOnly, updateRoomOnly } from '../common/index.js';
|
|
7
7
|
import { getTencentOpenReply } from '../proxy/tencent-open.js';
|
|
8
8
|
import { getRoomRecordContent, removeRecord } from "../db/roomDb.js";
|
|
9
|
+
import { geGPTReply } from '../proxy/chatgpt.js';
|
|
9
10
|
/**
|
|
10
11
|
* 根据事件名称分配不同的api处理,并获取返回内容
|
|
11
12
|
* @param {string} eName 事件名称
|
|
@@ -216,6 +217,11 @@ async function dispatchAiBot(bot, msg, name, id) {
|
|
|
216
217
|
res = await getTencentOpenReply({ msg, id, userInfo: { name } });
|
|
217
218
|
replys = res;
|
|
218
219
|
break;
|
|
220
|
+
case 6:
|
|
221
|
+
// ChatGPT
|
|
222
|
+
res = await geGPTReply(msg);
|
|
223
|
+
replys = res;
|
|
224
|
+
break;
|
|
219
225
|
default:
|
|
220
226
|
replys = [{ type: 1, content: '' }];
|
|
221
227
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wechaty-web-panel",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -59,12 +59,14 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"axios": "^0.27.2",
|
|
62
|
+
"chatgpt": "^1.4.0",
|
|
62
63
|
"ix": "^4.5.2",
|
|
63
64
|
"jsonwebtoken": "^8.5.1",
|
|
64
65
|
"mqtt": "^4.2.6",
|
|
65
66
|
"mustache": "^4.2.0",
|
|
66
67
|
"nedb": "^1.8.0",
|
|
67
68
|
"node-schedule": "^1.3.2",
|
|
69
|
+
"p-timeout": "^6.0.0",
|
|
68
70
|
"puppeteer": "^13.3.2",
|
|
69
71
|
"qrcode-terminal": "^0.12.0",
|
|
70
72
|
"superagent": "^5.2.2"
|