@tachybase/plugin-ai-chat 0.23.9
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/LICENSE +201 -0
- package/README.md +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/AIchatProvider.d.ts +2 -0
- package/dist/client/ai-chat/AIchatModalProvider.d.ts +16 -0
- package/dist/client/ai-chat/chatStyles.d.ts +28 -0
- package/dist/client/aichat-card/AIchat-BlockSettings.d.ts +2 -0
- package/dist/client/aichat-card/AIchatBlockInitializer.d.ts +5 -0
- package/dist/client/aichat-card/aichatCardStyles.d.ts +28 -0
- package/dist/client/aichat-setting/AIchatSettingsShortcut.d.ts +2 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js +455 -0
- package/dist/client/locale.d.ts +7 -0
- package/dist/externalVersion.js +15 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/en-US.json +10 -0
- package/dist/locale/zh-CN.json +13 -0
- package/dist/server/actions/aichat-controller.d.ts +6 -0
- package/dist/server/actions/aichat-controller.js +140 -0
- package/dist/server/collections/aisetting.d.ts +3 -0
- package/dist/server/collections/aisetting.js +46 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/plugin.d.ts +5 -0
- package/dist/server/plugin.js +104 -0
- package/package.json +23 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const NAMESPACE = "@tachybase/plugin-ai-chat";
|
|
2
|
+
export declare function usePluginTranslation(): any;
|
|
3
|
+
export declare function useTranslation(): {
|
|
4
|
+
t: (key: string, options?: {}) => string;
|
|
5
|
+
};
|
|
6
|
+
export declare function lang(key: string, options?: {}): string;
|
|
7
|
+
export declare const tval: (key: string) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"react": "18.3.1",
|
|
3
|
+
"@tachybase/client": "0.23.18",
|
|
4
|
+
"@ant-design/icons": "5.5.2",
|
|
5
|
+
"antd": "5.22.5",
|
|
6
|
+
"@tachybase/server": "0.23.18",
|
|
7
|
+
"antd-style": "3.7.1",
|
|
8
|
+
"@tachybase/schema": "0.23.18",
|
|
9
|
+
"lodash": "4.17.21",
|
|
10
|
+
"react-i18next": "15.2.0",
|
|
11
|
+
"@tachybase/actions": "0.23.18",
|
|
12
|
+
"@tachybase/utils": "0.23.18",
|
|
13
|
+
"axios": "1.7.9",
|
|
14
|
+
"@tachybase/database": "0.23.18"
|
|
15
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var src_exports = {};
|
|
30
|
+
__export(src_exports, {
|
|
31
|
+
default: () => import_server.default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(src_exports);
|
|
34
|
+
__reExport(src_exports, require("./server"), module.exports);
|
|
35
|
+
var import_server = __toESM(require("./server"));
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
...require("./server")
|
|
39
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"About Platform": "About the Platform",
|
|
3
|
+
"About Tachybase": "About Tachybase",
|
|
4
|
+
"DateComponent": "Date Component",
|
|
5
|
+
"Guess you want": "What you might want to know",
|
|
6
|
+
"How To Start": "How To Start",
|
|
7
|
+
"InformationForm": "Information Form",
|
|
8
|
+
"LoginComponent": "Login Component",
|
|
9
|
+
"What Can We Do": "What Can We Do"
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"AIchat": "AI对话",
|
|
3
|
+
"AIchat settings": "AI对话配置",
|
|
4
|
+
"About Platform": "关于平台",
|
|
5
|
+
"About Tachybase": "关于灵矶",
|
|
6
|
+
"DateComponent": "日期组件",
|
|
7
|
+
"Edit AIchat": "编辑AI卡片",
|
|
8
|
+
"Guess you want": "猜你想知道",
|
|
9
|
+
"How To Start": "如何开始",
|
|
10
|
+
"InformationForm": "信息表单",
|
|
11
|
+
"LoginComponent": "登录组件",
|
|
12
|
+
"What Can We Do": "我们能做什么"
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Context, Next } from '@tachybase/actions';
|
|
2
|
+
export declare class AIChatController {
|
|
3
|
+
handleMessage(ctx: Context, next: Next): Promise<void>;
|
|
4
|
+
getAIsetting(ctx: Context, next: Next): Promise<void>;
|
|
5
|
+
setAIsetting(ctx: Context, next: () => Promise<any>): Promise<any>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
8
|
+
var __typeError = (msg) => {
|
|
9
|
+
throw TypeError(msg);
|
|
10
|
+
};
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
|
+
var __decoratorStart = (base) => [, , , __create((base == null ? void 0 : base[__knownSymbol("metadata")]) ?? null)];
|
|
35
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
36
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
37
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
38
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
39
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
40
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
41
|
+
return value;
|
|
42
|
+
};
|
|
43
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
44
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
45
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
46
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
47
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
48
|
+
return __privateGet(this, extra);
|
|
49
|
+
}, set [name](x) {
|
|
50
|
+
return __privateSet(this, extra, x);
|
|
51
|
+
} }, name));
|
|
52
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
53
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
54
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
55
|
+
if (k) {
|
|
56
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
57
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
58
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
59
|
+
}
|
|
60
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
61
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
62
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
63
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
64
|
+
}
|
|
65
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
66
|
+
};
|
|
67
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
68
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
69
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
70
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
71
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
72
|
+
var aichat_controller_exports = {};
|
|
73
|
+
__export(aichat_controller_exports, {
|
|
74
|
+
AIChatController: () => AIChatController
|
|
75
|
+
});
|
|
76
|
+
module.exports = __toCommonJS(aichat_controller_exports);
|
|
77
|
+
var import_utils = require("@tachybase/utils");
|
|
78
|
+
var import_axios = __toESM(require("axios"));
|
|
79
|
+
var _setAIsetting_dec, _getAIsetting_dec, _handleMessage_dec, _AIChatController_decorators, _init;
|
|
80
|
+
_AIChatController_decorators = [(0, import_utils.Controller)("aichat")], _handleMessage_dec = [(0, import_utils.Action)("sendMessage", { acl: "loggedIn" })], _getAIsetting_dec = [(0, import_utils.Action)("get", { acl: "priviate" })], _setAIsetting_dec = [(0, import_utils.Action)("set", { acl: "priviate" })];
|
|
81
|
+
class AIChatController {
|
|
82
|
+
constructor() {
|
|
83
|
+
__runInitializers(_init, 5, this);
|
|
84
|
+
}
|
|
85
|
+
async handleMessage(ctx, next) {
|
|
86
|
+
var _a, _b, _c, _d, _e, _f;
|
|
87
|
+
const repo = ctx.db.getRepository("aisettings");
|
|
88
|
+
const data = await repo.findOne();
|
|
89
|
+
const model = data == null ? void 0 : data.Model;
|
|
90
|
+
const userMessage = ((_c = (_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) == null ? void 0 : _c.message) || void 0;
|
|
91
|
+
const apiUrl = data == null ? void 0 : data.AI_URL;
|
|
92
|
+
const aitoken = data == null ? void 0 : data.AI_API_KEY;
|
|
93
|
+
const requestData = {
|
|
94
|
+
model,
|
|
95
|
+
messages: [
|
|
96
|
+
{ role: "system", content: "You are a helpful assistant." },
|
|
97
|
+
{ role: "user", content: userMessage }
|
|
98
|
+
]
|
|
99
|
+
};
|
|
100
|
+
const headers = {
|
|
101
|
+
Authorization: `Bearer ${aitoken}`,
|
|
102
|
+
"Content-Type": "application/json"
|
|
103
|
+
};
|
|
104
|
+
try {
|
|
105
|
+
const response = await import_axios.default.post(apiUrl, requestData, { headers });
|
|
106
|
+
ctx.body = response.data;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
ctx.throw(((_f = (_e = (_d = error == null ? void 0 : error.response) == null ? void 0 : _d.data) == null ? void 0 : _e.error) == null ? void 0 : _f.message) || "request error");
|
|
109
|
+
}
|
|
110
|
+
await next();
|
|
111
|
+
}
|
|
112
|
+
async getAIsetting(ctx, next) {
|
|
113
|
+
const repo = ctx.db.getRepository("aisettings");
|
|
114
|
+
const data = await repo.findOne();
|
|
115
|
+
ctx.body = data;
|
|
116
|
+
await next();
|
|
117
|
+
}
|
|
118
|
+
async setAIsetting(ctx, next) {
|
|
119
|
+
const repo = ctx.db.getRepository("aisettings");
|
|
120
|
+
const values = ctx.action.params.values;
|
|
121
|
+
const data = await repo.findOne();
|
|
122
|
+
await repo.update({
|
|
123
|
+
values,
|
|
124
|
+
filter: {
|
|
125
|
+
id: values.id
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return next();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
_init = __decoratorStart(null);
|
|
132
|
+
__decorateElement(_init, 1, "handleMessage", _handleMessage_dec, AIChatController);
|
|
133
|
+
__decorateElement(_init, 1, "getAIsetting", _getAIsetting_dec, AIChatController);
|
|
134
|
+
__decorateElement(_init, 1, "setAIsetting", _setAIsetting_dec, AIChatController);
|
|
135
|
+
AIChatController = __decorateElement(_init, 0, "AIChatController", _AIChatController_decorators, AIChatController);
|
|
136
|
+
__runInitializers(_init, 1, AIChatController);
|
|
137
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
138
|
+
0 && (module.exports = {
|
|
139
|
+
AIChatController
|
|
140
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var aisetting_exports = {};
|
|
19
|
+
__export(aisetting_exports, {
|
|
20
|
+
default: () => aisetting_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(aisetting_exports);
|
|
23
|
+
var aisetting_default = {
|
|
24
|
+
name: "aisettings",
|
|
25
|
+
shared: true,
|
|
26
|
+
createdAt: false,
|
|
27
|
+
updatedAt: false,
|
|
28
|
+
createdBy: false,
|
|
29
|
+
updatedBy: false,
|
|
30
|
+
fields: [
|
|
31
|
+
{
|
|
32
|
+
type: "string",
|
|
33
|
+
name: "Model"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "string",
|
|
37
|
+
name: "AI_URL"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: "encryption",
|
|
41
|
+
name: "AI_API_KEY",
|
|
42
|
+
interface: "encryption",
|
|
43
|
+
iv: "mlbcs3d6i60962i6"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var server_exports = {};
|
|
29
|
+
__export(server_exports, {
|
|
30
|
+
default: () => import_plugin.default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(server_exports);
|
|
33
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
7
|
+
var __typeError = (msg) => {
|
|
8
|
+
throw TypeError(msg);
|
|
9
|
+
};
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var __decoratorStart = (base) => [, , , __create((base == null ? void 0 : base[__knownSymbol("metadata")]) ?? null)];
|
|
26
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
27
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
28
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
29
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
30
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
31
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
32
|
+
return value;
|
|
33
|
+
};
|
|
34
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
35
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
36
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
37
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
38
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
39
|
+
return __privateGet(this, extra);
|
|
40
|
+
}, set [name](x) {
|
|
41
|
+
return __privateSet(this, extra, x);
|
|
42
|
+
} }, name));
|
|
43
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
44
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
45
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
46
|
+
if (k) {
|
|
47
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
48
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
49
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
50
|
+
}
|
|
51
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
52
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
53
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
54
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
55
|
+
}
|
|
56
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
57
|
+
};
|
|
58
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
59
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
60
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
61
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
62
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
63
|
+
var plugin_exports = {};
|
|
64
|
+
__export(plugin_exports, {
|
|
65
|
+
PluginAiChatServer: () => PluginAiChatServer,
|
|
66
|
+
default: () => plugin_default
|
|
67
|
+
});
|
|
68
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
69
|
+
var import_server = require("@tachybase/server");
|
|
70
|
+
var import_aichat_controller = require("./actions/aichat-controller");
|
|
71
|
+
var _PluginAiChatServer_decorators, _init, _a;
|
|
72
|
+
_PluginAiChatServer_decorators = [(0, import_server.InjectedPlugin)({
|
|
73
|
+
Controllers: [import_aichat_controller.AIChatController]
|
|
74
|
+
})];
|
|
75
|
+
class PluginAiChatServer extends (_a = import_server.Plugin) {
|
|
76
|
+
async load() {
|
|
77
|
+
this.app.on("afterStart", async () => {
|
|
78
|
+
const AIRecord = await this.app.db.getRepository("aisettings").findOne();
|
|
79
|
+
if (!AIRecord) {
|
|
80
|
+
await this.app.db.getRepository("aisettings").create({
|
|
81
|
+
values: {
|
|
82
|
+
id: 1,
|
|
83
|
+
Model: "deepseek-chat",
|
|
84
|
+
AI_URL: "https://api.deepseek.com/chat/completions",
|
|
85
|
+
AI_API_KEY: "sk-xxxxxxxxxx"
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
this.app.acl.registerSnippet({
|
|
91
|
+
// name: `pm.${this.name}.aichat`,
|
|
92
|
+
name: `pm.system-services.ai-settings`,
|
|
93
|
+
actions: ["aichat:*"]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
_init = __decoratorStart(_a);
|
|
98
|
+
PluginAiChatServer = __decorateElement(_init, 0, "PluginAiChatServer", _PluginAiChatServer_decorators, PluginAiChatServer);
|
|
99
|
+
__runInitializers(_init, 1, PluginAiChatServer);
|
|
100
|
+
var plugin_default = PluginAiChatServer;
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
PluginAiChatServer
|
|
104
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tachybase/plugin-ai-chat",
|
|
3
|
+
"version": "0.23.9",
|
|
4
|
+
"main": "dist/server/index.js",
|
|
5
|
+
"devDependencies": {
|
|
6
|
+
"@ant-design/icons": "^5.5.2",
|
|
7
|
+
"@ant-design/x": "^1.0.3",
|
|
8
|
+
"antd": "5.22.5",
|
|
9
|
+
"antd-style": "3.7.1",
|
|
10
|
+
"lodash": "^4.17.21",
|
|
11
|
+
"openai": "^4.77.0",
|
|
12
|
+
"react-i18next": "^15.2.0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@tachybase/actions": "0.23.18",
|
|
16
|
+
"@tachybase/client": "0.23.18",
|
|
17
|
+
"@tachybase/database": "0.23.18",
|
|
18
|
+
"@tachybase/schema": "0.23.18",
|
|
19
|
+
"@tachybase/server": "0.23.18",
|
|
20
|
+
"@tachybase/utils": "0.23.18",
|
|
21
|
+
"@tachybase/test": "0.23.18"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/server.d.ts
ADDED
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|