wechaty-web-panel 1.6.112 → 1.6.113
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/dist/bot/chatgpt/index.js +235 -0
- package/dist/bot/coze/sdk/index.js +110 -0
- package/dist/bot/dify/sdk/index.js +461 -0
- package/dist/bot/dify/sdk/office.js +319 -0
- package/dist/bot/fastgpt/index.js +98 -0
- package/dist/bot/qanything/index.js +136 -0
- package/dist/botInstance/coze.js +167 -0
- package/dist/botInstance/cozev3.js +157 -0
- package/dist/botInstance/dify.js +160 -0
- package/dist/botInstance/fastgpt.js +130 -0
- package/dist/botInstance/gpt4v.js +95 -0
- package/dist/botInstance/officialOpenAi.js +186 -0
- package/dist/botInstance/qany.js +144 -0
- package/dist/botInstance/sdk/chatGPT4V.js +89 -0
- package/dist/botInstance/sdk/coze.js +200 -0
- package/dist/botInstance/sdk/difyClient.js +354 -0
- package/dist/botInstance/sdk/pTimeout.js +97 -0
- package/dist/botInstance/sdk/qanything.js +137 -0
- package/dist/botInstance/sdk/quick-lru.js +237 -0
- package/dist/common/hook.js +66 -0
- package/dist/common/index.js +513 -0
- package/dist/common/multiReply.js +158 -0
- package/dist/common/reply.js +23 -0
- package/dist/const/puppet-type.js +71 -0
- package/dist/db/aiDb.js +27 -0
- package/dist/db/aichatDb.js +84 -0
- package/dist/db/chatHistory.js +137 -0
- package/dist/db/configDb.js +97 -0
- package/dist/db/global.js +62 -0
- package/dist/db/gptConfig.js +85 -0
- package/dist/db/nedb.js +88 -0
- package/dist/db/puppetDb.js +58 -0
- package/dist/db/roomDb.js +83 -0
- package/dist/db/rssConfig.js +82 -0
- package/dist/db/rssHistory.js +88 -0
- package/dist/db/userDb.js +27 -0
- package/dist/handlers/on-callback-message.js +183 -0
- package/dist/handlers/on-error.js +5 -0
- package/dist/handlers/on-friend.js +62 -0
- package/dist/handlers/on-heartbeat.js +20 -0
- package/dist/handlers/on-login.js +58 -0
- package/dist/handlers/on-logout.js +17 -0
- package/dist/handlers/on-message.js +644 -0
- package/dist/handlers/on-ready.js +36 -0
- package/dist/handlers/on-record-message.js +56 -0
- package/dist/handlers/on-roomjoin.js +42 -0
- package/dist/handlers/on-roomleave.js +12 -0
- package/dist/handlers/on-roomtopic.js +16 -0
- package/dist/handlers/on-scan.js +64 -0
- package/dist/handlers/on-verifycode.js +42 -0
- package/dist/index.js +81 -69306
- package/dist/lib/contentCensor.js +23 -0
- package/dist/lib/index.js +562 -0
- package/dist/lib/oss.js +43 -0
- package/dist/lib/s3oss.js +33 -0
- package/dist/mcp/mcp-server.js +26 -0
- package/dist/mcp/src/config/database.js +51 -0
- package/dist/mcp/src/index.js +238 -0
- package/dist/mcp/src/mcp/schemas.js +178 -0
- package/dist/mcp/src/mcp/server.js +421 -0
- package/dist/mcp/src/mcp/streamable-server.js +690 -0
- package/dist/mcp/src/models/ChatMessage.js +151 -0
- package/dist/mcp/src/models/Friend.js +64 -0
- package/dist/mcp/src/models/Group.js +55 -0
- package/dist/mcp/src/models/GroupMember.js +67 -0
- package/dist/mcp/src/models/index.js +27 -0
- package/dist/mcp/src/scripts/migrate.js +21 -0
- package/dist/mcp/src/services/ChatDataService.js +284 -0
- package/dist/mcp/src/services/McpService.js +521 -0
- package/dist/mcp/src/services/McpTools.js +504 -0
- package/dist/mcp/streamable-examples.js +283 -0
- package/dist/mcp/streamable-server.js +79 -0
- package/dist/mcp/test-mcp.js +64 -0
- package/dist/mcp/test-streamable-server.js +86 -0
- package/dist/package-json.js +89 -0
- package/dist/proxy/aibotk.js +829 -0
- package/dist/proxy/api.js +431 -0
- package/dist/proxy/apib.js +587 -0
- package/dist/proxy/bot/chatgpt.js +38 -0
- package/dist/proxy/bot/coze.js +38 -0
- package/dist/proxy/bot/cozev3.js +38 -0
- package/dist/proxy/bot/dify.js +38 -0
- package/dist/proxy/bot/dispatch.js +81 -0
- package/dist/proxy/bot/fastgpt.js +27 -0
- package/dist/proxy/bot/qany.js +27 -0
- package/dist/proxy/config.js +14 -0
- package/dist/proxy/cozeAi.js +60 -0
- package/dist/proxy/cozeV3Ai.js +60 -0
- package/dist/proxy/difyAi.js +58 -0
- package/dist/proxy/fastgpt.js +55 -0
- package/dist/proxy/mqtt.js +275 -0
- package/dist/proxy/multimodal.js +122 -0
- package/dist/proxy/openAi.js +63 -0
- package/dist/proxy/outapi.js +62 -0
- package/dist/proxy/qAnyAi.js +57 -0
- package/dist/proxy/superagent.js +200 -0
- package/dist/proxy/tencent-open.js +255 -0
- package/dist/service/event-dispatch-service.js +309 -0
- package/dist/service/gpt4vService.js +45 -0
- package/dist/service/msg-filter-service.js +121 -0
- package/dist/service/msg-filters.js +645 -0
- package/dist/service/room-async-service.js +455 -0
- package/dist/task/index.js +535 -0
- package/dist/task/rss.js +174 -0
- package/package.json +2 -2
- package/src/package-json.js +2 -2
- package/tsconfig.json +3 -12
- package/dist/index.d.ts +0 -9
- package/tsconfig.cjs.json +0 -12
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import DifyAi from "../../botInstance/dify.js";
|
|
2
|
+
import { getPromotInfo } from "../aibotk.js";
|
|
3
|
+
let difyAi = {};
|
|
4
|
+
export function reset(adminId) {
|
|
5
|
+
if (!difyAi[adminId])
|
|
6
|
+
return;
|
|
7
|
+
difyAi[adminId].reset();
|
|
8
|
+
difyAi[adminId] = null;
|
|
9
|
+
}
|
|
10
|
+
export function resetAll() {
|
|
11
|
+
Object.keys(difyAi).forEach(key => {
|
|
12
|
+
if (difyAi[key]) {
|
|
13
|
+
difyAi[key].reset();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
difyAi = {};
|
|
17
|
+
}
|
|
18
|
+
export async function getDifyAiReply({ content, file, inputs }, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", showQuestion: false, timeoutMs: 80, model: "", systemMessage: "", keywordSystemMessages: [], isAiAgent: false, ignoreFiles: false, filterLinkContent: false }) {
|
|
19
|
+
if (!config.token) {
|
|
20
|
+
console.log('请到智能微秘书平台配置Dify的 api秘钥方可使用');
|
|
21
|
+
return [{ type: 1, content: '请到智能微秘书平台配置Dify的 api秘钥方可使用' }];
|
|
22
|
+
}
|
|
23
|
+
if (!difyAi[adminId]) {
|
|
24
|
+
difyAi[adminId] = new DifyAi(config);
|
|
25
|
+
}
|
|
26
|
+
let systemMessage = '';
|
|
27
|
+
if (config.keywordSystemMessages && config.keywordSystemMessages.length) {
|
|
28
|
+
const finalSystemMsg = config.keywordSystemMessages.find(item => content.startsWith(item.keyword));
|
|
29
|
+
if (finalSystemMsg && finalSystemMsg.promotId) {
|
|
30
|
+
const promotInfo = await getPromotInfo(finalSystemMsg.promotId);
|
|
31
|
+
console.log(`触发关键词角色功能,使用对应预设角色:${promotInfo.name}`);
|
|
32
|
+
systemMessage = promotInfo.promot;
|
|
33
|
+
content = content.replace(finalSystemMsg.keyword, '');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return await difyAi[adminId].getReply({ content, file, inputs }, uid, adminId, systemMessage);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=dify.js.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { getChatGPTReply } from './chatgpt.js';
|
|
2
|
+
import { getFastGPTReply } from './fastgpt.js';
|
|
3
|
+
import { getDifyAiReply } from './dify.js';
|
|
4
|
+
import { getCozeReply } from './coze.js';
|
|
5
|
+
import { getCozeV3AiReply } from './cozev3.js';
|
|
6
|
+
import { getQAnyReply } from './qany.js';
|
|
7
|
+
import { updateChatRecord } from '../aibotk.js';
|
|
8
|
+
import globalConfig from '../../db/global.js';
|
|
9
|
+
import { getUser } from '../../db/userDb.js';
|
|
10
|
+
/**
|
|
11
|
+
* 消息转发
|
|
12
|
+
* @param {botType: 机器人类别, content: 消息内容, uid: 说话的用户id, updateId: 更新的用户id, adminId: 对话实例id,用于分割不同配置, config: 机器人配置}
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export async function dispatchBot({ botType, isMention, userAlias, userWeixin, content, id, uid, uname, roomId, roomName, adminId, config, file }) {
|
|
16
|
+
console.log('进入定制机器人回复');
|
|
17
|
+
let userId = '';
|
|
18
|
+
if (process.env['CUSTOM_USER_ID']) {
|
|
19
|
+
userId = process.env['CUSTOM_USER_ID'];
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const contactSelf = await getUser();
|
|
23
|
+
const gptConfig = globalConfig.getGptConfigById(adminId);
|
|
24
|
+
let res, replys;
|
|
25
|
+
switch (botType) {
|
|
26
|
+
case 6:
|
|
27
|
+
// ChatGPT api
|
|
28
|
+
res = await getChatGPTReply({ content, file }, id, adminId, config, false);
|
|
29
|
+
replys = res;
|
|
30
|
+
break;
|
|
31
|
+
case 8:
|
|
32
|
+
// dify ai
|
|
33
|
+
console.log('进入Dify聊天');
|
|
34
|
+
res = await getDifyAiReply({ content, file, inputs: { userid: userId, isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
35
|
+
replys = res;
|
|
36
|
+
break;
|
|
37
|
+
case 9:
|
|
38
|
+
// fastGPT api
|
|
39
|
+
console.log('进入FastGPT聊天');
|
|
40
|
+
res = await getFastGPTReply({ content, file, variables: { userid: userId, isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
41
|
+
replys = res;
|
|
42
|
+
break;
|
|
43
|
+
case 11:
|
|
44
|
+
// coze api
|
|
45
|
+
console.log('进入Coze V2聊天');
|
|
46
|
+
if (file) {
|
|
47
|
+
replys = [{ type: 1, content: '' }];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
res = await getCozeReply(content, id, adminId, config);
|
|
51
|
+
replys = res;
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case 12:
|
|
55
|
+
// coze v3 api
|
|
56
|
+
console.log('进入Coze V3聊天');
|
|
57
|
+
res = await getCozeV3AiReply({ content, file, inputs: { userid: userId, isMention: isMention ? '1' : '0', uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
58
|
+
replys = res;
|
|
59
|
+
break;
|
|
60
|
+
case 13:
|
|
61
|
+
// QAnything api
|
|
62
|
+
console.log('进入有道QAnything聊天');
|
|
63
|
+
res = await getQAnyReply(content, id, adminId, config);
|
|
64
|
+
replys = res;
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
replys = [];
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (replys.length) {
|
|
71
|
+
void updateChatRecord(adminId, gptConfig.usedNum + 1);
|
|
72
|
+
globalConfig.updateOneGptConfig(adminId, { ...gptConfig, usedNum: gptConfig.usedNum + 1 });
|
|
73
|
+
}
|
|
74
|
+
return replys;
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
console.log('机器人接口信息获取失败', e);
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import FastGPTAi from "../../botInstance/fastgpt.js";
|
|
2
|
+
let fastGPT = {};
|
|
3
|
+
export function reset(adminId) {
|
|
4
|
+
if (!fastGPT[adminId])
|
|
5
|
+
return;
|
|
6
|
+
fastGPT[adminId].reset();
|
|
7
|
+
fastGPT[adminId] = null;
|
|
8
|
+
}
|
|
9
|
+
export function resetAll() {
|
|
10
|
+
Object.keys(fastGPT).forEach(key => {
|
|
11
|
+
if (fastGPT[key]) {
|
|
12
|
+
fastGPT[key].reset();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
fastGPT = {};
|
|
16
|
+
}
|
|
17
|
+
export async function getFastGPTReply({ content, file, variables }, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", showQuestion: false, timeoutMs: 80, ignoreFiles: false, filterLinkContent: false }) {
|
|
18
|
+
if (!config.token) {
|
|
19
|
+
console.log('请到智能微秘书平台配置FastGPT apikey参数方可使用');
|
|
20
|
+
return [{ type: 1, content: '请到平台配置FastGPT apikey参数方可使用' }];
|
|
21
|
+
}
|
|
22
|
+
if (!fastGPT[adminId]) {
|
|
23
|
+
fastGPT[adminId] = new FastGPTAi(config);
|
|
24
|
+
}
|
|
25
|
+
return await fastGPT[adminId].getReply({ content, uid, adminId, file, variables });
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=fastgpt.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import QAnyAi from "../../botInstance/qany.js";
|
|
2
|
+
let chatQAny = {};
|
|
3
|
+
export function reset(adminId) {
|
|
4
|
+
if (!chatQAny[adminId])
|
|
5
|
+
return;
|
|
6
|
+
chatQAny[adminId].reset();
|
|
7
|
+
chatQAny[adminId] = null;
|
|
8
|
+
}
|
|
9
|
+
export function resetAll() {
|
|
10
|
+
Object.keys(chatQAny).forEach(key => {
|
|
11
|
+
if (chatQAny[key]) {
|
|
12
|
+
chatQAny[key].reset();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
chatQAny = {};
|
|
16
|
+
}
|
|
17
|
+
export async function getQAnyReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", timeoutMs: 180, ignoreFiles: false, filterLinkContent: false }) {
|
|
18
|
+
if (!config.token || !config.botId) {
|
|
19
|
+
console.log('请到智能微秘书平台配置QAnything token 和 botId参数方可使用');
|
|
20
|
+
return [{ type: 1, content: '请到平台配置QAnything token 和 botId参数方可使用' }];
|
|
21
|
+
}
|
|
22
|
+
if (!chatQAny[adminId]) {
|
|
23
|
+
chatQAny[adminId] = new QAnyAi(config);
|
|
24
|
+
}
|
|
25
|
+
return await chatQAny[adminId].getReply(content, uid, adminId, '');
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=qany.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const AIBOTK = 'https://api-bot.aibotk.com/open/v1/api';
|
|
2
|
+
// export const AIBOTK = 'http://127.0.0.1:7002/open/v1/api'
|
|
3
|
+
export const AIBOTK_OUTAPI = 'https://outapi.aibotk.com/open/api/v1';
|
|
4
|
+
export const TULING = 'http://openapi.tuling123.com/openapi/api/v2';
|
|
5
|
+
export const TXHOST = 'http://api.tianapi.com';
|
|
6
|
+
export const TXSJHOST = 'https://apis.tianapi.com';
|
|
7
|
+
export const EMOHOST = 'https://doutu.lccyy.com/t/doutu/items?pageNum=1&pageSize=20&';
|
|
8
|
+
export default {
|
|
9
|
+
AIBOTK,
|
|
10
|
+
TULING,
|
|
11
|
+
TXHOST,
|
|
12
|
+
EMOHOST,
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { allConfig } from "../db/configDb.js";
|
|
2
|
+
import CozeAi from "../botInstance/coze.js";
|
|
3
|
+
let chatCoze = null;
|
|
4
|
+
/**
|
|
5
|
+
* 重置实例
|
|
6
|
+
*/
|
|
7
|
+
export function reset() {
|
|
8
|
+
if (chatCoze) {
|
|
9
|
+
chatCoze.reset();
|
|
10
|
+
chatCoze = null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export async function getCozeReply(content, uid) {
|
|
14
|
+
const config = await allConfig();
|
|
15
|
+
if (!config.coze_token || !config.coze_botId) {
|
|
16
|
+
console.log('请到智能微秘书平台配置Coze Token 和 botId参数方可使用');
|
|
17
|
+
return [{ type: 1, content: '请到平台配置Coze Token 和 botId 参数方可使用' }];
|
|
18
|
+
}
|
|
19
|
+
const chatConfig = {
|
|
20
|
+
token: config.coze_token, // token
|
|
21
|
+
debug: config.openaiDebug, // 开启调试
|
|
22
|
+
botId: config.coze_botId,
|
|
23
|
+
proxyPass: config.coze_baseUrl, // 反向代理地址
|
|
24
|
+
showQuestion: config.showQuestion, // 显示原文
|
|
25
|
+
showSuggestions: config.coze_showSuggestions, // 显示原文
|
|
26
|
+
timeoutMs: config.openaiTimeout, // 超时时间 s
|
|
27
|
+
systemMessage: config.openaiSystemMessage, // 预设promotion
|
|
28
|
+
filter: config.chatFilter,
|
|
29
|
+
ignoreFiles: config?.ignoreFiles || false,
|
|
30
|
+
filterLinkContent: config?.filterLinkContent || false,
|
|
31
|
+
filterConfig: {
|
|
32
|
+
type: 1,
|
|
33
|
+
appId: config.filterAppid,
|
|
34
|
+
apiKey: config.filterApiKey,
|
|
35
|
+
secretKey: config.filterSecretKey
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
if (!chatCoze) {
|
|
39
|
+
chatCoze = new CozeAi(chatConfig);
|
|
40
|
+
}
|
|
41
|
+
return await chatCoze.getReply(content, uid, '', '');
|
|
42
|
+
}
|
|
43
|
+
export async function getCozeSimpleReply({ content, uid, config }) {
|
|
44
|
+
if (!config.token || !config.botId) {
|
|
45
|
+
console.log('请到智能微秘书平台配置聊天总结的Coze Token 和 botId参数方可使用');
|
|
46
|
+
return [{ type: 1, content: '请到平台配置聊天总结的Coze Token 和 botId 参数方可使用' }];
|
|
47
|
+
}
|
|
48
|
+
const chatConfig = {
|
|
49
|
+
token: config.token, // token
|
|
50
|
+
debug: config.debug, // 开启调试
|
|
51
|
+
botId: config.botId,
|
|
52
|
+
proxyPass: config.baseUrl, // 反向代理地址
|
|
53
|
+
showQuestion: false, // 显示原文
|
|
54
|
+
showSuggestions: false, // 显示原文
|
|
55
|
+
timeoutMs: config.timeout, // 超时时间 s
|
|
56
|
+
systemMessage: '', // 预设promotion
|
|
57
|
+
};
|
|
58
|
+
return await new CozeAi(chatConfig).getReply(content, uid, '', '');
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=cozeAi.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { allConfig } from "../db/configDb.js";
|
|
2
|
+
import CozeV3Ai from "../botInstance/cozev3.js";
|
|
3
|
+
let cozeV3Ai = null;
|
|
4
|
+
/**
|
|
5
|
+
* 重置实例
|
|
6
|
+
*/
|
|
7
|
+
export function reset() {
|
|
8
|
+
if (cozeV3Ai) {
|
|
9
|
+
cozeV3Ai.reset();
|
|
10
|
+
cozeV3Ai = null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export async function getCozeV3Reply({ content, file, id, inputs }) {
|
|
14
|
+
const config = await allConfig();
|
|
15
|
+
if (!config.cozev3_token || !config.cozev3_botId) {
|
|
16
|
+
console.log('请到智能微秘书平台配置Coze token 和 botId参数方可使用');
|
|
17
|
+
return [{ type: 1, content: '请到平台配置Coze token 和 botId参数方可使用' }];
|
|
18
|
+
}
|
|
19
|
+
const chatConfig = {
|
|
20
|
+
token: config.cozev3_token, // token
|
|
21
|
+
botId: config.cozev3_botId, // botId
|
|
22
|
+
debug: config.openaiDebug, // 开启调试
|
|
23
|
+
proxyPass: config.cozev3_baseUrl, // 反向代理地址
|
|
24
|
+
showQuestion: config.showQuestion, // 显示原文
|
|
25
|
+
timeoutMs: config.openaiTimeout, // 超时时间 s
|
|
26
|
+
systemMessage: config.openaiSystemMessage, // 预设promotion
|
|
27
|
+
filter: config.chatFilter,
|
|
28
|
+
stream: config?.stream || false,
|
|
29
|
+
ignoreFiles: config?.ignoreFiles || false,
|
|
30
|
+
filterLinkContent: config?.filterLinkContent || false,
|
|
31
|
+
filterConfig: {
|
|
32
|
+
type: 1,
|
|
33
|
+
appId: config.filterAppid,
|
|
34
|
+
apiKey: config.filterApiKey,
|
|
35
|
+
secretKey: config.filterSecretKey
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
if (!cozeV3Ai) {
|
|
39
|
+
cozeV3Ai = new CozeV3Ai(chatConfig);
|
|
40
|
+
}
|
|
41
|
+
return await cozeV3Ai.getReply({ content, file, inputs }, id);
|
|
42
|
+
}
|
|
43
|
+
export async function getCozeV3SimpleReply({ content, id, inputs, config }) {
|
|
44
|
+
if (!config.token) {
|
|
45
|
+
console.log('请到智能微秘书平台配置聊天总结API Token参数方可使用');
|
|
46
|
+
return [{ type: 1, content: '请到平台配置API Token参数方可使用' }];
|
|
47
|
+
}
|
|
48
|
+
const chatConfig = {
|
|
49
|
+
token: config.token, // token
|
|
50
|
+
debug: config.debug, // 开启调试
|
|
51
|
+
proxyPass: config.baseUrl, // 反向代理地址
|
|
52
|
+
botId: config.botId, // botId
|
|
53
|
+
showQuestion: false, // 显示原文
|
|
54
|
+
timeoutMs: config.timeout, // 超时时间 s
|
|
55
|
+
systemMessage: '', // 预设promotion
|
|
56
|
+
stream: false,
|
|
57
|
+
};
|
|
58
|
+
return await new CozeV3Ai(chatConfig).getReply({ content, inputs }, id);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=cozeV3Ai.js.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { allConfig } from "../db/configDb.js";
|
|
2
|
+
import DifyAi from "../botInstance/dify.js";
|
|
3
|
+
let difyAi = null;
|
|
4
|
+
/**
|
|
5
|
+
* 重置实例
|
|
6
|
+
*/
|
|
7
|
+
export function reset() {
|
|
8
|
+
if (difyAi) {
|
|
9
|
+
difyAi.reset();
|
|
10
|
+
difyAi = null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export async function getDifyReply({ content, file, id, inputs }) {
|
|
14
|
+
const config = await allConfig();
|
|
15
|
+
if (!config.dify_token) {
|
|
16
|
+
console.log('请到智能微秘书平台配置difyAi apikey参数方可使用');
|
|
17
|
+
return [{ type: 1, content: '请到平台配置difyAi apikey参数方可使用' }];
|
|
18
|
+
}
|
|
19
|
+
const chatConfig = {
|
|
20
|
+
token: config.dify_token, // token
|
|
21
|
+
debug: config.openaiDebug, // 开启调试
|
|
22
|
+
proxyPass: config.dify_baseUrl, // 反向代理地址
|
|
23
|
+
showQuestion: config.showQuestion, // 显示原文
|
|
24
|
+
timeoutMs: config.openaiTimeout, // 超时时间 s
|
|
25
|
+
systemMessage: config.openaiSystemMessage, // 预设promotion
|
|
26
|
+
filter: config.chatFilter,
|
|
27
|
+
isAiAgent: config?.difyAgent || false,
|
|
28
|
+
ignoreFiles: config?.ignoreFiles || false,
|
|
29
|
+
filterLinkContent: config?.filterLinkContent || false,
|
|
30
|
+
filterConfig: {
|
|
31
|
+
type: 1,
|
|
32
|
+
appId: config.filterAppid,
|
|
33
|
+
apiKey: config.filterApiKey,
|
|
34
|
+
secretKey: config.filterSecretKey
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
if (!difyAi) {
|
|
38
|
+
difyAi = new DifyAi(chatConfig);
|
|
39
|
+
}
|
|
40
|
+
return await difyAi.getReply({ content, file, inputs }, id);
|
|
41
|
+
}
|
|
42
|
+
export async function getDifySimpleReply({ content, id, inputs, config }) {
|
|
43
|
+
if (!config.token) {
|
|
44
|
+
console.log('请到智能微秘书平台配置聊天总结API Token参数方可使用');
|
|
45
|
+
return [{ type: 1, content: '请到平台配置API Token参数方可使用' }];
|
|
46
|
+
}
|
|
47
|
+
const chatConfig = {
|
|
48
|
+
token: config.token, // token
|
|
49
|
+
debug: config.debug, // 开启调试
|
|
50
|
+
proxyPass: config.baseUrl, // 反向代理地址
|
|
51
|
+
showQuestion: false, // 显示原文
|
|
52
|
+
timeoutMs: config.timeout, // 超时时间 s
|
|
53
|
+
systemMessage: '', // 预设promotion
|
|
54
|
+
isAiAgent: true,
|
|
55
|
+
};
|
|
56
|
+
return await new DifyAi(chatConfig).getReply({ content, inputs }, id);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=difyAi.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { allConfig } from "../db/configDb.js";
|
|
2
|
+
import FastGPTAi from "../botInstance/fastgpt.js";
|
|
3
|
+
let fastGPT = null;
|
|
4
|
+
/**
|
|
5
|
+
* 重置实例
|
|
6
|
+
*/
|
|
7
|
+
export function reset() {
|
|
8
|
+
if (fastGPT) {
|
|
9
|
+
fastGPT.reset();
|
|
10
|
+
fastGPT = null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export async function getFastGPTReply({ content, file }, uid, variables) {
|
|
14
|
+
const config = await allConfig();
|
|
15
|
+
if (!config.gpttoken) {
|
|
16
|
+
console.log('请到智能微秘书平台配置Openai apikey参数方可使用');
|
|
17
|
+
return [{ type: 1, content: '请到平台配置Openai apikey参数方可使用' }];
|
|
18
|
+
}
|
|
19
|
+
const chatConfig = {
|
|
20
|
+
token: config.gpttoken, // token
|
|
21
|
+
debug: config.openaiDebug, // 开启调试
|
|
22
|
+
proxyPass: config.proxyPassUrl, // 反向代理地址
|
|
23
|
+
showQuestion: config.showQuestion, // 显示原文
|
|
24
|
+
timeoutMs: config.openaiTimeout, // 超时时间 s
|
|
25
|
+
filter: config.chatFilter,
|
|
26
|
+
ignoreFiles: config?.ignoreFiles || false,
|
|
27
|
+
filterLinkContent: config?.filterLinkContent || false,
|
|
28
|
+
filterConfig: {
|
|
29
|
+
type: 1,
|
|
30
|
+
appId: config.filterAppid,
|
|
31
|
+
apiKey: config.filterApiKey,
|
|
32
|
+
secretKey: config.filterSecretKey
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
if (!fastGPT) {
|
|
36
|
+
fastGPT = new FastGPTAi(chatConfig);
|
|
37
|
+
}
|
|
38
|
+
return await fastGPT.getReply({ content, file, uid, adminId: '', variables });
|
|
39
|
+
}
|
|
40
|
+
export async function getSimpleFastGptReply({ content, uid, config, variables }) {
|
|
41
|
+
if (!config.token) {
|
|
42
|
+
console.log('请到智能微秘书平台配置聊天总结的FastGPT API Token参数方可使用');
|
|
43
|
+
return [{ type: 1, content: '请到平台配置聊天总结的FastGPT API Token参数方可使用' }];
|
|
44
|
+
}
|
|
45
|
+
const chatConfig = {
|
|
46
|
+
token: config.token, // token
|
|
47
|
+
debug: config.debug, // 开启调试
|
|
48
|
+
proxyPass: config.baseUrl, // 反向代理地址
|
|
49
|
+
proxyUrl: '', // 代理地址
|
|
50
|
+
showQuestion: false, // 显示原文
|
|
51
|
+
timeoutMs: config.timeout, // 超时时间 s
|
|
52
|
+
};
|
|
53
|
+
return await new FastGPTAi(chatConfig).getReply({ content, uid, adminId: '', variables });
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=fastgpt.js.map
|