wechaty-web-panel 1.4.15 → 1.4.16
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 +1 -1
- package/dist/cjs/src/package-json.d.ts +0 -3
- package/dist/cjs/src/package-json.js +2 -5
- package/dist/cjs/src/service/event-dispatch-service.js +0 -4
- package/dist/esm/src/package-json.d.ts +0 -3
- package/dist/esm/src/package-json.js +2 -5
- package/dist/esm/src/service/event-dispatch-service.js +1 -5
- package/package.json +2 -5
- package/dist/cjs/src/proxy/chatgpt.d.ts +0 -10
- package/dist/cjs/src/proxy/chatgpt.js +0 -71
- package/dist/esm/src/proxy/chatgpt.d.ts +0 -10
- package/dist/esm/src/proxy/chatgpt.js +0 -64
package/CHANGELOG.md
CHANGED
|
@@ -61,11 +61,8 @@ export namespace packageJson {
|
|
|
61
61
|
nedb: string;
|
|
62
62
|
"node-fetch": string;
|
|
63
63
|
"node-schedule": string;
|
|
64
|
-
openai: string;
|
|
65
64
|
puppeteer: string;
|
|
66
65
|
"qrcode-terminal": string;
|
|
67
|
-
remark: string;
|
|
68
|
-
"strip-markdown": string;
|
|
69
66
|
superagent: string;
|
|
70
67
|
};
|
|
71
68
|
namespace publishConfig {
|
|
@@ -6,7 +6,7 @@ exports.packageJson = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
exports.packageJson = {
|
|
8
8
|
"name": "wechaty-web-panel",
|
|
9
|
-
"version": "1.4.
|
|
9
|
+
"version": "1.4.16",
|
|
10
10
|
"description": "智能微秘书插件",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -68,7 +68,7 @@ exports.packageJson = {
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"axios": "^0.27.2",
|
|
71
|
-
"chatgpt": "^5.
|
|
71
|
+
"chatgpt": "^5.1.1",
|
|
72
72
|
"dayjs": "^1.11.7",
|
|
73
73
|
"https-proxy-agent": "^5.0.1",
|
|
74
74
|
"isomorphic-fetch": "^3.0.0",
|
|
@@ -79,11 +79,8 @@ exports.packageJson = {
|
|
|
79
79
|
"nedb": "^1.8.0",
|
|
80
80
|
"node-fetch": "^2.6.9",
|
|
81
81
|
"node-schedule": "^1.3.2",
|
|
82
|
-
"openai": "^3.1.0",
|
|
83
82
|
"puppeteer": "^13.3.2",
|
|
84
83
|
"qrcode-terminal": "^0.12.0",
|
|
85
|
-
"remark": "^13.0.0",
|
|
86
|
-
"strip-markdown": "^4.2.0",
|
|
87
84
|
"superagent": "^5.2.2"
|
|
88
85
|
},
|
|
89
86
|
"publishConfig": {
|
|
@@ -230,10 +230,6 @@ async function dispatchAiBot(bot, msg, name, id) {
|
|
|
230
230
|
case 6:
|
|
231
231
|
// ChatGPT3
|
|
232
232
|
res = await (0, openAi_js_1.geGPT3Reply)(msg, id);
|
|
233
|
-
if (res.length === 1 && !res[0].content) {
|
|
234
|
-
console.log('第一个gpt接口返回失败,开始请求第二个gpt接口');
|
|
235
|
-
res = await (0, chatgpt_js_1.geGPTReply)(msg, id);
|
|
236
|
-
}
|
|
237
233
|
replys = res;
|
|
238
234
|
break;
|
|
239
235
|
default:
|
|
@@ -61,11 +61,8 @@ export namespace packageJson {
|
|
|
61
61
|
nedb: string;
|
|
62
62
|
"node-fetch": string;
|
|
63
63
|
"node-schedule": string;
|
|
64
|
-
openai: string;
|
|
65
64
|
puppeteer: string;
|
|
66
65
|
"qrcode-terminal": string;
|
|
67
|
-
remark: string;
|
|
68
|
-
"strip-markdown": string;
|
|
69
66
|
superagent: string;
|
|
70
67
|
};
|
|
71
68
|
namespace publishConfig {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const packageJson = {
|
|
5
5
|
"name": "wechaty-web-panel",
|
|
6
|
-
"version": "1.4.
|
|
6
|
+
"version": "1.4.16",
|
|
7
7
|
"description": "智能微秘书插件",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
@@ -65,7 +65,7 @@ export const packageJson = {
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"axios": "^0.27.2",
|
|
68
|
-
"chatgpt": "^5.
|
|
68
|
+
"chatgpt": "^5.1.1",
|
|
69
69
|
"dayjs": "^1.11.7",
|
|
70
70
|
"https-proxy-agent": "^5.0.1",
|
|
71
71
|
"isomorphic-fetch": "^3.0.0",
|
|
@@ -76,11 +76,8 @@ export const packageJson = {
|
|
|
76
76
|
"nedb": "^1.8.0",
|
|
77
77
|
"node-fetch": "^2.6.9",
|
|
78
78
|
"node-schedule": "^1.3.2",
|
|
79
|
-
"openai": "^3.1.0",
|
|
80
79
|
"puppeteer": "^13.3.2",
|
|
81
80
|
"qrcode-terminal": "^0.12.0",
|
|
82
|
-
"remark": "^13.0.0",
|
|
83
|
-
"strip-markdown": "^4.2.0",
|
|
84
81
|
"superagent": "^5.2.2"
|
|
85
82
|
},
|
|
86
83
|
"publishConfig": {
|
|
@@ -6,7 +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 {
|
|
9
|
+
import { initOpenApi } from '../proxy/chatgpt.js';
|
|
10
10
|
import { geGPT3Reply, initGpt } from '../proxy/openAi.js';
|
|
11
11
|
/**
|
|
12
12
|
* 根据事件名称分配不同的api处理,并获取返回内容
|
|
@@ -223,10 +223,6 @@ async function dispatchAiBot(bot, msg, name, id) {
|
|
|
223
223
|
case 6:
|
|
224
224
|
// ChatGPT3
|
|
225
225
|
res = await geGPT3Reply(msg, id);
|
|
226
|
-
if (res.length === 1 && !res[0].content) {
|
|
227
|
-
console.log('第一个gpt接口返回失败,开始请求第二个gpt接口');
|
|
228
|
-
res = await geGPTReply(msg, id);
|
|
229
|
-
}
|
|
230
226
|
replys = res;
|
|
231
227
|
break;
|
|
232
228
|
default:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wechaty-web-panel",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.16",
|
|
4
4
|
"description": "智能微秘书插件",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"axios": "^0.27.2",
|
|
65
|
-
"chatgpt": "^5.
|
|
65
|
+
"chatgpt": "^5.1.1",
|
|
66
66
|
"dayjs": "^1.11.7",
|
|
67
67
|
"https-proxy-agent": "^5.0.1",
|
|
68
68
|
"isomorphic-fetch": "^3.0.0",
|
|
@@ -73,11 +73,8 @@
|
|
|
73
73
|
"nedb": "^1.8.0",
|
|
74
74
|
"node-fetch": "^2.6.9",
|
|
75
75
|
"node-schedule": "^1.3.2",
|
|
76
|
-
"openai": "^3.1.0",
|
|
77
76
|
"puppeteer": "^13.3.2",
|
|
78
77
|
"qrcode-terminal": "^0.12.0",
|
|
79
|
-
"remark": "^13.0.0",
|
|
80
|
-
"strip-markdown": "^4.2.0",
|
|
81
78
|
"superagent": "^5.2.2"
|
|
82
79
|
},
|
|
83
80
|
"publishConfig": {
|
|
@@ -1,71 +0,0 @@
|
|
|
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 = exports.initOpenApi = void 0;
|
|
7
|
-
const remark_1 = __importDefault(require("remark"));
|
|
8
|
-
const strip_markdown_1 = __importDefault(require("strip-markdown"));
|
|
9
|
-
const openai_1 = require("openai");
|
|
10
|
-
const configDb_js_1 = require("../db/configDb.js");
|
|
11
|
-
let openai = null;
|
|
12
|
-
function markdownToText(markdown) {
|
|
13
|
-
return (0, remark_1.default)()
|
|
14
|
-
.use(strip_markdown_1.default)
|
|
15
|
-
.processSync(markdown || '')
|
|
16
|
-
.toString();
|
|
17
|
-
}
|
|
18
|
-
function initOpenApi() {
|
|
19
|
-
openai = null;
|
|
20
|
-
}
|
|
21
|
-
exports.initOpenApi = initOpenApi;
|
|
22
|
-
async function geGPTReply(content) {
|
|
23
|
-
try {
|
|
24
|
-
const config = await (0, configDb_js_1.allConfig)();
|
|
25
|
-
if (!config.gpttoken) {
|
|
26
|
-
console.log('请到智能微秘书平台配置Openai apikey参数方可使用');
|
|
27
|
-
return [{ type: 1, content: '请到平台配置Openai apikey参数方可使用' }];
|
|
28
|
-
}
|
|
29
|
-
if (!openai) {
|
|
30
|
-
let configuration = new openai_1.Configuration({
|
|
31
|
-
apiKey: config.gpttoken,
|
|
32
|
-
});
|
|
33
|
-
openai = new openai_1.OpenAIApi(configuration);
|
|
34
|
-
}
|
|
35
|
-
let response = await openai.createCompletion({
|
|
36
|
-
model: 'text-davinci-003',
|
|
37
|
-
prompt: content,
|
|
38
|
-
temperature: 0.9,
|
|
39
|
-
max_tokens: 2000,
|
|
40
|
-
top_p: 1,
|
|
41
|
-
frequency_penalty: 0.0,
|
|
42
|
-
presence_penalty: 0.6,
|
|
43
|
-
stop: ['Human:', 'AI:'],
|
|
44
|
-
});
|
|
45
|
-
console.log('chat gpt返回原始数据:' + response.data.choices[0].text);
|
|
46
|
-
response = markdownToText(response.data.choices[0].text);
|
|
47
|
-
let replys = [];
|
|
48
|
-
let message = response;
|
|
49
|
-
while (message.length > 500) {
|
|
50
|
-
replys.push(message.slice(0, 500));
|
|
51
|
-
message = message.slice(500);
|
|
52
|
-
}
|
|
53
|
-
replys.push(message);
|
|
54
|
-
replys = replys.map(item => {
|
|
55
|
-
return {
|
|
56
|
-
type: 1,
|
|
57
|
-
content: item.trim()
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
return replys;
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
console.log('chat gpt报错:' + e);
|
|
64
|
-
return [{ type: 1, content: '' }];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.geGPTReply = geGPTReply;
|
|
68
|
-
exports.default = {
|
|
69
|
-
geGPTReply,
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=chatgpt.js.map
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import remark from 'remark';
|
|
2
|
-
import stripMarkdown from 'strip-markdown';
|
|
3
|
-
import { Configuration, OpenAIApi } from 'openai';
|
|
4
|
-
import { allConfig } from "../db/configDb.js";
|
|
5
|
-
let openai = null;
|
|
6
|
-
function markdownToText(markdown) {
|
|
7
|
-
return remark()
|
|
8
|
-
.use(stripMarkdown)
|
|
9
|
-
.processSync(markdown || '')
|
|
10
|
-
.toString();
|
|
11
|
-
}
|
|
12
|
-
export function initOpenApi() {
|
|
13
|
-
openai = null;
|
|
14
|
-
}
|
|
15
|
-
async function geGPTReply(content) {
|
|
16
|
-
try {
|
|
17
|
-
const config = await allConfig();
|
|
18
|
-
if (!config.gpttoken) {
|
|
19
|
-
console.log('请到智能微秘书平台配置Openai apikey参数方可使用');
|
|
20
|
-
return [{ type: 1, content: '请到平台配置Openai apikey参数方可使用' }];
|
|
21
|
-
}
|
|
22
|
-
if (!openai) {
|
|
23
|
-
let configuration = new Configuration({
|
|
24
|
-
apiKey: config.gpttoken,
|
|
25
|
-
});
|
|
26
|
-
openai = new OpenAIApi(configuration);
|
|
27
|
-
}
|
|
28
|
-
let response = await openai.createCompletion({
|
|
29
|
-
model: 'text-davinci-003',
|
|
30
|
-
prompt: content,
|
|
31
|
-
temperature: 0.9,
|
|
32
|
-
max_tokens: 2000,
|
|
33
|
-
top_p: 1,
|
|
34
|
-
frequency_penalty: 0.0,
|
|
35
|
-
presence_penalty: 0.6,
|
|
36
|
-
stop: ['Human:', 'AI:'],
|
|
37
|
-
});
|
|
38
|
-
console.log('chat gpt返回原始数据:' + response.data.choices[0].text);
|
|
39
|
-
response = markdownToText(response.data.choices[0].text);
|
|
40
|
-
let replys = [];
|
|
41
|
-
let message = response;
|
|
42
|
-
while (message.length > 500) {
|
|
43
|
-
replys.push(message.slice(0, 500));
|
|
44
|
-
message = message.slice(500);
|
|
45
|
-
}
|
|
46
|
-
replys.push(message);
|
|
47
|
-
replys = replys.map(item => {
|
|
48
|
-
return {
|
|
49
|
-
type: 1,
|
|
50
|
-
content: item.trim()
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
return replys;
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
console.log('chat gpt报错:' + e);
|
|
57
|
-
return [{ type: 1, content: '' }];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export { geGPTReply };
|
|
61
|
-
export default {
|
|
62
|
-
geGPTReply,
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=chatgpt.js.map
|