wechaty-web-panel 1.6.51 → 1.6.53
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 +7 -0
- package/dist/cjs/src/botInstance/officialOpenAi.d.ts +6 -0
- package/dist/cjs/src/botInstance/officialOpenAi.js +16 -6
- package/dist/cjs/src/botInstance/sdk/chatGPT.js +14 -7
- package/dist/cjs/src/handlers/on-friend.js +1 -1
- package/dist/cjs/src/package-json.js +1 -1
- package/dist/cjs/src/proxy/aibotk.d.ts +12 -0
- package/dist/cjs/src/proxy/aibotk.js +49 -1
- package/dist/cjs/src/proxy/openAi.js +3 -0
- package/dist/cjs/src/task/rss.js +9 -6
- package/dist/esm/src/botInstance/officialOpenAi.d.ts +6 -0
- package/dist/esm/src/botInstance/officialOpenAi.js +16 -6
- package/dist/esm/src/botInstance/sdk/chatGPT.js +14 -7
- package/dist/esm/src/handlers/on-friend.js +1 -1
- package/dist/esm/src/package-json.js +1 -1
- package/dist/esm/src/proxy/aibotk.d.ts +12 -0
- package/dist/esm/src/proxy/aibotk.js +48 -0
- package/dist/esm/src/proxy/openAi.js +3 -0
- package/dist/esm/src/task/rss.js +9 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export default OfficialOpenAi;
|
|
2
2
|
declare class OfficialOpenAi {
|
|
3
3
|
constructor(config?: {
|
|
4
|
+
temperature: number;
|
|
5
|
+
top_p: number;
|
|
6
|
+
presence_penalty: number;
|
|
4
7
|
token: string;
|
|
5
8
|
debug: number;
|
|
6
9
|
proxyPass: string;
|
|
@@ -40,6 +43,9 @@ declare class OfficialOpenAi {
|
|
|
40
43
|
_defaultUpsertMessage(message: any): Promise<void>;
|
|
41
44
|
} | null;
|
|
42
45
|
config: {
|
|
46
|
+
temperature: number;
|
|
47
|
+
top_p: number;
|
|
48
|
+
presence_penalty: number;
|
|
43
49
|
token: string;
|
|
44
50
|
debug: number;
|
|
45
51
|
proxyPass: string;
|
|
@@ -16,6 +16,9 @@ const index_js_1 = require("../lib/index.js");
|
|
|
16
16
|
let chatGPT = null;
|
|
17
17
|
class OfficialOpenAi {
|
|
18
18
|
constructor(config = {
|
|
19
|
+
temperature: 0.8,
|
|
20
|
+
top_p: 1,
|
|
21
|
+
presence_penalty: 1,
|
|
19
22
|
token: '',
|
|
20
23
|
debug: 0,
|
|
21
24
|
proxyPass: '',
|
|
@@ -47,7 +50,7 @@ class OfficialOpenAi {
|
|
|
47
50
|
}
|
|
48
51
|
const baseOptions = {
|
|
49
52
|
apiKey: this.config.token,
|
|
50
|
-
completionParams: { model: this.config.model },
|
|
53
|
+
completionParams: { model: this.config.model, temperature: this.config?.temperature || 0.8, top_p: this.config?.top_p || 1, presence_penalty: this.config?.presence_penalty || 1 },
|
|
51
54
|
debug: this.config.debug,
|
|
52
55
|
systemMessage: this.config.systemMessage || '',
|
|
53
56
|
};
|
|
@@ -57,25 +60,32 @@ class OfficialOpenAi {
|
|
|
57
60
|
if (this.config.model.toLowerCase().includes('32k')) {
|
|
58
61
|
baseOptions.maxModelTokens = 32768;
|
|
59
62
|
baseOptions.maxResponseTokens = 8192;
|
|
60
|
-
} // if use GPT-4 Turbo
|
|
61
|
-
else if (this.config.model.toLowerCase().includes('
|
|
63
|
+
} // if use GPT-4 Turbo preview 4o
|
|
64
|
+
else if (this.config.model.toLowerCase().includes('-preview') || this.config.model.toLowerCase().includes('-turbo') || this.config.model.toLowerCase().includes('gpt-4o')) {
|
|
62
65
|
baseOptions.maxModelTokens = 128000;
|
|
63
66
|
baseOptions.maxResponseTokens = 4096;
|
|
64
67
|
}
|
|
65
68
|
else {
|
|
66
69
|
baseOptions.maxModelTokens = 8192;
|
|
67
|
-
baseOptions.maxResponseTokens =
|
|
70
|
+
baseOptions.maxResponseTokens = 4096;
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
if (this.config.model.toLowerCase().includes('gpt-3.5')) {
|
|
71
|
-
if (this.config.model.toLowerCase().includes('16k') || this.config.model.toLowerCase().includes('turbo-1106')) {
|
|
74
|
+
if (this.config.model.toLowerCase() === 'gpt-3.5-turbo' || this.config.model.toLowerCase().includes('16k') || this.config.model.toLowerCase().includes('turbo-1106') || this.config.model.toLowerCase().includes('turbo-0125')) {
|
|
72
75
|
baseOptions.maxModelTokens = 16385;
|
|
73
76
|
baseOptions.maxResponseTokens = 4096;
|
|
74
77
|
}
|
|
75
78
|
else {
|
|
76
|
-
baseOptions.
|
|
79
|
+
baseOptions.maxModelTokens = 4096;
|
|
80
|
+
baseOptions.maxResponseTokens = 1024;
|
|
77
81
|
}
|
|
78
82
|
}
|
|
83
|
+
if (this.config?.modelMaxToken) {
|
|
84
|
+
baseOptions.maxModelTokens = this.config.modelMaxToken;
|
|
85
|
+
}
|
|
86
|
+
if (this.config?.maxToken) {
|
|
87
|
+
baseOptions.maxResponseTokens = this.config.maxToken;
|
|
88
|
+
}
|
|
79
89
|
if (this.config.proxyUrl) {
|
|
80
90
|
console.log(`启用代理请求:${this.config.proxyUrl}`);
|
|
81
91
|
this.chatGPT = new chatGPT_js_1.ChatGPTAPI({
|
|
@@ -120,12 +120,11 @@ let ChatGPTAPI = class {
|
|
|
120
120
|
...completionParams
|
|
121
121
|
};
|
|
122
122
|
this._systemMessage = systemMessage;
|
|
123
|
-
if (this._systemMessage
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
123
|
+
// if (!this._systemMessage) {
|
|
124
|
+
// const currentDate = new Date().toISOString().split("T")[0];
|
|
125
|
+
// this._systemMessage = `You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.
|
|
126
|
+
// Current date: ${currentDate}`;
|
|
127
|
+
// }
|
|
129
128
|
this._maxModelTokens = maxModelTokens;
|
|
130
129
|
this._maxResponseTokens = maxResponseTokens;
|
|
131
130
|
this._getMessageById = getMessageById ?? this._defaultGetMessageById;
|
|
@@ -257,7 +256,15 @@ Current date: ${currentDate}`;
|
|
|
257
256
|
}
|
|
258
257
|
if ((_a = response == null ? void 0 : response.choices) == null ? void 0 : _a.length) {
|
|
259
258
|
const message2 = response.choices[0].message;
|
|
260
|
-
|
|
259
|
+
if (typeof message2.content === 'string') {
|
|
260
|
+
result.text = message2.content;
|
|
261
|
+
}
|
|
262
|
+
else if (Array.isArray(message2.content)) {
|
|
263
|
+
const finalContent = message2.content.find(item => item.type === 'text');
|
|
264
|
+
if (finalContent) {
|
|
265
|
+
result.text = finalContent?.text?.content || '';
|
|
266
|
+
}
|
|
267
|
+
}
|
|
261
268
|
if (message2.role) {
|
|
262
269
|
result.role = message2.role;
|
|
263
270
|
}
|
|
@@ -22,7 +22,7 @@ async function onFriend(friendship) {
|
|
|
22
22
|
await (0, index_js_1.delay)(10000);
|
|
23
23
|
await friendship.accept();
|
|
24
24
|
}
|
|
25
|
-
else if (config.acceptFriendKeyWords.length > 0 && config.acceptFriendKeyWords.includes(hello)) {
|
|
25
|
+
else if (config.acceptFriendKeyWords.length > 0 && config.acceptFriendKeyWords.find(item => item.includes(hello))) {
|
|
26
26
|
console.log(`触发关键词${hello},10秒后自动通过好友请求`);
|
|
27
27
|
await (0, index_js_1.delay)(10000);
|
|
28
28
|
await friendship.accept();
|
|
@@ -67,6 +67,8 @@ declare namespace _default {
|
|
|
67
67
|
export { getMaterial };
|
|
68
68
|
export { getFireNews };
|
|
69
69
|
export { clearVerifyCode };
|
|
70
|
+
export { getRssLast };
|
|
71
|
+
export { updateRssLast };
|
|
70
72
|
export { getVerifyCode };
|
|
71
73
|
}
|
|
72
74
|
export default _default;
|
|
@@ -184,4 +186,14 @@ export function updateChatRecord(id: any, num: any): Promise<any>;
|
|
|
184
186
|
* @return {Promise<*>}
|
|
185
187
|
*/
|
|
186
188
|
export function getPromotInfo(id: any): Promise<any>;
|
|
189
|
+
/**
|
|
190
|
+
* 更新rss最后一条内容的配置
|
|
191
|
+
* @return {Promise<*>}
|
|
192
|
+
*/
|
|
193
|
+
export function getRssLast(id: any): Promise<any>;
|
|
194
|
+
/**
|
|
195
|
+
* 更新rss最后一条内容的配置
|
|
196
|
+
* @return {Promise<*>}
|
|
197
|
+
*/
|
|
198
|
+
export function updateRssLast(id: any, lastcontent: any): Promise<any>;
|
|
187
199
|
//# sourceMappingURL=aibotk.d.ts.map
|
|
@@ -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.getPromotInfo = exports.updateChatRecord = exports.getFireNews = exports.getMaterial = exports.getOne = exports.getMeiNv = exports.getMqttConfig = exports.updatePanelVersion = exports.asyncData = exports.sendRoom = exports.sendFriend = exports.putqn = exports.sendRobotInfo = exports.sendHeartBeat = exports.setQrCode = exports.updateSchedule = exports.setSchedule = exports.getScheduleList = exports.getConfig = exports.clearVerifyCode = exports.getVerifyCode = exports.getPanelVersion = exports.getRssConfig = exports.getTasks = exports.getGptConfig = exports.getCustomEvents = exports.getCustomNews = exports.getWordCloud = exports.getWordCloudConfig = exports.getWordCloudRoom = void 0;
|
|
6
|
+
exports.updateRssLast = exports.getRssLast = exports.getPromotInfo = exports.updateChatRecord = exports.getFireNews = exports.getMaterial = exports.getOne = exports.getMeiNv = exports.getMqttConfig = exports.updatePanelVersion = exports.asyncData = exports.sendRoom = exports.sendFriend = exports.putqn = exports.sendRobotInfo = exports.sendHeartBeat = exports.setQrCode = exports.updateSchedule = exports.setSchedule = exports.getScheduleList = exports.getConfig = exports.clearVerifyCode = exports.getVerifyCode = exports.getPanelVersion = exports.getRssConfig = exports.getTasks = exports.getGptConfig = exports.getCustomEvents = exports.getCustomNews = exports.getWordCloud = exports.getWordCloudConfig = exports.getWordCloudRoom = void 0;
|
|
7
7
|
const superagent_js_1 = require("./superagent.js");
|
|
8
8
|
const configDb_js_1 = require("../db/configDb.js");
|
|
9
9
|
const package_json_js_1 = require("../package-json.js");
|
|
@@ -224,6 +224,11 @@ async function getConfig() {
|
|
|
224
224
|
openaiAccessToken: '',
|
|
225
225
|
openaiDebug: false,
|
|
226
226
|
openaiModel: 'gpt-3.5-turbo',
|
|
227
|
+
temperature: 0.8,
|
|
228
|
+
top_p: 1,
|
|
229
|
+
presence_penalty: 1,
|
|
230
|
+
maxToken: null,
|
|
231
|
+
modelMaxToken: null,
|
|
227
232
|
dify_token: '',
|
|
228
233
|
dify_baseUrl: '',
|
|
229
234
|
difyAgent: false,
|
|
@@ -324,6 +329,47 @@ async function getRssConfig() {
|
|
|
324
329
|
}
|
|
325
330
|
}
|
|
326
331
|
exports.getRssConfig = getRssConfig;
|
|
332
|
+
/**
|
|
333
|
+
* 更新rss最后一条内容的配置
|
|
334
|
+
* @return {Promise<*>}
|
|
335
|
+
*/
|
|
336
|
+
async function updateRssLast(id, lastcontent) {
|
|
337
|
+
try {
|
|
338
|
+
console.log('id----', id, lastcontent);
|
|
339
|
+
let option = {
|
|
340
|
+
method: 'POST',
|
|
341
|
+
url: `/rss/lastcontent/${id}`,
|
|
342
|
+
params: {
|
|
343
|
+
content: lastcontent
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
let content = await (0, superagent_js_1.aiBotReq)(option);
|
|
347
|
+
return content;
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
console.log('获取rss配置文件失败:' + error);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
exports.updateRssLast = updateRssLast;
|
|
354
|
+
/**
|
|
355
|
+
* 更新rss最后一条内容的配置
|
|
356
|
+
* @return {Promise<*>}
|
|
357
|
+
*/
|
|
358
|
+
async function getRssLast(id) {
|
|
359
|
+
try {
|
|
360
|
+
let option = {
|
|
361
|
+
method: 'GET',
|
|
362
|
+
url: `/rss/lastcontent/${id}`,
|
|
363
|
+
params: {},
|
|
364
|
+
};
|
|
365
|
+
let content = await (0, superagent_js_1.aiBotReq)(option);
|
|
366
|
+
return content.data;
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
console.log('获取rss配置文件失败:' + error);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
exports.getRssLast = getRssLast;
|
|
327
373
|
/**
|
|
328
374
|
* 更新对话次数
|
|
329
375
|
* @param id
|
|
@@ -741,6 +787,8 @@ exports.default = {
|
|
|
741
787
|
getMaterial,
|
|
742
788
|
getFireNews,
|
|
743
789
|
clearVerifyCode,
|
|
790
|
+
getRssLast,
|
|
791
|
+
updateRssLast,
|
|
744
792
|
getVerifyCode
|
|
745
793
|
};
|
|
746
794
|
//# sourceMappingURL=aibotk.js.map
|
|
@@ -31,6 +31,9 @@ async function getGptOfficialReply(content, uid, isFastGPT) {
|
|
|
31
31
|
showQuestion: config.showQuestion,
|
|
32
32
|
timeoutMs: config.openaiTimeout,
|
|
33
33
|
model: config.openaiModel,
|
|
34
|
+
temperature: config?.temperature,
|
|
35
|
+
top_p: config?.top_p,
|
|
36
|
+
presence_penalty: config?.presence_penalty,
|
|
34
37
|
systemMessage: config.openaiSystemMessage,
|
|
35
38
|
filter: config.chatFilter,
|
|
36
39
|
filterConfig: {
|
package/dist/cjs/src/task/rss.js
CHANGED
|
@@ -11,6 +11,7 @@ const index_js_2 = require("../common/index.js");
|
|
|
11
11
|
const rss_parser_1 = __importDefault(require("rss-parser"));
|
|
12
12
|
const puppet_type_js_1 = require("../const/puppet-type.js");
|
|
13
13
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
14
|
+
const aibotk_js_1 = require("../proxy/aibotk.js");
|
|
14
15
|
async function getRssContent(info) {
|
|
15
16
|
try {
|
|
16
17
|
const parser = new rss_parser_1.default({
|
|
@@ -21,17 +22,17 @@ async function getRssContent(info) {
|
|
|
21
22
|
});
|
|
22
23
|
console.log('订阅源:' + info.rssUrl);
|
|
23
24
|
const feed = await parser.parseURL(info.rssUrl);
|
|
24
|
-
const lastItem = await (0,
|
|
25
|
-
console.log('
|
|
25
|
+
const lastItem = await (0, aibotk_js_1.getRssLast)(info.id);
|
|
26
|
+
console.log('上一条已经推送的消息', JSON.stringify(lastItem));
|
|
26
27
|
// 当存在文章的时候
|
|
27
28
|
if (feed.items && feed.items.length) {
|
|
28
29
|
// 当存在历史推送记录 需要判读是否推送过
|
|
29
30
|
const last = feed.items[0];
|
|
30
31
|
const lastContent = last.link || last.title;
|
|
31
32
|
if (lastItem) {
|
|
32
|
-
if (lastContent !== lastItem
|
|
33
|
+
if (lastContent !== lastItem?.lastContent) {
|
|
33
34
|
const content = await setContent(last, info);
|
|
34
|
-
void (0,
|
|
35
|
+
void (0, aibotk_js_1.updateRssLast)(info.id, lastContent);
|
|
35
36
|
return content;
|
|
36
37
|
}
|
|
37
38
|
console.log('rss内容未更新,最后一条内容已推送');
|
|
@@ -39,13 +40,14 @@ async function getRssContent(info) {
|
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
41
42
|
const content = await setContent(last, info);
|
|
42
|
-
void (0,
|
|
43
|
+
void (0, aibotk_js_1.updateRssLast)(info.id, lastContent);
|
|
43
44
|
return content;
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
catch (e) {
|
|
48
49
|
console.log("获取rss内容失败,大概率是订阅源格式不规范,请更换:" + e);
|
|
50
|
+
return [];
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
async function setContent(feed, info) {
|
|
@@ -56,7 +58,8 @@ async function setContent(feed, info) {
|
|
|
56
58
|
return [res];
|
|
57
59
|
}
|
|
58
60
|
else {
|
|
59
|
-
const
|
|
61
|
+
const desc = (0, index_js_1.delHtmlTag)(feed.content)?.substring(0, 1500)?.trim();
|
|
62
|
+
const content = `${info.prefixWord ? info.prefixWord + eol + eol : ''}${(0, index_js_1.delHtmlTag)(feed.title)}${eol}${eol} ${desc ? `【摘要】:${desc}...${eol}` : ''}【链接】:${feed.link}${eol}${eol}${info.suffixWord || ''}`;
|
|
60
63
|
return [{ type: 1, content: content }];
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export default OfficialOpenAi;
|
|
2
2
|
declare class OfficialOpenAi {
|
|
3
3
|
constructor(config?: {
|
|
4
|
+
temperature: number;
|
|
5
|
+
top_p: number;
|
|
6
|
+
presence_penalty: number;
|
|
4
7
|
token: string;
|
|
5
8
|
debug: number;
|
|
6
9
|
proxyPass: string;
|
|
@@ -40,6 +43,9 @@ declare class OfficialOpenAi {
|
|
|
40
43
|
_defaultUpsertMessage(message: any): Promise<void>;
|
|
41
44
|
} | null;
|
|
42
45
|
config: {
|
|
46
|
+
temperature: number;
|
|
47
|
+
top_p: number;
|
|
48
|
+
presence_penalty: number;
|
|
43
49
|
token: string;
|
|
44
50
|
debug: number;
|
|
45
51
|
proxyPass: string;
|
|
@@ -11,6 +11,9 @@ import { extractImageLinks } from '../lib/index.js';
|
|
|
11
11
|
let chatGPT = null;
|
|
12
12
|
class OfficialOpenAi {
|
|
13
13
|
constructor(config = {
|
|
14
|
+
temperature: 0.8,
|
|
15
|
+
top_p: 1,
|
|
16
|
+
presence_penalty: 1,
|
|
14
17
|
token: '',
|
|
15
18
|
debug: 0,
|
|
16
19
|
proxyPass: '',
|
|
@@ -42,7 +45,7 @@ class OfficialOpenAi {
|
|
|
42
45
|
}
|
|
43
46
|
const baseOptions = {
|
|
44
47
|
apiKey: this.config.token,
|
|
45
|
-
completionParams: { model: this.config.model },
|
|
48
|
+
completionParams: { model: this.config.model, temperature: this.config?.temperature || 0.8, top_p: this.config?.top_p || 1, presence_penalty: this.config?.presence_penalty || 1 },
|
|
46
49
|
debug: this.config.debug,
|
|
47
50
|
systemMessage: this.config.systemMessage || '',
|
|
48
51
|
};
|
|
@@ -52,25 +55,32 @@ class OfficialOpenAi {
|
|
|
52
55
|
if (this.config.model.toLowerCase().includes('32k')) {
|
|
53
56
|
baseOptions.maxModelTokens = 32768;
|
|
54
57
|
baseOptions.maxResponseTokens = 8192;
|
|
55
|
-
} // if use GPT-4 Turbo
|
|
56
|
-
else if (this.config.model.toLowerCase().includes('
|
|
58
|
+
} // if use GPT-4 Turbo preview 4o
|
|
59
|
+
else if (this.config.model.toLowerCase().includes('-preview') || this.config.model.toLowerCase().includes('-turbo') || this.config.model.toLowerCase().includes('gpt-4o')) {
|
|
57
60
|
baseOptions.maxModelTokens = 128000;
|
|
58
61
|
baseOptions.maxResponseTokens = 4096;
|
|
59
62
|
}
|
|
60
63
|
else {
|
|
61
64
|
baseOptions.maxModelTokens = 8192;
|
|
62
|
-
baseOptions.maxResponseTokens =
|
|
65
|
+
baseOptions.maxResponseTokens = 4096;
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
if (this.config.model.toLowerCase().includes('gpt-3.5')) {
|
|
66
|
-
if (this.config.model.toLowerCase().includes('16k') || this.config.model.toLowerCase().includes('turbo-1106')) {
|
|
69
|
+
if (this.config.model.toLowerCase() === 'gpt-3.5-turbo' || this.config.model.toLowerCase().includes('16k') || this.config.model.toLowerCase().includes('turbo-1106') || this.config.model.toLowerCase().includes('turbo-0125')) {
|
|
67
70
|
baseOptions.maxModelTokens = 16385;
|
|
68
71
|
baseOptions.maxResponseTokens = 4096;
|
|
69
72
|
}
|
|
70
73
|
else {
|
|
71
|
-
baseOptions.
|
|
74
|
+
baseOptions.maxModelTokens = 4096;
|
|
75
|
+
baseOptions.maxResponseTokens = 1024;
|
|
72
76
|
}
|
|
73
77
|
}
|
|
78
|
+
if (this.config?.modelMaxToken) {
|
|
79
|
+
baseOptions.maxModelTokens = this.config.modelMaxToken;
|
|
80
|
+
}
|
|
81
|
+
if (this.config?.maxToken) {
|
|
82
|
+
baseOptions.maxResponseTokens = this.config.maxToken;
|
|
83
|
+
}
|
|
74
84
|
if (this.config.proxyUrl) {
|
|
75
85
|
console.log(`启用代理请求:${this.config.proxyUrl}`);
|
|
76
86
|
this.chatGPT = new ChatGPTAPI({
|
|
@@ -112,12 +112,11 @@ let ChatGPTAPI = class {
|
|
|
112
112
|
...completionParams
|
|
113
113
|
};
|
|
114
114
|
this._systemMessage = systemMessage;
|
|
115
|
-
if (this._systemMessage
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
115
|
+
// if (!this._systemMessage) {
|
|
116
|
+
// const currentDate = new Date().toISOString().split("T")[0];
|
|
117
|
+
// this._systemMessage = `You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.
|
|
118
|
+
// Current date: ${currentDate}`;
|
|
119
|
+
// }
|
|
121
120
|
this._maxModelTokens = maxModelTokens;
|
|
122
121
|
this._maxResponseTokens = maxResponseTokens;
|
|
123
122
|
this._getMessageById = getMessageById ?? this._defaultGetMessageById;
|
|
@@ -249,7 +248,15 @@ Current date: ${currentDate}`;
|
|
|
249
248
|
}
|
|
250
249
|
if ((_a = response == null ? void 0 : response.choices) == null ? void 0 : _a.length) {
|
|
251
250
|
const message2 = response.choices[0].message;
|
|
252
|
-
|
|
251
|
+
if (typeof message2.content === 'string') {
|
|
252
|
+
result.text = message2.content;
|
|
253
|
+
}
|
|
254
|
+
else if (Array.isArray(message2.content)) {
|
|
255
|
+
const finalContent = message2.content.find(item => item.type === 'text');
|
|
256
|
+
if (finalContent) {
|
|
257
|
+
result.text = finalContent?.text?.content || '';
|
|
258
|
+
}
|
|
259
|
+
}
|
|
253
260
|
if (message2.role) {
|
|
254
261
|
result.role = message2.role;
|
|
255
262
|
}
|
|
@@ -20,7 +20,7 @@ async function onFriend(friendship) {
|
|
|
20
20
|
await delay(10000);
|
|
21
21
|
await friendship.accept();
|
|
22
22
|
}
|
|
23
|
-
else if (config.acceptFriendKeyWords.length > 0 && config.acceptFriendKeyWords.includes(hello)) {
|
|
23
|
+
else if (config.acceptFriendKeyWords.length > 0 && config.acceptFriendKeyWords.find(item => item.includes(hello))) {
|
|
24
24
|
console.log(`触发关键词${hello},10秒后自动通过好友请求`);
|
|
25
25
|
await delay(10000);
|
|
26
26
|
await friendship.accept();
|
|
@@ -67,6 +67,8 @@ declare namespace _default {
|
|
|
67
67
|
export { getMaterial };
|
|
68
68
|
export { getFireNews };
|
|
69
69
|
export { clearVerifyCode };
|
|
70
|
+
export { getRssLast };
|
|
71
|
+
export { updateRssLast };
|
|
70
72
|
export { getVerifyCode };
|
|
71
73
|
}
|
|
72
74
|
export default _default;
|
|
@@ -184,4 +186,14 @@ export function updateChatRecord(id: any, num: any): Promise<any>;
|
|
|
184
186
|
* @return {Promise<*>}
|
|
185
187
|
*/
|
|
186
188
|
export function getPromotInfo(id: any): Promise<any>;
|
|
189
|
+
/**
|
|
190
|
+
* 更新rss最后一条内容的配置
|
|
191
|
+
* @return {Promise<*>}
|
|
192
|
+
*/
|
|
193
|
+
export function getRssLast(id: any): Promise<any>;
|
|
194
|
+
/**
|
|
195
|
+
* 更新rss最后一条内容的配置
|
|
196
|
+
* @return {Promise<*>}
|
|
197
|
+
*/
|
|
198
|
+
export function updateRssLast(id: any, lastcontent: any): Promise<any>;
|
|
187
199
|
//# sourceMappingURL=aibotk.d.ts.map
|
|
@@ -210,6 +210,11 @@ async function getConfig() {
|
|
|
210
210
|
openaiAccessToken: '',
|
|
211
211
|
openaiDebug: false,
|
|
212
212
|
openaiModel: 'gpt-3.5-turbo',
|
|
213
|
+
temperature: 0.8,
|
|
214
|
+
top_p: 1,
|
|
215
|
+
presence_penalty: 1,
|
|
216
|
+
maxToken: null,
|
|
217
|
+
modelMaxToken: null,
|
|
213
218
|
dify_token: '',
|
|
214
219
|
dify_baseUrl: '',
|
|
215
220
|
difyAgent: false,
|
|
@@ -306,6 +311,45 @@ export async function getRssConfig() {
|
|
|
306
311
|
console.log('获取rss配置文件失败:' + error);
|
|
307
312
|
}
|
|
308
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* 更新rss最后一条内容的配置
|
|
316
|
+
* @return {Promise<*>}
|
|
317
|
+
*/
|
|
318
|
+
async function updateRssLast(id, lastcontent) {
|
|
319
|
+
try {
|
|
320
|
+
console.log('id----', id, lastcontent);
|
|
321
|
+
let option = {
|
|
322
|
+
method: 'POST',
|
|
323
|
+
url: `/rss/lastcontent/${id}`,
|
|
324
|
+
params: {
|
|
325
|
+
content: lastcontent
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
let content = await aiBotReq(option);
|
|
329
|
+
return content;
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
console.log('获取rss配置文件失败:' + error);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* 更新rss最后一条内容的配置
|
|
337
|
+
* @return {Promise<*>}
|
|
338
|
+
*/
|
|
339
|
+
async function getRssLast(id) {
|
|
340
|
+
try {
|
|
341
|
+
let option = {
|
|
342
|
+
method: 'GET',
|
|
343
|
+
url: `/rss/lastcontent/${id}`,
|
|
344
|
+
params: {},
|
|
345
|
+
};
|
|
346
|
+
let content = await aiBotReq(option);
|
|
347
|
+
return content.data;
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
console.log('获取rss配置文件失败:' + error);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
309
353
|
/**
|
|
310
354
|
* 更新对话次数
|
|
311
355
|
* @param id
|
|
@@ -707,6 +751,8 @@ export { getMaterial };
|
|
|
707
751
|
export { getFireNews };
|
|
708
752
|
export { updateChatRecord };
|
|
709
753
|
export { getPromotInfo };
|
|
754
|
+
export { getRssLast };
|
|
755
|
+
export { updateRssLast };
|
|
710
756
|
export default {
|
|
711
757
|
getConfig,
|
|
712
758
|
getScheduleList,
|
|
@@ -726,6 +772,8 @@ export default {
|
|
|
726
772
|
getMaterial,
|
|
727
773
|
getFireNews,
|
|
728
774
|
clearVerifyCode,
|
|
775
|
+
getRssLast,
|
|
776
|
+
updateRssLast,
|
|
729
777
|
getVerifyCode
|
|
730
778
|
};
|
|
731
779
|
//# sourceMappingURL=aibotk.js.map
|
|
@@ -24,6 +24,9 @@ export async function getGptOfficialReply(content, uid, isFastGPT) {
|
|
|
24
24
|
showQuestion: config.showQuestion,
|
|
25
25
|
timeoutMs: config.openaiTimeout,
|
|
26
26
|
model: config.openaiModel,
|
|
27
|
+
temperature: config?.temperature,
|
|
28
|
+
top_p: config?.top_p,
|
|
29
|
+
presence_penalty: config?.presence_penalty,
|
|
27
30
|
systemMessage: config.openaiSystemMessage,
|
|
28
31
|
filter: config.chatFilter,
|
|
29
32
|
filterConfig: {
|
package/dist/esm/src/task/rss.js
CHANGED
|
@@ -5,6 +5,7 @@ import { roomSay, contactSay } from "../common/index.js";
|
|
|
5
5
|
import rssParser from 'rss-parser';
|
|
6
6
|
import { getPuppetEol } from "../const/puppet-type.js";
|
|
7
7
|
import dayjs from "dayjs";
|
|
8
|
+
import { getRssLast, updateRssLast } from '../proxy/aibotk.js';
|
|
8
9
|
async function getRssContent(info) {
|
|
9
10
|
try {
|
|
10
11
|
const parser = new rssParser({
|
|
@@ -15,17 +16,17 @@ async function getRssContent(info) {
|
|
|
15
16
|
});
|
|
16
17
|
console.log('订阅源:' + info.rssUrl);
|
|
17
18
|
const feed = await parser.parseURL(info.rssUrl);
|
|
18
|
-
const lastItem = await
|
|
19
|
-
console.log('
|
|
19
|
+
const lastItem = await getRssLast(info.id);
|
|
20
|
+
console.log('上一条已经推送的消息', JSON.stringify(lastItem));
|
|
20
21
|
// 当存在文章的时候
|
|
21
22
|
if (feed.items && feed.items.length) {
|
|
22
23
|
// 当存在历史推送记录 需要判读是否推送过
|
|
23
24
|
const last = feed.items[0];
|
|
24
25
|
const lastContent = last.link || last.title;
|
|
25
26
|
if (lastItem) {
|
|
26
|
-
if (lastContent !== lastItem
|
|
27
|
+
if (lastContent !== lastItem?.lastContent) {
|
|
27
28
|
const content = await setContent(last, info);
|
|
28
|
-
void
|
|
29
|
+
void updateRssLast(info.id, lastContent);
|
|
29
30
|
return content;
|
|
30
31
|
}
|
|
31
32
|
console.log('rss内容未更新,最后一条内容已推送');
|
|
@@ -33,13 +34,14 @@ async function getRssContent(info) {
|
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
const content = await setContent(last, info);
|
|
36
|
-
void
|
|
37
|
+
void updateRssLast(info.id, lastContent);
|
|
37
38
|
return content;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
catch (e) {
|
|
42
43
|
console.log("获取rss内容失败,大概率是订阅源格式不规范,请更换:" + e);
|
|
44
|
+
return [];
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
async function setContent(feed, info) {
|
|
@@ -50,7 +52,8 @@ async function setContent(feed, info) {
|
|
|
50
52
|
return [res];
|
|
51
53
|
}
|
|
52
54
|
else {
|
|
53
|
-
const
|
|
55
|
+
const desc = delHtmlTag(feed.content)?.substring(0, 1500)?.trim();
|
|
56
|
+
const content = `${info.prefixWord ? info.prefixWord + eol + eol : ''}${delHtmlTag(feed.title)}${eol}${eol} ${desc ? `【摘要】:${desc}...${eol}` : ''}【链接】:${feed.link}${eol}${eol}${info.suffixWord || ''}`;
|
|
54
57
|
return [{ type: 1, content: content }];
|
|
55
58
|
}
|
|
56
59
|
}
|