plugin-knowledge-base 1.0.0 → 1.0.1
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/README.md +1 -1
- package/dist/externalVersion.js +6 -6
- package/dist/server/pipeline/vectorization.js +18 -11
- package/dist/server/resources/ai-knowledge-base-documents.js +2 -2
- package/dist/server/resources/ai-vector-databases.js +0 -6
- package/package.json +1 -1
- package/dist/node_modules/@langchain/textsplitters/LICENSE +0 -21
- package/dist/node_modules/@langchain/textsplitters/dist/_virtual/rolldown_runtime.cjs +0 -25
- package/dist/node_modules/@langchain/textsplitters/dist/index.cjs +0 -7
- package/dist/node_modules/@langchain/textsplitters/dist/index.d.cts +0 -2
- package/dist/node_modules/@langchain/textsplitters/dist/index.d.ts +0 -2
- package/dist/node_modules/@langchain/textsplitters/dist/index.js +0 -3
- package/dist/node_modules/@langchain/textsplitters/dist/text_splitter.cjs +0 -539
- package/dist/node_modules/@langchain/textsplitters/dist/text_splitter.d.cts +0 -84
- package/dist/node_modules/@langchain/textsplitters/dist/text_splitter.d.ts +0 -84
- package/dist/node_modules/@langchain/textsplitters/dist/text_splitter.js +0 -532
- package/dist/node_modules/@langchain/textsplitters/package.json +0 -1
package/README.md
CHANGED
package/dist/externalVersion.js
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
|
-
"@nocobase/client": "2.0.
|
|
13
|
-
"@nocobase/utils": "2.0.
|
|
14
|
-
"@nocobase/server": "2.0.
|
|
15
|
-
"@nocobase/plugin-ai": "2.0.
|
|
12
|
+
"@nocobase/client": "2.0.15",
|
|
13
|
+
"@nocobase/utils": "2.0.15",
|
|
14
|
+
"@nocobase/server": "2.0.15",
|
|
15
|
+
"@nocobase/plugin-ai": "2.0.15",
|
|
16
16
|
"antd": "5.24.2",
|
|
17
17
|
"@ant-design/icons": "5.6.1",
|
|
18
|
-
"@nocobase/database": "2.0.
|
|
18
|
+
"@nocobase/database": "2.0.15",
|
|
19
19
|
"@langchain/core": "1.1.24",
|
|
20
|
-
"@nocobase/actions": "2.0.
|
|
20
|
+
"@nocobase/actions": "2.0.15",
|
|
21
21
|
"pg": "8.20.0"
|
|
22
22
|
};
|
|
@@ -50,19 +50,26 @@ class VectorizationPipeline {
|
|
|
50
50
|
}
|
|
51
51
|
const doc = docRecord.toJSON();
|
|
52
52
|
const file = doc.file;
|
|
53
|
+
const textContent = doc.textContent;
|
|
53
54
|
const knowledgeBase = doc.knowledgeBase;
|
|
54
|
-
if (!file) {
|
|
55
|
-
throw new Error("Document has no associated file");
|
|
55
|
+
if (!file && !textContent) {
|
|
56
|
+
throw new Error("Document has no associated file or text content");
|
|
56
57
|
}
|
|
57
58
|
if (!(knowledgeBase == null ? void 0 : knowledgeBase.vectorStore)) {
|
|
58
59
|
throw new Error("Knowledge base has no vector store configured");
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
let rawText;
|
|
62
|
+
if (textContent) {
|
|
63
|
+
rawText = textContent;
|
|
64
|
+
} else {
|
|
65
|
+
const aiPlugin = this.plugin.aiPlugin;
|
|
66
|
+
const parseResult = await aiPlugin.documentLoaders.cached.load(file);
|
|
67
|
+
if (!parseResult.supported) {
|
|
68
|
+
throw new Error(`File type not supported: ${file.filename}`);
|
|
69
|
+
}
|
|
70
|
+
rawText = parseResult.text || "";
|
|
64
71
|
}
|
|
65
|
-
if (!
|
|
72
|
+
if (!rawText || rawText.trim().length === 0) {
|
|
66
73
|
await docRepo.update({
|
|
67
74
|
filter: { id: documentId },
|
|
68
75
|
values: { status: "success", chunkCount: 0 }
|
|
@@ -70,11 +77,11 @@ class VectorizationPipeline {
|
|
|
70
77
|
return { success: true, chunkCount: 0 };
|
|
71
78
|
}
|
|
72
79
|
const splitter = new import_text_splitter.DocumentTextSplitter(options);
|
|
73
|
-
const chunks = await splitter.splitText(
|
|
80
|
+
const chunks = await splitter.splitText(rawText, {
|
|
74
81
|
knowledgeBaseId: knowledgeBase.id,
|
|
75
82
|
knowledgeBaseOuterId: knowledgeBase.id,
|
|
76
83
|
documentId,
|
|
77
|
-
source: file.filename,
|
|
84
|
+
source: (file == null ? void 0 : file.filename) ?? doc.filename ?? "pasted-text",
|
|
78
85
|
// Permission metadata for vector-level filtering
|
|
79
86
|
userId: doc.uploadedById ?? null,
|
|
80
87
|
accessLevel: knowledgeBase.accessLevel ?? "PUBLIC"
|
|
@@ -95,7 +102,7 @@ class VectorizationPipeline {
|
|
|
95
102
|
throw new Error(`LLM service "${vectorStore.llmService}" not found`);
|
|
96
103
|
}
|
|
97
104
|
const llmService = llmServiceRecord.toJSON();
|
|
98
|
-
const providerMeta = aiPlugin.aiManager.llmProviders.get(llmService.provider);
|
|
105
|
+
const providerMeta = this.plugin.aiPlugin.aiManager.llmProviders.get(llmService.provider);
|
|
99
106
|
if (!(providerMeta == null ? void 0 : providerMeta.embedding)) {
|
|
100
107
|
throw new Error(
|
|
101
108
|
`LLM provider "${llmService.provider}" does not support embedding`
|
|
@@ -107,7 +114,7 @@ class VectorizationPipeline {
|
|
|
107
114
|
modelOptions: { model: vectorStore.embeddingModel }
|
|
108
115
|
});
|
|
109
116
|
const embeddings = embeddingProvider.createEmbedding();
|
|
110
|
-
const vdbProvider = aiPlugin.features.vectorDatabaseProvider;
|
|
117
|
+
const vdbProvider = this.plugin.aiPlugin.features.vectorDatabaseProvider;
|
|
111
118
|
const vectorStoreInstance = await vdbProvider.createVectorStore(
|
|
112
119
|
vectorDatabase.provider,
|
|
113
120
|
embeddings,
|
|
@@ -98,7 +98,7 @@ var ai_knowledge_base_documents_default = {
|
|
|
98
98
|
if (values.knowledgeBaseId) doc.set("knowledgeBaseId", values.knowledgeBaseId);
|
|
99
99
|
if (values.fileId) doc.set("fileId", values.fileId);
|
|
100
100
|
}
|
|
101
|
-
const plugin = ctx.app.pm.get("
|
|
101
|
+
const plugin = ctx.app.pm.get("plugin-knowledge-base");
|
|
102
102
|
if (plugin == null ? void 0 : plugin.vectorizationPipeline) {
|
|
103
103
|
plugin.vectorizationPipeline.processDocument(doc.id).catch((err) => {
|
|
104
104
|
ctx.logger.error(`Vectorization failed for document ${doc.id}:`, err);
|
|
@@ -121,7 +121,7 @@ var ai_knowledge_base_documents_default = {
|
|
|
121
121
|
filterByTk,
|
|
122
122
|
values: { status: "pending", error: null, chunkCount: 0 }
|
|
123
123
|
});
|
|
124
|
-
const plugin = ctx.app.pm.get("
|
|
124
|
+
const plugin = ctx.app.pm.get("plugin-knowledge-base");
|
|
125
125
|
if (plugin == null ? void 0 : plugin.vectorizationPipeline) {
|
|
126
126
|
plugin.vectorizationPipeline.processDocument(filterByTk).catch((err) => {
|
|
127
127
|
ctx.logger.error(`Re-vectorization failed for document ${filterByTk}:`, err);
|
|
@@ -84,12 +84,6 @@ var ai_vector_databases_default = {
|
|
|
84
84
|
await next();
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
const kbPlugin = ctx.app.pm.get("@nocobase/plugin-knowledge-base");
|
|
88
|
-
if (!kbPlugin) {
|
|
89
|
-
ctx.body = { success: false, error: "Knowledge base plugin not found" };
|
|
90
|
-
await next();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
87
|
try {
|
|
94
88
|
const { Client } = require("pg");
|
|
95
89
|
const client = new Client({
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Provides Knowledge Base management, Vector Store, Vector Database (PGVector), and RAG retrieval capabilities for AI Employees.",
|
|
7
7
|
"description.vi-VN": "Cung cấp quản lý Cơ sở tri thức, Vector Store, Vector Database (PGVector), và khả năng truy xuất RAG cho nhân viên AI.",
|
|
8
8
|
"description.zh-CN": "为 AI 员工提供知识库管理、向量存储、向量数据库 (PGVector) 和 RAG 检索功能。",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.1",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"files": [
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) LangChain, Inc.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
|
|
25
|
-
exports.__toESM = __toESM;
|