@nocobase/plugin-ai 2.1.0-beta.13 → 2.1.0-beta.15
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/client/{35156dfea5f288fa.js → 204.91be8cfc54d91a59.js} +1 -1
- package/dist/client/ai-employees/chatbox/hooks/useChatMessageActions.d.ts +2 -0
- package/dist/client/index.js +3 -3
- package/dist/externalVersion.js +16 -17
- package/dist/node_modules/fast-glob/package.json +1 -1
- package/dist/node_modules/flexsearch/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.js +5 -0
- package/dist/server/document-loader/constants.d.ts +1 -2
- package/dist/server/document-loader/constants.js +6 -1
- package/dist/server/document-loader/loader.d.ts +0 -1
- package/dist/server/document-loader/loader.js +2 -55
- package/dist/server/document-loader/types.d.ts +0 -1
- package/dist/server/llm-providers/anthropic.d.ts +2 -2
- package/dist/server/llm-providers/anthropic.js +1 -1
- package/dist/server/llm-providers/dashscope.d.ts +2 -3
- package/dist/server/llm-providers/dashscope.js +3 -28
- package/dist/server/llm-providers/deepseek.d.ts +2 -3
- package/dist/server/llm-providers/deepseek.js +2 -31
- package/dist/server/llm-providers/google-genai.d.ts +3 -18
- package/dist/server/llm-providers/google-genai.js +9 -7
- package/dist/server/llm-providers/kimi/provider.d.ts +4 -4
- package/dist/server/llm-providers/kimi/provider.js +3 -28
- package/dist/server/llm-providers/provider.d.ts +11 -2
- package/dist/server/llm-providers/provider.js +60 -0
- package/dist/server/manager/ai-chat-conversation.js +6 -2
- package/dist/server/manager/built-in-manager.js +1 -2
- package/dist/server/{document-loader/loader.worker.d.ts → migrations/20260424000000-remove-cole-ai-employee.d.ts} +6 -1
- package/dist/server/migrations/20260424000000-remove-cole-ai-employee.js +48 -0
- package/dist/server/utils.js +3 -2
- package/package.json +2 -2
- package/dist/server/document-loader/loader.worker.js +0 -68
- package/dist/server/document-loader/vendor/langchain/document_loaders/fs/text.d.ts +0 -20
- package/dist/server/document-loader/vendor/langchain/document_loaders/fs/text.js +0 -96
- /package/dist/client/{1a5eedf9bc8e8a4e.js → 107.64d9efa24d6b9143.js} +0 -0
- /package/dist/client/{9ac6d4760aecc4ba.js → 124.768c8aa5d6e6b461.js} +0 -0
- /package/dist/client/{031e76adc8e418c0.js → 159.d52107c7a34ce2da.js} +0 -0
- /package/dist/client/{5672875b55ce455d.js → 192.0419770b69678994.js} +0 -0
- /package/dist/client/{3a04632b58ae88ec.js → 238.9f784a7cdb751999.js} +0 -0
- /package/dist/client/{6f06d6017f0c35fe.js → 263.6e1dfb1cbb1964f5.js} +0 -0
- /package/dist/client/{154167de2cbe8144.js → 35.5ee7503d9c09daa8.js} +0 -0
- /package/dist/client/{05bb46e182de283c.js → 47.6bd245f2140efd24.js} +0 -0
- /package/dist/client/{d42de7ae09b416c1.js → 481.03b3d2306d409933.js} +0 -0
- /package/dist/client/{d1c1b405bbcb3d80.js → 524.954f96ec4fc2fd7a.js} +0 -0
- /package/dist/client/{372594b4121f3e21.js → 586.6a1510cabaa84f23.js} +0 -0
- /package/dist/client/{f4b27eaa2f42f3b6.js → 650.8871a07b31c307ea.js} +0 -0
- /package/dist/client/{c49179ef6fcbc972.js → 755.e295bbd2b2a1cc21.js} +0 -0
- /package/dist/client/{a28774e6b2ca1fa1.js → 772.d51f683c55e18dd4.js} +0 -0
- /package/dist/client/{a0a62fe07b8187c2.js → 870.84187dcb8c89b4dc.js} +0 -0
- /package/dist/client/{a2b9e4140138455f.js → 91.90e7098b7fbd5d00.js} +0 -0
- /package/dist/client/{4ef570b622fa76c4.js → 933.baab3aa75f30e020.js} +0 -0
- /package/dist/client/{7f65c7eb3e7c2e8e.js → 987.3aee964e7f406939.js} +0 -0
|
@@ -46,20 +46,20 @@ var import_provider = require("./provider");
|
|
|
46
46
|
var import_axios = __toESM(require("axios"));
|
|
47
47
|
var import_utils = require("../utils");
|
|
48
48
|
var import_ai_manager = require("../manager/ai-manager");
|
|
49
|
-
const GOOGLE_GEN_AI_URL = "https://generativelanguage.googleapis.com
|
|
49
|
+
const GOOGLE_GEN_AI_URL = "https://generativelanguage.googleapis.com";
|
|
50
50
|
class GoogleGenAIProvider extends import_provider.LLMProvider {
|
|
51
51
|
get baseURL() {
|
|
52
52
|
return GOOGLE_GEN_AI_URL;
|
|
53
53
|
}
|
|
54
54
|
createModel() {
|
|
55
|
-
const { apiKey } = this.serviceOptions || {};
|
|
55
|
+
const { apiKey, baseURL } = this.serviceOptions || {};
|
|
56
56
|
const { model, responseFormat } = this.modelOptions || {};
|
|
57
57
|
return new import_google_genai.ChatGoogleGenerativeAI({
|
|
58
58
|
apiKey,
|
|
59
59
|
...this.modelOptions,
|
|
60
60
|
model,
|
|
61
61
|
json: responseFormat === "json",
|
|
62
|
-
|
|
62
|
+
baseUrl: baseURL ?? this.baseURL
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
async listModels() {
|
|
@@ -77,7 +77,7 @@ class GoogleGenAIProvider extends import_provider.LLMProvider {
|
|
|
77
77
|
baseURL = baseURL.slice(0, -1);
|
|
78
78
|
}
|
|
79
79
|
try {
|
|
80
|
-
const res = await import_axios.default.get(`${baseURL}/models?key=${apiKey}`);
|
|
80
|
+
const res = await import_axios.default.get(`${baseURL}/v1beta/models?key=${apiKey}`);
|
|
81
81
|
return {
|
|
82
82
|
models: (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.models.map((model) => ({
|
|
83
83
|
id: model.name
|
|
@@ -122,11 +122,12 @@ class GoogleGenAIProvider extends import_provider.LLMProvider {
|
|
|
122
122
|
role
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
async
|
|
125
|
+
async convertToContent(ctx, attachment) {
|
|
126
|
+
var _a;
|
|
126
127
|
const fileManager = this.app.pm.get("file-manager");
|
|
127
128
|
const url = await fileManager.getFileURL(attachment);
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
if ((_a = attachment.mimetype) == null ? void 0 : _a.startsWith("image/")) {
|
|
130
|
+
const data = await (0, import_utils.encodeFile)(ctx, decodeURIComponent(url));
|
|
130
131
|
return {
|
|
131
132
|
placement: "contentBlocks",
|
|
132
133
|
content: {
|
|
@@ -137,6 +138,7 @@ class GoogleGenAIProvider extends import_provider.LLMProvider {
|
|
|
137
138
|
}
|
|
138
139
|
};
|
|
139
140
|
} else {
|
|
141
|
+
const data = await (0, import_utils.encodeFile)(ctx, decodeURIComponent(url));
|
|
140
142
|
return {
|
|
141
143
|
placement: "contentBlocks",
|
|
142
144
|
content: {
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { AIMessageChunk } from '@langchain/core/messages';
|
|
10
|
-
import { Context } from '@nocobase/actions';
|
|
11
10
|
import { Model } from '@nocobase/database';
|
|
12
11
|
import { LLMProvider } from '../provider';
|
|
13
12
|
import { LLMProviderMeta } from '../../manager/ai-manager';
|
|
13
|
+
import { CachedDocumentLoader } from '../../document-loader';
|
|
14
14
|
import { ReasoningChatOpenAI } from '../common/reasoning';
|
|
15
|
+
import { AttachmentModel } from '@nocobase/plugin-file-manager';
|
|
15
16
|
export declare class KimiProvider extends LLMProvider {
|
|
16
17
|
chatModel: ReasoningChatOpenAI;
|
|
17
18
|
private _documentLoader;
|
|
@@ -26,8 +27,7 @@ export declare class KimiProvider extends LLMProvider {
|
|
|
26
27
|
status: string;
|
|
27
28
|
content: string;
|
|
28
29
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
private get documentLoader();
|
|
30
|
+
protected isApiSupportedAttachment(attachment: AttachmentModel): boolean;
|
|
31
|
+
protected get documentLoader(): CachedDocumentLoader;
|
|
32
32
|
}
|
|
33
33
|
export declare const kimiProviderOptions: LLMProviderMeta;
|
|
@@ -40,7 +40,6 @@ __export(provider_exports, {
|
|
|
40
40
|
kimiProviderOptions: () => kimiProviderOptions
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(provider_exports);
|
|
43
|
-
var import_node_path = __toESM(require("node:path"));
|
|
44
43
|
var import_lodash = __toESM(require("lodash"));
|
|
45
44
|
var import_provider = require("../provider");
|
|
46
45
|
var import_ai_manager = require("../../manager/ai-manager");
|
|
@@ -101,33 +100,9 @@ class KimiProvider extends import_provider.LLMProvider {
|
|
|
101
100
|
}
|
|
102
101
|
return null;
|
|
103
102
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
const parsed = await this.documentLoader.load(attachment);
|
|
109
|
-
const safeFilename = attachment.filename ? import_node_path.default.basename(attachment.filename) : "document";
|
|
110
|
-
if (!parsed.supported) {
|
|
111
|
-
return {
|
|
112
|
-
placement: "system",
|
|
113
|
-
content: `File ${safeFilename} is not a supported document type for text parsing.`
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
if (parsed.text.length === 0) {
|
|
117
|
-
return {
|
|
118
|
-
placement: "system",
|
|
119
|
-
content: `The file provided by the user is an empty file, file name is "${safeFilename}"`
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
placement: "system",
|
|
124
|
-
content: `<parsed_document filename="${safeFilename}">
|
|
125
|
-
${parsed.text}
|
|
126
|
-
</parsed_document>`
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
get aiPlugin() {
|
|
130
|
-
return this.app.pm.get("ai");
|
|
103
|
+
isApiSupportedAttachment(attachment) {
|
|
104
|
+
var _a;
|
|
105
|
+
return ((_a = attachment.mimetype) == null ? void 0 : _a.startsWith("image/")) ?? false;
|
|
131
106
|
}
|
|
132
107
|
get documentLoader() {
|
|
133
108
|
var _a, _b;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
10
10
|
import { Model } from '@nocobase/database';
|
|
11
|
+
import { AttachmentModel } from '@nocobase/plugin-file-manager';
|
|
11
12
|
import { Application } from '@nocobase/server';
|
|
12
13
|
import { AIChatContext } from '../types/ai-chat-conversation.type';
|
|
13
14
|
import { EmbeddingsInterface } from '@langchain/core/embeddings';
|
|
@@ -15,6 +16,8 @@ import { AIMessageChunk } from '@langchain/core/messages';
|
|
|
15
16
|
import { Context } from '@nocobase/actions';
|
|
16
17
|
import '@langchain/core/utils/stream';
|
|
17
18
|
import { LLMResult } from '@langchain/core/outputs';
|
|
19
|
+
import { CachedDocumentLoader } from '../document-loader';
|
|
20
|
+
import PluginAIServer from '../plugin';
|
|
18
21
|
export type ParsedAttachmentResult = {
|
|
19
22
|
placement: string;
|
|
20
23
|
content: any;
|
|
@@ -30,7 +33,7 @@ export declare abstract class LLMProvider {
|
|
|
30
33
|
modelOptions: Record<string, any>;
|
|
31
34
|
chatModel: any;
|
|
32
35
|
abstract createModel(): BaseChatModel | any;
|
|
33
|
-
get baseURL():
|
|
36
|
+
get baseURL(): string | null;
|
|
34
37
|
constructor(opts: LLMProviderOptions);
|
|
35
38
|
prepareChain(context: AIChatContext): any;
|
|
36
39
|
invoke(context: AIChatContext, options?: any): Promise<any>;
|
|
@@ -48,7 +51,11 @@ export declare abstract class LLMProvider {
|
|
|
48
51
|
role: any;
|
|
49
52
|
};
|
|
50
53
|
parseResponseChunk(chunk: any): string;
|
|
51
|
-
parseAttachment(ctx: Context, attachment:
|
|
54
|
+
parseAttachment(ctx: Context, attachment: AttachmentModel): Promise<ParsedAttachmentResult>;
|
|
55
|
+
protected isApiSupportedAttachment(attachment: AttachmentModel): boolean;
|
|
56
|
+
protected isDocumentLoaderSupportedAttachment(attachment: AttachmentModel): boolean;
|
|
57
|
+
protected convertToContent(ctx: Context, attachment: any): Promise<ParsedAttachmentResult>;
|
|
58
|
+
protected loadDocument(_ctx: Context, attachment: any): Promise<any>;
|
|
52
59
|
getStructuredOutputOptions(structuredOutput: AIChatContext['structuredOutput']): any;
|
|
53
60
|
testFlight(): Promise<{
|
|
54
61
|
status: 'success' | 'error';
|
|
@@ -68,6 +75,8 @@ export declare abstract class LLMProvider {
|
|
|
68
75
|
};
|
|
69
76
|
parseResponseMetadata(output: LLMResult): any;
|
|
70
77
|
parseResponseError(err: any): any;
|
|
78
|
+
protected get documentLoader(): CachedDocumentLoader;
|
|
79
|
+
protected get aiPlugin(): PluginAIServer;
|
|
71
80
|
}
|
|
72
81
|
export interface EmbeddingProviderOptions {
|
|
73
82
|
app: Application;
|
|
@@ -45,6 +45,8 @@ var import_axios = __toESM(require("axios"));
|
|
|
45
45
|
var import_utils = require("../utils");
|
|
46
46
|
var import_langchain = require("langchain");
|
|
47
47
|
var import_stream = require("@langchain/core/utils/stream");
|
|
48
|
+
var import_document_loader = require("../document-loader");
|
|
49
|
+
var import_node_path = __toESM(require("node:path"));
|
|
48
50
|
class LLMProvider {
|
|
49
51
|
app;
|
|
50
52
|
serviceOptions;
|
|
@@ -126,6 +128,36 @@ class LLMProvider {
|
|
|
126
128
|
return (0, import_utils.stripToolCallTags)(chunk);
|
|
127
129
|
}
|
|
128
130
|
async parseAttachment(ctx, attachment) {
|
|
131
|
+
if (this.isApiSupportedAttachment(attachment)) {
|
|
132
|
+
return await this.convertToContent(ctx, attachment);
|
|
133
|
+
} else if (this.isDocumentLoaderSupportedAttachment(attachment)) {
|
|
134
|
+
return await this.loadDocument(ctx, attachment);
|
|
135
|
+
} else {
|
|
136
|
+
const safeFilename = attachment.filename ? import_node_path.default.basename(attachment.filename) : "document";
|
|
137
|
+
return {
|
|
138
|
+
placement: "system",
|
|
139
|
+
content: `The user has uploaded a ${attachment.mimetype} file (filename: ${safeFilename}). Please inform the user directly that you do not support parsing ${attachment.mimetype} content.`
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
isApiSupportedAttachment(attachment) {
|
|
144
|
+
const media = ["image/"];
|
|
145
|
+
const pdf = ["application/pdf"];
|
|
146
|
+
const supportedMedia = media.some((it) => {
|
|
147
|
+
var _a;
|
|
148
|
+
return (_a = attachment == null ? void 0 : attachment.mimetype) == null ? void 0 : _a.startsWith(it);
|
|
149
|
+
});
|
|
150
|
+
const supportedPdf = pdf.some((it) => {
|
|
151
|
+
var _a;
|
|
152
|
+
return (_a = attachment == null ? void 0 : attachment.mimetype) == null ? void 0 : _a.includes(it);
|
|
153
|
+
});
|
|
154
|
+
return supportedMedia || supportedPdf;
|
|
155
|
+
}
|
|
156
|
+
isDocumentLoaderSupportedAttachment(attachment) {
|
|
157
|
+
const ext = import_node_path.default.extname((attachment == null ? void 0 : attachment.filename) ?? "").toLocaleLowerCase();
|
|
158
|
+
return import_document_loader.SUPPORTED_DOCUMENT_EXTNAMES.includes(ext);
|
|
159
|
+
}
|
|
160
|
+
async convertToContent(ctx, attachment) {
|
|
129
161
|
const fileManager = this.app.pm.get("file-manager");
|
|
130
162
|
const url = await fileManager.getFileURL(attachment);
|
|
131
163
|
const data = await (0, import_utils.encodeFile)(ctx, decodeURIComponent(url));
|
|
@@ -153,6 +185,28 @@ class LLMProvider {
|
|
|
153
185
|
};
|
|
154
186
|
}
|
|
155
187
|
}
|
|
188
|
+
async loadDocument(_ctx, attachment) {
|
|
189
|
+
const safeFilename = attachment.filename ? import_node_path.default.basename(attachment.filename) : "document";
|
|
190
|
+
const parsed = await this.documentLoader.load(attachment);
|
|
191
|
+
if (!parsed.supported) {
|
|
192
|
+
return {
|
|
193
|
+
placement: "system",
|
|
194
|
+
content: `File ${safeFilename} is not a supported document type for text parsing.`
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
if (parsed.text.length === 0) {
|
|
198
|
+
return {
|
|
199
|
+
placement: "system",
|
|
200
|
+
content: `The file provided by the user is an empty file, file name is "${safeFilename}"`
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
placement: "system",
|
|
205
|
+
content: `<parsed_document filename="${safeFilename}">
|
|
206
|
+
${parsed.text}
|
|
207
|
+
</parsed_document>`
|
|
208
|
+
};
|
|
209
|
+
}
|
|
156
210
|
getStructuredOutputOptions(structuredOutput) {
|
|
157
211
|
const { responseFormat } = this.modelOptions || {};
|
|
158
212
|
const { schema, name, description, strict } = structuredOutput || {};
|
|
@@ -220,6 +274,12 @@ class LLMProvider {
|
|
|
220
274
|
parseResponseError(err) {
|
|
221
275
|
return (err == null ? void 0 : err.message) ?? "Unexpected LLM service error";
|
|
222
276
|
}
|
|
277
|
+
get documentLoader() {
|
|
278
|
+
return this.aiPlugin.documentLoaders.cached;
|
|
279
|
+
}
|
|
280
|
+
get aiPlugin() {
|
|
281
|
+
return this.app.pm.get("ai");
|
|
282
|
+
}
|
|
223
283
|
}
|
|
224
284
|
class EmbeddingProvider {
|
|
225
285
|
constructor(opts) {
|
|
@@ -137,8 +137,12 @@ class AIChatConversationImpl {
|
|
|
137
137
|
getSystemPrompt,
|
|
138
138
|
formatMessages
|
|
139
139
|
} = options ?? {};
|
|
140
|
-
|
|
141
|
-
const
|
|
140
|
+
let messages = userMessages ? await (formatMessages == null ? void 0 : formatMessages(userMessages)) ?? [] : void 0;
|
|
141
|
+
const additionSystemPrompt = messages == null ? void 0 : messages.filter((it) => it.role === "system").map((it) => it.content).join("\n");
|
|
142
|
+
messages = messages == null ? void 0 : messages.filter((it) => it.role !== "system");
|
|
143
|
+
const systemPrompt = `${await (getSystemPrompt == null ? void 0 : getSystemPrompt(userMessages ?? [])) ?? ""}
|
|
144
|
+
|
|
145
|
+
${additionSystemPrompt}`;
|
|
142
146
|
const chatContext = {
|
|
143
147
|
systemPrompt,
|
|
144
148
|
messages,
|
|
@@ -45,7 +45,6 @@ var import_data_organizer = __toESM(require("../ai-employees/built-in/data-organ
|
|
|
45
45
|
var import_insights_analyst = __toESM(require("../ai-employees/built-in/insights-analyst"));
|
|
46
46
|
var import_research_analyst = __toESM(require("../ai-employees/built-in/research-analyst"));
|
|
47
47
|
var import_translator = __toESM(require("../ai-employees/built-in/translator"));
|
|
48
|
-
var import_nocobase_assistant = __toESM(require("../ai-employees/built-in/nocobase-assistant"));
|
|
49
48
|
var import_email_assistant = __toESM(require("../ai-employees/built-in/email-assistant"));
|
|
50
49
|
var import_data_visualization = __toESM(require("../ai-employees/built-in/data-visualization"));
|
|
51
50
|
var import_lodash = __toESM(require("lodash"));
|
|
@@ -67,7 +66,7 @@ class BuiltInManager {
|
|
|
67
66
|
import_insights_analyst.default,
|
|
68
67
|
import_research_analyst.default,
|
|
69
68
|
import_translator.default,
|
|
70
|
-
|
|
69
|
+
// nocobaseAssistant,
|
|
71
70
|
import_email_assistant.default,
|
|
72
71
|
import_data_visualization.default
|
|
73
72
|
];
|
|
@@ -6,4 +6,9 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
import { Migration } from '@nocobase/server';
|
|
10
|
+
export default class extends Migration {
|
|
11
|
+
on: string;
|
|
12
|
+
appVersion: string;
|
|
13
|
+
up(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var remove_cole_ai_employee_exports = {};
|
|
28
|
+
__export(remove_cole_ai_employee_exports, {
|
|
29
|
+
default: () => remove_cole_ai_employee_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(remove_cole_ai_employee_exports);
|
|
32
|
+
var import_server = require("@nocobase/server");
|
|
33
|
+
class remove_cole_ai_employee_default extends import_server.Migration {
|
|
34
|
+
on = "afterSync";
|
|
35
|
+
appVersion = "<2.2.0";
|
|
36
|
+
async up() {
|
|
37
|
+
const repo = this.db.getRepository("aiEmployees");
|
|
38
|
+
if (!repo) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
await repo.destroy({
|
|
42
|
+
filter: {
|
|
43
|
+
username: "cole"
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
this.app.logger.info('Removed AI employee with username "cole"');
|
|
47
|
+
}
|
|
48
|
+
}
|
package/dist/server/utils.js
CHANGED
|
@@ -46,7 +46,6 @@ __export(utils_exports, {
|
|
|
46
46
|
module.exports = __toCommonJS(utils_exports);
|
|
47
47
|
var import_path = __toESM(require("path"));
|
|
48
48
|
var import_fs = __toESM(require("fs"));
|
|
49
|
-
var import_axios = __toESM(require("axios"));
|
|
50
49
|
var import_utils = require("@nocobase/utils");
|
|
51
50
|
function sendSSEError(ctx, error, errorName) {
|
|
52
51
|
const body = typeof error === "string" ? error : error.message || "Unknown error";
|
|
@@ -103,7 +102,9 @@ async function encodeFile(ctx, url) {
|
|
|
103
102
|
const referer = ctx.get("referer") || "";
|
|
104
103
|
const ua = ctx.get("user-agent") || "";
|
|
105
104
|
ctx.log.trace("llm message encode file", { url, referer, ua });
|
|
106
|
-
const response = await
|
|
105
|
+
const response = await (0, import_utils.serverRequest)({
|
|
106
|
+
method: "get",
|
|
107
|
+
url,
|
|
107
108
|
responseType: "arraybuffer",
|
|
108
109
|
headers: {
|
|
109
110
|
referer,
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Create AI employees with diverse skills to collaborate with humans, build systems, and handle business operations.",
|
|
7
7
|
"description.ru-RU": "Поддержка интеграции с AI-сервисами: предоставляются AI-узлы для рабочих процессов, расширяя возможности бизнес-обработки.",
|
|
8
8
|
"description.zh-CN": "创建各种技能的 AI 员工,与人类协同,搭建系统,处理业务。",
|
|
9
|
-
"version": "2.1.0-beta.
|
|
9
|
+
"version": "2.1.0-beta.15",
|
|
10
10
|
"main": "dist/server/index.js",
|
|
11
11
|
"homepage": "https://docs.nocobase.com/handbook/action-ai",
|
|
12
12
|
"homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/action-ai",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"keywords": [
|
|
60
60
|
"AI"
|
|
61
61
|
],
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "dc1aceea6357e6ab149976c2a236fc4b6bee1370"
|
|
63
63
|
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var import_pdf = require("@langchain/community/document_loaders/fs/pdf");
|
|
11
|
-
var import_pptx = require("@langchain/community/document_loaders/fs/pptx");
|
|
12
|
-
var import_docx = require("@langchain/community/document_loaders/fs/docx");
|
|
13
|
-
var import_node_worker_threads = require("node:worker_threads");
|
|
14
|
-
var import_text = require("./vendor/langchain/document_loaders/fs/text");
|
|
15
|
-
var _a;
|
|
16
|
-
const loadPdf = async (blob) => {
|
|
17
|
-
const loader = new import_pdf.PDFLoader(blob);
|
|
18
|
-
return loader.load();
|
|
19
|
-
};
|
|
20
|
-
const loadDoc = async (blob, type) => {
|
|
21
|
-
const loader = new import_docx.DocxLoader(blob, { type });
|
|
22
|
-
return loader.load();
|
|
23
|
-
};
|
|
24
|
-
const loadPpt = async (blob) => {
|
|
25
|
-
const loader = new import_pptx.PPTXLoader(blob);
|
|
26
|
-
return loader.load();
|
|
27
|
-
};
|
|
28
|
-
const loadTxt = async (blob) => {
|
|
29
|
-
const loader = new import_text.TextLoader(blob);
|
|
30
|
-
return loader.load();
|
|
31
|
-
};
|
|
32
|
-
const loadByExtname = async (payload) => {
|
|
33
|
-
const blob = new Blob([Buffer.from(payload.buffer)], { type: payload.mimeType ?? "application/octet-stream" });
|
|
34
|
-
switch (payload.extname) {
|
|
35
|
-
case ".pdf":
|
|
36
|
-
return loadPdf(blob);
|
|
37
|
-
case ".ppt":
|
|
38
|
-
case ".pptx":
|
|
39
|
-
return loadPpt(blob);
|
|
40
|
-
case ".doc":
|
|
41
|
-
return loadDoc(blob, "doc");
|
|
42
|
-
case ".docx":
|
|
43
|
-
return loadDoc(blob, "docx");
|
|
44
|
-
case ".txt":
|
|
45
|
-
return loadTxt(blob);
|
|
46
|
-
default:
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
(_a = import_node_worker_threads.parentPort) == null ? void 0 : _a.on("message", async (payload) => {
|
|
51
|
-
var _a2;
|
|
52
|
-
try {
|
|
53
|
-
const documents = await loadByExtname(payload);
|
|
54
|
-
const response = {
|
|
55
|
-
documents: documents.map((doc) => ({
|
|
56
|
-
pageContent: doc.pageContent,
|
|
57
|
-
metadata: doc.metadata,
|
|
58
|
-
id: doc.id
|
|
59
|
-
}))
|
|
60
|
-
};
|
|
61
|
-
import_node_worker_threads.parentPort.postMessage(response);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
const response = {
|
|
64
|
-
error: String((error == null ? void 0 : error.stack) || error)
|
|
65
|
-
};
|
|
66
|
-
(_a2 = import_node_worker_threads.parentPort) == null ? void 0 : _a2.postMessage(response);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
/// <reference types="node" />
|
|
10
|
-
import { Document } from '@langchain/core/documents';
|
|
11
|
-
import { BaseDocumentLoader } from '@langchain/core/document_loaders/base';
|
|
12
|
-
export declare class TextLoader extends BaseDocumentLoader {
|
|
13
|
-
private filePathOrBlob;
|
|
14
|
-
constructor(filePathOrBlob: any);
|
|
15
|
-
parse(raw: any): Promise<any[]>;
|
|
16
|
-
load(): Promise<Document<any>[]>;
|
|
17
|
-
static imports(): Promise<{
|
|
18
|
-
readFile: typeof import("fs/promises").readFile;
|
|
19
|
-
}>;
|
|
20
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var text_exports = {};
|
|
38
|
-
__export(text_exports, {
|
|
39
|
-
TextLoader: () => TextLoader
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(text_exports);
|
|
42
|
-
var import_documents = require("@langchain/core/documents");
|
|
43
|
-
var import_env = require("@langchain/core/utils/env");
|
|
44
|
-
var import_base = require("@langchain/core/document_loaders/base");
|
|
45
|
-
class TextLoader extends import_base.BaseDocumentLoader {
|
|
46
|
-
filePathOrBlob;
|
|
47
|
-
constructor(filePathOrBlob) {
|
|
48
|
-
super();
|
|
49
|
-
this.filePathOrBlob = filePathOrBlob;
|
|
50
|
-
}
|
|
51
|
-
async parse(raw) {
|
|
52
|
-
return [raw];
|
|
53
|
-
}
|
|
54
|
-
async load() {
|
|
55
|
-
let text;
|
|
56
|
-
let metadata;
|
|
57
|
-
if (typeof this.filePathOrBlob === "string") {
|
|
58
|
-
const { readFile } = await TextLoader.imports();
|
|
59
|
-
text = await readFile(this.filePathOrBlob, "utf8");
|
|
60
|
-
metadata = { source: this.filePathOrBlob };
|
|
61
|
-
} else {
|
|
62
|
-
text = await this.filePathOrBlob.text();
|
|
63
|
-
metadata = { source: "blob", blobType: this.filePathOrBlob.type };
|
|
64
|
-
}
|
|
65
|
-
const parsed = await this.parse(text);
|
|
66
|
-
parsed.forEach((pageContent, i) => {
|
|
67
|
-
if (typeof pageContent !== "string") {
|
|
68
|
-
throw new Error(`Expected string, at position ${i} got ${typeof pageContent}`);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return parsed.map(
|
|
72
|
-
(pageContent, i) => new import_documents.Document({
|
|
73
|
-
pageContent,
|
|
74
|
-
metadata: parsed.length === 1 ? metadata : {
|
|
75
|
-
...metadata,
|
|
76
|
-
line: i + 1
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
static async imports() {
|
|
82
|
-
try {
|
|
83
|
-
const { readFile } = await import("node:fs/promises");
|
|
84
|
-
return { readFile };
|
|
85
|
-
} catch (e) {
|
|
86
|
-
console.error(e);
|
|
87
|
-
throw new Error(
|
|
88
|
-
`Failed to load fs/promises. TextLoader available only on environment 'node'. It appears you are running environment '${(0, import_env.getEnv)()}'. See https://<link to docs> for alternatives.`
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
-
0 && (module.exports = {
|
|
95
|
-
TextLoader
|
|
96
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|