@shenghuabi/knowledge 1.0.21
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/embedding/embedding.service.d.ts +4 -0
- package/embedding/index.d.ts +2 -0
- package/embedding/type.d.ts +12 -0
- package/embedding.mjs +61 -0
- package/embedding.mjs.map +7 -0
- package/file-parser/const.d.ts +20 -0
- package/file-parser/dict/dict-format/dsl/dsl-parse.service.d.ts +6 -0
- package/file-parser/dict/dict-format/dsl/dsl.format.d.ts +1 -0
- package/file-parser/dict/dict-format/mdict-parse.service.d.ts +20 -0
- package/file-parser/dict/dict-format/stardict-parse.service.d.ts +12 -0
- package/file-parser/dict/dict-format/yaml-parse.service.d.ts +25 -0
- package/file-parser/dict/dict.service.d.ts +10 -0
- package/file-parser/dict/index.d.ts +2 -0
- package/file-parser/dict/type.d.ts +24 -0
- package/file-parser/document-file-parser.service.d.ts +15 -0
- package/file-parser/document-loader/pdf-img.loader.d.ts +8 -0
- package/file-parser/document-loader/xlsx.loader.d.ts +6 -0
- package/file-parser/file-parser.service.d.ts +13 -0
- package/file-parser/index.d.ts +6 -0
- package/file-parser/text-analyse.d.ts +1 -0
- package/file-parser/text-parser.d.ts +3 -0
- package/file-parser/vl-parser/markdown.parser.d.ts +8 -0
- package/file-parser.mjs +850 -0
- package/file-parser.mjs.map +7 -0
- package/image/convert.d.ts +25 -0
- package/image/extract.d.ts +2 -0
- package/image/image-metadata.d.ts +2 -0
- package/image/index.d.ts +3 -0
- package/image.mjs +134 -0
- package/image.mjs.map +7 -0
- package/knowledge/article/article.knowledge.service.d.ts +53 -0
- package/knowledge/article/define/config.d.ts +60 -0
- package/knowledge/article/define/index.d.ts +2 -0
- package/knowledge/article/define/payload.d.ts +16 -0
- package/knowledge/article/index.d.ts +2 -0
- package/knowledge/common/common.knowledge.service.d.ts +240 -0
- package/knowledge/common/define/base.d.ts +7 -0
- package/knowledge/common/define/chunk.d.ts +14 -0
- package/knowledge/common/define/embedding.d.ts +5 -0
- package/knowledge/common/define/index.d.ts +3 -0
- package/knowledge/common/index.d.ts +1 -0
- package/knowledge/common/query.d.ts +7 -0
- package/knowledge/const.d.ts +95 -0
- package/knowledge/define/index.d.ts +245 -0
- package/knowledge/dict/define/config.d.ts +68 -0
- package/knowledge/dict/define/index.d.ts +1 -0
- package/knowledge/dict/dict.knowledge.service.d.ts +67 -0
- package/knowledge/graph/const.d.ts +20 -0
- package/knowledge/graph/define/config.d.ts +169 -0
- package/knowledge/graph/define/define.d.ts +402 -0
- package/knowledge/graph/define/index.d.ts +2 -0
- package/knowledge/graph/define/query.d.ts +14 -0
- package/knowledge/graph/graph.handle.service.d.ts +28 -0
- package/knowledge/graph/graph.knowledge.service.d.ts +40 -0
- package/knowledge/graph/graph.local.service.d.ts +85 -0
- package/knowledge/graph/graph.query.service.d.ts +160 -0
- package/knowledge/graph/graph.service.d.ts +24 -0
- package/knowledge/graph/graph.util.service.d.ts +31 -0
- package/knowledge/graph/type.d.ts +11 -0
- package/knowledge/graph/util/format-attr.d.ts +48 -0
- package/knowledge/graph/util/graph-util.d.ts +5 -0
- package/knowledge/graph/util.d.ts +1 -0
- package/knowledge/graph/vecotr-format.d.ts +11 -0
- package/knowledge/index.d.ts +17 -0
- package/knowledge/knowledge.manager.service.d.ts +42 -0
- package/knowledge/knowledge.util.service.d.ts +21 -0
- package/knowledge/normal/define/config.d.ts +60 -0
- package/knowledge/normal/define/index.d.ts +1 -0
- package/knowledge/normal/normal.knowledge.service.d.ts +49 -0
- package/knowledge/template.format.d.ts +6 -0
- package/knowledge/type.d.ts +28 -0
- package/knowledge.mjs +2856 -0
- package/knowledge.mjs.map +7 -0
- package/ocr/FileUtils.d.ts +4 -0
- package/ocr/ImageRaw.d.ts +11 -0
- package/ocr/index.d.ts +2 -0
- package/ocr/model-config.d.ts +8 -0
- package/ocr/ocr.d.ts +29 -0
- package/ocr.mjs +351 -0
- package/ocr.mjs.map +7 -0
- package/package.json +105 -0
- package/qdrant/index.d.ts +3 -0
- package/qdrant/qdrant-client.service.d.ts +396 -0
- package/qdrant/qdrant-server.service.d.ts +21 -0
- package/qdrant/type.d.ts +18 -0
- package/qdrant/util.d.ts +1 -0
- package/qdrant.mjs +274 -0
- package/qdrant.mjs.map +7 -0
- package/util/batch-queue.d.ts +6 -0
- package/util/cache-queue.d.ts +10 -0
- package/util/clone.d.ts +1 -0
- package/util/embedding-queue.d.ts +3 -0
- package/util/get-hash.d.ts +2 -0
- package/util/html-to-text/index.d.ts +5 -0
- package/util/index.d.ts +10 -0
- package/util/is-truthy.d.ts +1 -0
- package/util/log.service.d.ts +6 -0
- package/util/promise.d.ts +5 -0
- package/util/type.d.ts +1 -0
- package/util/uniq-object-key.d.ts +1 -0
- package/util.mjs +219 -0
- package/util.mjs.map +7 -0
- package/worker/custom-cache.d.ts +28 -0
- package/worker/ocr/index.d.ts +17 -0
- package/worker/ocr.mjs +75 -0
- package/worker/ocr.mjs.map +7 -0
- package/worker/reranker.mjs +180 -0
- package/worker/reranker.mjs.map +7 -0
- package/worker/set-transformers-config.d.ts +19 -0
- package/worker/text2vec/index.d.ts +9 -0
- package/worker/text2vec.mjs +194 -0
- package/worker/text2vec.mjs.map +7 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
/** 提取的实体 */
|
|
3
|
+
export declare const ENTITY_DEFINE: v.ObjectSchema<{
|
|
4
|
+
readonly name: v.StringSchema<undefined>;
|
|
5
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
6
|
+
/** 实体类型 */
|
|
7
|
+
readonly type: v.StringSchema<undefined>;
|
|
8
|
+
}, undefined>;
|
|
9
|
+
/** 联系 */
|
|
10
|
+
export declare const ENTITY_RELATION_DEFINE: v.ObjectSchema<{
|
|
11
|
+
readonly source: v.StringSchema<undefined>;
|
|
12
|
+
readonly target: v.StringSchema<undefined>;
|
|
13
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
14
|
+
readonly strength: v.OptionalSchema<v.NumberSchema<undefined>, 5>;
|
|
15
|
+
readonly keywords: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>]>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
|
|
16
|
+
}, undefined>;
|
|
17
|
+
/** 提取定义 */
|
|
18
|
+
export declare const EntityExtraDefine: v.ObjectSchema<{
|
|
19
|
+
readonly entity: v.SchemaWithPipe<readonly [v.NullishSchema<v.ArraySchema<v.ObjectSchema<{
|
|
20
|
+
readonly name: v.StringSchema<undefined>;
|
|
21
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
22
|
+
/** 实体类型 */
|
|
23
|
+
readonly type: v.StringSchema<undefined>;
|
|
24
|
+
}, undefined>, undefined>, readonly []>, v.TransformAction<{
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
type: string;
|
|
28
|
+
}[], {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
type: string;
|
|
32
|
+
}[]>]>;
|
|
33
|
+
readonly entity_relation: v.SchemaWithPipe<readonly [v.NullishSchema<v.ArraySchema<v.ObjectSchema<{
|
|
34
|
+
readonly source: v.StringSchema<undefined>;
|
|
35
|
+
readonly target: v.StringSchema<undefined>;
|
|
36
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
37
|
+
readonly strength: v.OptionalSchema<v.NumberSchema<undefined>, 5>;
|
|
38
|
+
readonly keywords: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>]>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
|
|
39
|
+
}, undefined>, undefined>, readonly []>, v.TransformAction<{
|
|
40
|
+
source: string;
|
|
41
|
+
target: string;
|
|
42
|
+
description: string;
|
|
43
|
+
strength: number;
|
|
44
|
+
keywords?: string[] | undefined;
|
|
45
|
+
}[], {
|
|
46
|
+
source: string;
|
|
47
|
+
target: string;
|
|
48
|
+
description: string;
|
|
49
|
+
strength: number;
|
|
50
|
+
keywords?: string[] | undefined;
|
|
51
|
+
}[]>]>;
|
|
52
|
+
readonly keyword: v.SchemaWithPipe<readonly [v.NullishSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, readonly []>, v.TransformAction<string[], string[]>]>;
|
|
53
|
+
}, undefined>;
|
|
54
|
+
export type EntityExtractType = v.InferOutput<typeof EntityExtraDefine>;
|
|
55
|
+
export type NodeExtract = EntityExtractType['entity'][number];
|
|
56
|
+
/** 完整的graph节点项 */
|
|
57
|
+
export declare const NodePayloadDefine: v.ObjectSchema<{
|
|
58
|
+
readonly kind: v.OptionalSchema<v.LiteralSchema<"node", undefined>, "node">;
|
|
59
|
+
readonly id: v.StringSchema<undefined>;
|
|
60
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
61
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
62
|
+
readonly name: v.StringSchema<undefined>;
|
|
63
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
64
|
+
/** 实体类型 */
|
|
65
|
+
readonly type: v.StringSchema<undefined>;
|
|
66
|
+
}, undefined>;
|
|
67
|
+
export declare const NodeItemDefine: v.SchemaWithPipe<readonly [Omit<v.ObjectSchema<{
|
|
68
|
+
readonly kind: v.OptionalSchema<v.LiteralSchema<"node", undefined>, "node">;
|
|
69
|
+
readonly id: v.StringSchema<undefined>;
|
|
70
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
71
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
72
|
+
readonly name: v.StringSchema<undefined>;
|
|
73
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
74
|
+
/** 实体类型 */
|
|
75
|
+
readonly type: v.StringSchema<undefined>;
|
|
76
|
+
}, undefined>, "entries" | "~types" | "~run" | "~standard"> & {
|
|
77
|
+
readonly entries: Omit<{
|
|
78
|
+
readonly kind: v.OptionalSchema<v.LiteralSchema<"node", undefined>, "node">;
|
|
79
|
+
readonly id: v.StringSchema<undefined>;
|
|
80
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
81
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
82
|
+
readonly name: v.StringSchema<undefined>;
|
|
83
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
84
|
+
/** 实体类型 */
|
|
85
|
+
readonly type: v.StringSchema<undefined>;
|
|
86
|
+
}, "kind">;
|
|
87
|
+
readonly '~standard': v.StandardProps<{
|
|
88
|
+
name: string;
|
|
89
|
+
fileName: string;
|
|
90
|
+
type: string;
|
|
91
|
+
id: string;
|
|
92
|
+
description?: string | undefined;
|
|
93
|
+
chunkId: string;
|
|
94
|
+
}, {
|
|
95
|
+
name: string;
|
|
96
|
+
fileName: string;
|
|
97
|
+
type: string;
|
|
98
|
+
id: string;
|
|
99
|
+
description: string;
|
|
100
|
+
chunkId: string;
|
|
101
|
+
}>;
|
|
102
|
+
readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
103
|
+
name: string;
|
|
104
|
+
fileName: string;
|
|
105
|
+
type: string;
|
|
106
|
+
id: string;
|
|
107
|
+
description: string;
|
|
108
|
+
chunkId: string;
|
|
109
|
+
}, v.ObjectIssue | v.StringIssue>;
|
|
110
|
+
readonly '~types'?: {
|
|
111
|
+
readonly input: {
|
|
112
|
+
name: string;
|
|
113
|
+
fileName: string;
|
|
114
|
+
type: string;
|
|
115
|
+
id: string;
|
|
116
|
+
description?: string | undefined;
|
|
117
|
+
chunkId: string;
|
|
118
|
+
};
|
|
119
|
+
readonly output: {
|
|
120
|
+
name: string;
|
|
121
|
+
fileName: string;
|
|
122
|
+
type: string;
|
|
123
|
+
id: string;
|
|
124
|
+
description: string;
|
|
125
|
+
chunkId: string;
|
|
126
|
+
};
|
|
127
|
+
readonly issue: v.ObjectIssue | v.StringIssue;
|
|
128
|
+
} | undefined;
|
|
129
|
+
}, v.TransformAction<{
|
|
130
|
+
name: string;
|
|
131
|
+
fileName: string;
|
|
132
|
+
type: string;
|
|
133
|
+
id: string;
|
|
134
|
+
description: string;
|
|
135
|
+
chunkId: string;
|
|
136
|
+
}, {
|
|
137
|
+
kind: "node";
|
|
138
|
+
name: string;
|
|
139
|
+
fileName: string;
|
|
140
|
+
type: string;
|
|
141
|
+
id: string;
|
|
142
|
+
description: string;
|
|
143
|
+
chunkId: string;
|
|
144
|
+
}>]>;
|
|
145
|
+
export declare const NodePayloadNewDefine: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
146
|
+
readonly embeddingChunk: v.StringSchema<undefined>;
|
|
147
|
+
readonly name: v.StringSchema<undefined>;
|
|
148
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
149
|
+
readonly kind: v.OptionalSchema<v.LiteralSchema<"node", undefined>, "node">;
|
|
150
|
+
readonly type: v.StringSchema<undefined>;
|
|
151
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
152
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
153
|
+
}, undefined>]>;
|
|
154
|
+
export declare const NodeItemNewDefine: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
155
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, () => string>;
|
|
156
|
+
readonly name: v.StringSchema<undefined>;
|
|
157
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
158
|
+
readonly type: v.StringSchema<undefined>;
|
|
159
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
160
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
161
|
+
}, undefined>, v.TransformAction<{
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
fileName: string;
|
|
165
|
+
type: string;
|
|
166
|
+
description: string;
|
|
167
|
+
chunkId: string;
|
|
168
|
+
}, {
|
|
169
|
+
kind: "node";
|
|
170
|
+
id: string;
|
|
171
|
+
name: string;
|
|
172
|
+
fileName: string;
|
|
173
|
+
type: string;
|
|
174
|
+
description: string;
|
|
175
|
+
chunkId: string;
|
|
176
|
+
}>]>;
|
|
177
|
+
export type NodeItemType = v.InferInput<typeof NodeItemDefine>;
|
|
178
|
+
export type NodeItemNewType = v.InferInput<typeof NodeItemNewDefine>;
|
|
179
|
+
export type EdgeExtract = EntityExtractType['entity_relation'][number];
|
|
180
|
+
export declare const EdgePayloadDefine: v.ObjectSchema<{
|
|
181
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
182
|
+
readonly kind: v.OptionalSchema<v.LiteralSchema<"edge", undefined>, "edge">;
|
|
183
|
+
readonly name: v.StringSchema<undefined>;
|
|
184
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
185
|
+
readonly id: v.StringSchema<undefined>;
|
|
186
|
+
readonly source: v.StringSchema<undefined>;
|
|
187
|
+
readonly target: v.StringSchema<undefined>;
|
|
188
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
189
|
+
readonly strength: v.OptionalSchema<v.NumberSchema<undefined>, 5>;
|
|
190
|
+
readonly keywords: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>]>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
|
|
191
|
+
}, undefined>;
|
|
192
|
+
export declare const EdgeItemDefine: v.SchemaWithPipe<readonly [Omit<v.ObjectSchema<{
|
|
193
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
194
|
+
readonly kind: v.OptionalSchema<v.LiteralSchema<"edge", undefined>, "edge">;
|
|
195
|
+
readonly name: v.StringSchema<undefined>;
|
|
196
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
197
|
+
readonly id: v.StringSchema<undefined>;
|
|
198
|
+
readonly source: v.StringSchema<undefined>;
|
|
199
|
+
readonly target: v.StringSchema<undefined>;
|
|
200
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
201
|
+
readonly strength: v.OptionalSchema<v.NumberSchema<undefined>, 5>;
|
|
202
|
+
readonly keywords: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>]>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
|
|
203
|
+
}, undefined>, "entries" | "~types" | "~run" | "~standard"> & {
|
|
204
|
+
readonly entries: Omit<{
|
|
205
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
206
|
+
readonly kind: v.OptionalSchema<v.LiteralSchema<"edge", undefined>, "edge">;
|
|
207
|
+
readonly name: v.StringSchema<undefined>;
|
|
208
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
209
|
+
readonly id: v.StringSchema<undefined>;
|
|
210
|
+
readonly source: v.StringSchema<undefined>;
|
|
211
|
+
readonly target: v.StringSchema<undefined>;
|
|
212
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
213
|
+
readonly strength: v.OptionalSchema<v.NumberSchema<undefined>, 5>;
|
|
214
|
+
readonly keywords: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>]>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
|
|
215
|
+
}, "name" | "kind">;
|
|
216
|
+
readonly '~standard': v.StandardProps<{
|
|
217
|
+
fileName: string;
|
|
218
|
+
id: string;
|
|
219
|
+
description?: string | undefined;
|
|
220
|
+
strength?: number | undefined;
|
|
221
|
+
keywords?: string | string[] | undefined;
|
|
222
|
+
source: string;
|
|
223
|
+
target: string;
|
|
224
|
+
chunkId: string;
|
|
225
|
+
}, {
|
|
226
|
+
fileName: string;
|
|
227
|
+
id: string;
|
|
228
|
+
description: string;
|
|
229
|
+
strength: number;
|
|
230
|
+
keywords?: string[] | undefined;
|
|
231
|
+
source: string;
|
|
232
|
+
target: string;
|
|
233
|
+
chunkId: string;
|
|
234
|
+
}>;
|
|
235
|
+
readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
236
|
+
fileName: string;
|
|
237
|
+
id: string;
|
|
238
|
+
description: string;
|
|
239
|
+
strength: number;
|
|
240
|
+
keywords?: string[] | undefined;
|
|
241
|
+
source: string;
|
|
242
|
+
target: string;
|
|
243
|
+
chunkId: string;
|
|
244
|
+
}, v.ArrayIssue | v.ObjectIssue | v.StringIssue | v.NumberIssue | v.UnionIssue<v.ArrayIssue | v.StringIssue>>;
|
|
245
|
+
readonly '~types'?: {
|
|
246
|
+
readonly input: {
|
|
247
|
+
fileName: string;
|
|
248
|
+
id: string;
|
|
249
|
+
description?: string | undefined;
|
|
250
|
+
strength?: number | undefined;
|
|
251
|
+
keywords?: string | string[] | undefined;
|
|
252
|
+
source: string;
|
|
253
|
+
target: string;
|
|
254
|
+
chunkId: string;
|
|
255
|
+
};
|
|
256
|
+
readonly output: {
|
|
257
|
+
fileName: string;
|
|
258
|
+
id: string;
|
|
259
|
+
description: string;
|
|
260
|
+
strength: number;
|
|
261
|
+
keywords?: string[] | undefined;
|
|
262
|
+
source: string;
|
|
263
|
+
target: string;
|
|
264
|
+
chunkId: string;
|
|
265
|
+
};
|
|
266
|
+
readonly issue: v.ArrayIssue | v.ObjectIssue | v.StringIssue | v.NumberIssue | v.UnionIssue<v.ArrayIssue | v.StringIssue>;
|
|
267
|
+
} | undefined;
|
|
268
|
+
}, v.TransformAction<{
|
|
269
|
+
fileName: string;
|
|
270
|
+
id: string;
|
|
271
|
+
description: string;
|
|
272
|
+
strength: number;
|
|
273
|
+
keywords?: string[] | undefined;
|
|
274
|
+
source: string;
|
|
275
|
+
target: string;
|
|
276
|
+
chunkId: string;
|
|
277
|
+
}, {
|
|
278
|
+
name: string;
|
|
279
|
+
kind: "edge";
|
|
280
|
+
fileName: string;
|
|
281
|
+
id: string;
|
|
282
|
+
description: string;
|
|
283
|
+
strength: number;
|
|
284
|
+
keywords?: string[] | undefined;
|
|
285
|
+
source: string;
|
|
286
|
+
target: string;
|
|
287
|
+
chunkId: string;
|
|
288
|
+
}>]>;
|
|
289
|
+
export declare const EdgePayloadNewDefine: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
290
|
+
readonly embeddingChunk: v.StringSchema<undefined>;
|
|
291
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
292
|
+
readonly kind: v.OptionalSchema<v.LiteralSchema<"edge", undefined>, "edge">;
|
|
293
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
294
|
+
readonly strength: v.OptionalSchema<v.NumberSchema<undefined>, 5>;
|
|
295
|
+
readonly keywords: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>]>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
|
|
296
|
+
readonly source: v.StringSchema<undefined>;
|
|
297
|
+
readonly target: v.StringSchema<undefined>;
|
|
298
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
299
|
+
}, undefined>, v.TransformAction<{
|
|
300
|
+
embeddingChunk: string;
|
|
301
|
+
fileName: string;
|
|
302
|
+
kind: "edge";
|
|
303
|
+
description: string;
|
|
304
|
+
strength: number;
|
|
305
|
+
keywords?: string[] | undefined;
|
|
306
|
+
source: string;
|
|
307
|
+
target: string;
|
|
308
|
+
chunkId: string;
|
|
309
|
+
}, {
|
|
310
|
+
name: string;
|
|
311
|
+
embeddingChunk: string;
|
|
312
|
+
fileName: string;
|
|
313
|
+
kind: "edge";
|
|
314
|
+
description: string;
|
|
315
|
+
strength: number;
|
|
316
|
+
keywords?: string[] | undefined;
|
|
317
|
+
source: string;
|
|
318
|
+
target: string;
|
|
319
|
+
chunkId: string;
|
|
320
|
+
}>]>;
|
|
321
|
+
export declare const EdgeItemNewDefine: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
322
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, () => string>;
|
|
323
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
324
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
325
|
+
readonly strength: v.OptionalSchema<v.NumberSchema<undefined>, 5>;
|
|
326
|
+
readonly keywords: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>]>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
|
|
327
|
+
readonly source: v.StringSchema<undefined>;
|
|
328
|
+
readonly target: v.StringSchema<undefined>;
|
|
329
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
330
|
+
}, undefined>, v.TransformAction<{
|
|
331
|
+
id: string;
|
|
332
|
+
fileName: string;
|
|
333
|
+
description: string;
|
|
334
|
+
strength: number;
|
|
335
|
+
keywords?: string[] | undefined;
|
|
336
|
+
source: string;
|
|
337
|
+
target: string;
|
|
338
|
+
chunkId: string;
|
|
339
|
+
}, {
|
|
340
|
+
name: string;
|
|
341
|
+
kind: "edge";
|
|
342
|
+
id: string;
|
|
343
|
+
fileName: string;
|
|
344
|
+
description: string;
|
|
345
|
+
strength: number;
|
|
346
|
+
keywords?: string[] | undefined;
|
|
347
|
+
source: string;
|
|
348
|
+
target: string;
|
|
349
|
+
chunkId: string;
|
|
350
|
+
}>]>;
|
|
351
|
+
export type EdgePayload = v.InferOutput<typeof EdgePayloadDefine>;
|
|
352
|
+
export type EdgeItemType = v.InferInput<typeof EdgeItemDefine>;
|
|
353
|
+
export type EdgeItemNewType = v.InferInput<typeof EdgeItemNewDefine>;
|
|
354
|
+
export type EdgeQueryPayload = EdgePayload & {
|
|
355
|
+
embeddingChunk: string;
|
|
356
|
+
};
|
|
357
|
+
export interface RagExtraKeyword {
|
|
358
|
+
high_level_keywords: string[];
|
|
359
|
+
low_level_keywords: string[];
|
|
360
|
+
}
|
|
361
|
+
export declare const KnowledgeGraphCreateDefine: v.ObjectSchema<{
|
|
362
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
363
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
364
|
+
readonly nodeList: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
365
|
+
readonly name: v.StringSchema<undefined>;
|
|
366
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
367
|
+
/** 实体类型 */
|
|
368
|
+
readonly type: v.StringSchema<undefined>;
|
|
369
|
+
}, undefined>, undefined>, readonly []>;
|
|
370
|
+
readonly edgeList: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
371
|
+
readonly source: v.StringSchema<undefined>;
|
|
372
|
+
readonly target: v.StringSchema<undefined>;
|
|
373
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
374
|
+
readonly strength: v.OptionalSchema<v.NumberSchema<undefined>, 5>;
|
|
375
|
+
readonly keywords: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>]>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
|
|
376
|
+
}, undefined>, undefined>, readonly []>;
|
|
377
|
+
}, undefined>;
|
|
378
|
+
export type KnowledgeGraphItemType = {
|
|
379
|
+
nodes?: NodeItemNewType[];
|
|
380
|
+
edges?: EdgeItemNewType[];
|
|
381
|
+
};
|
|
382
|
+
/** 属性分割,因为有一部分没id的 */
|
|
383
|
+
export type NodePayload = v.InferOutput<typeof NodePayloadDefine>;
|
|
384
|
+
export type NodeQueryPayload = NodePayload & {
|
|
385
|
+
embeddingChunk: string;
|
|
386
|
+
};
|
|
387
|
+
export type GraphNodeAttr = {
|
|
388
|
+
list: NodePayload[];
|
|
389
|
+
name: string;
|
|
390
|
+
};
|
|
391
|
+
export type GraphEdgeAttr = {
|
|
392
|
+
list: EdgePayload[];
|
|
393
|
+
name: string;
|
|
394
|
+
source: string;
|
|
395
|
+
target: string;
|
|
396
|
+
};
|
|
397
|
+
export declare const KeywordPayloadNewDefine: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
398
|
+
readonly kind: v.OptionalSchema<v.LiteralSchema<"keyword", undefined>, "keyword">;
|
|
399
|
+
readonly keyword: v.StringSchema<undefined>;
|
|
400
|
+
readonly chunkId: v.StringSchema<undefined>;
|
|
401
|
+
readonly fileName: v.StringSchema<undefined>;
|
|
402
|
+
}, undefined>]>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export declare const GraphRelationQueryDefine: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
3
|
+
readonly node: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
4
|
+
readonly edge: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
5
|
+
}, undefined>, v.BaseValidation<{
|
|
6
|
+
node?: string | undefined;
|
|
7
|
+
edge?: string | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
node?: string | undefined;
|
|
10
|
+
edge?: string | undefined;
|
|
11
|
+
}, v.PartialCheckIssue<{
|
|
12
|
+
node?: string | undefined;
|
|
13
|
+
edge?: string | undefined;
|
|
14
|
+
}>>]>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NodeItemType, KnowledgeGraphItemType, EdgeItemType } from './define/define';
|
|
2
|
+
export declare class GraphHandleService {
|
|
3
|
+
#private;
|
|
4
|
+
/** 拆分节点
|
|
5
|
+
*/
|
|
6
|
+
splitNode(options: {
|
|
7
|
+
node: string;
|
|
8
|
+
list: string[];
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
/** 合并节点 */
|
|
11
|
+
mergeNode(options: {
|
|
12
|
+
node: string;
|
|
13
|
+
list: string[];
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
/** 虽然可以修改其他的,但是只允许修改描述 */
|
|
16
|
+
changeNodeDescription(item: NodeItemType): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* 修改边,如果关系修改了不需要改边 */
|
|
19
|
+
changeEdge(item: EdgeItemType): Promise<void>;
|
|
20
|
+
/** 可以添加节点/边 */
|
|
21
|
+
addNodeItem(input: KnowledgeGraphItemType): Promise<void>;
|
|
22
|
+
/** 删除节点的一条 */
|
|
23
|
+
deleteNodeItem(item: Pick<NodeItemType, 'id' | 'name'>): Promise<void>;
|
|
24
|
+
/** 删除整个边(边不影响节点) */
|
|
25
|
+
deleteEdge(item: Pick<EdgeItemType, 'id' | 'source' | 'target'>): Promise<void>;
|
|
26
|
+
/** 删除整个节点(对应边也删除) */
|
|
27
|
+
deleteNodeByName(name: string): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NormalKnowledgeService } from '../normal/normal.knowledge.service';
|
|
2
|
+
import { GraphCollectionInlineType } from './define/config';
|
|
3
|
+
export declare class GraphKnolwdgeService extends NormalKnowledgeService {
|
|
4
|
+
#private;
|
|
5
|
+
formatCollection(input: any): {
|
|
6
|
+
graphCollectionName: string;
|
|
7
|
+
collectionName: string;
|
|
8
|
+
size: number;
|
|
9
|
+
embeddingTemplate?: {
|
|
10
|
+
entry?: {
|
|
11
|
+
enable: boolean;
|
|
12
|
+
value?: string | undefined;
|
|
13
|
+
} | undefined;
|
|
14
|
+
node?: {
|
|
15
|
+
enable: boolean;
|
|
16
|
+
value?: string | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
edge?: {
|
|
19
|
+
enable: boolean;
|
|
20
|
+
value?: string | undefined;
|
|
21
|
+
} | undefined;
|
|
22
|
+
} | undefined;
|
|
23
|
+
};
|
|
24
|
+
create(collection: GraphCollectionInlineType): Promise<void>;
|
|
25
|
+
/** 图谱知识库不允许改chunksize,因为改了后切片就不一样了,那么生成的关系一定也不一样了 */
|
|
26
|
+
insertItem(fileName: string, content: string, signal?: AbortSignal): Promise<void>;
|
|
27
|
+
deleteItem(fileName: string): Promise<void>;
|
|
28
|
+
updateItem(fileName: string, content: string): Promise<void>;
|
|
29
|
+
addCollection(collection: GraphCollectionInlineType): Promise<void>;
|
|
30
|
+
deleteCollection(collectionName: string): Promise<boolean>;
|
|
31
|
+
changeActivateCollection(collectionName: string): Promise<void>;
|
|
32
|
+
export(): Promise<{
|
|
33
|
+
collection: string;
|
|
34
|
+
name?: string | undefined;
|
|
35
|
+
creation_time?: string | null | undefined;
|
|
36
|
+
size?: number | undefined;
|
|
37
|
+
checksum?: string | null | undefined;
|
|
38
|
+
}[]>;
|
|
39
|
+
destroy(): Promise<void>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Signal } from 'static-injector';
|
|
2
|
+
import Graph from 'graphology';
|
|
3
|
+
import { EdgeItemNewType, EdgeItemType, EdgePayload, GraphEdgeAttr, GraphNodeAttr, KnowledgeGraphItemType, NodeItemNewType, NodeItemType, NodePayload } from './define/define';
|
|
4
|
+
import { Attributes } from 'graphology-types';
|
|
5
|
+
export declare class GraphLocalService {
|
|
6
|
+
#private;
|
|
7
|
+
update$: import("static-injector").WritableSignal<number>;
|
|
8
|
+
graphExport$$: Signal<import("graphology-types").SerializedGraph<GraphNodeAttr, GraphEdgeAttr, Attributes>>;
|
|
9
|
+
getGraph(): Graph<GraphNodeAttr, GraphEdgeAttr, Attributes>;
|
|
10
|
+
loadDataInitGraph$$: Signal<Promise<void>>;
|
|
11
|
+
/** 只初始化数据 */
|
|
12
|
+
initGraph(): Graph<GraphNodeAttr, GraphEdgeAttr, Attributes>;
|
|
13
|
+
getTargetListFromSource(name: string): {
|
|
14
|
+
kind: "node";
|
|
15
|
+
id: string;
|
|
16
|
+
chunkId: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
type: string;
|
|
21
|
+
}[];
|
|
22
|
+
edgeToNode(item: EdgeItemNewType, type: 'source' | 'target'): NodeItemNewType;
|
|
23
|
+
createOrUpdateNodeAttr(item: NodeItemNewType): void;
|
|
24
|
+
createOrUpdateEdgeAttr(item: EdgeItemNewType): void;
|
|
25
|
+
loadingData(): Promise<void>;
|
|
26
|
+
/** 一个节点分多个,需要删除原来的节点和边,然后插入
|
|
27
|
+
* 拆分后的节点有可能是存在的
|
|
28
|
+
*/
|
|
29
|
+
splitNode(options: {
|
|
30
|
+
node: string;
|
|
31
|
+
list: string[];
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
mergeNode(options: {
|
|
34
|
+
node: string;
|
|
35
|
+
list: string[];
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
changeNodeDescription(payload: NodeItemType): Promise<void>;
|
|
38
|
+
changeEdge(item: EdgeItemType, oldItem: Pick<EdgePayload, 'id' | 'source' | 'target'>): Promise<void>;
|
|
39
|
+
add(input: KnowledgeGraphItemType): Promise<void>;
|
|
40
|
+
deleteNodeItem(item: Pick<NodeItemType, 'id' | 'name'>): Promise<void>;
|
|
41
|
+
deleteEdgeItem(item: Pick<EdgeItemType, 'id' | 'source' | 'target'>): void;
|
|
42
|
+
deleteNode(name: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* node=>edge
|
|
45
|
+
* 确定最相似的chunk(第一位)
|
|
46
|
+
* 获取传入节点的所有变
|
|
47
|
+
*/
|
|
48
|
+
getEdgeByNode(nodes: NodePayload[]): {
|
|
49
|
+
chunkId: string;
|
|
50
|
+
kind: "edge";
|
|
51
|
+
name: string;
|
|
52
|
+
fileName: string;
|
|
53
|
+
id: string;
|
|
54
|
+
source: string;
|
|
55
|
+
target: string;
|
|
56
|
+
description: string;
|
|
57
|
+
strength: number;
|
|
58
|
+
keywords?: string[] | undefined;
|
|
59
|
+
}[];
|
|
60
|
+
/**
|
|
61
|
+
* 根据边查节点
|
|
62
|
+
* 通过边上的chunkid,查找同在这个chunkid上的souce/target节点,权重为边
|
|
63
|
+
*/
|
|
64
|
+
getNodeByEdge(edges: EdgePayload[]): {
|
|
65
|
+
kind: "node";
|
|
66
|
+
id: string;
|
|
67
|
+
chunkId: string;
|
|
68
|
+
fileName: string;
|
|
69
|
+
name: string;
|
|
70
|
+
description: string;
|
|
71
|
+
type: string;
|
|
72
|
+
}[];
|
|
73
|
+
getChunkEdgeByNode(node: Pick<NodeItemType, 'name' | 'chunkId'>): {
|
|
74
|
+
chunkId: string;
|
|
75
|
+
kind: "edge";
|
|
76
|
+
name: string;
|
|
77
|
+
fileName: string;
|
|
78
|
+
id: string;
|
|
79
|
+
source: string;
|
|
80
|
+
target: string;
|
|
81
|
+
description: string;
|
|
82
|
+
strength: number;
|
|
83
|
+
keywords?: string[] | undefined;
|
|
84
|
+
}[];
|
|
85
|
+
}
|