@dxpos/knowledge 0.11.0 → 0.12.0

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.
@@ -21,6 +21,8 @@ export const deleteApiFiles = (options) => (options.client ?? client).delete({
21
21
  });
22
22
  /**
23
23
  * 列出文件
24
+ *
25
+ * 按创建时间倒序分页返回。q 分词后匹配文件名,命中词在 filenameSnippet 中高亮。
24
26
  */
25
27
  export const getApiFiles = (options) => (options?.client ?? client).get({
26
28
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -34,7 +36,7 @@ export const getApiFiles = (options) => (options?.client ?? client).get({
34
36
  /**
35
37
  * 服务端直传文件
36
38
  *
37
- * 需编辑者及以上。
39
+ * 需编辑者及以上。multipart 上传一个或多个文件,逐个返回结果,部分失败不影响其余文件。
38
40
  */
39
41
  export const postApiFiles = (options) => (options.client ?? client).post({
40
42
  ...formDataBodySerializer,
@@ -53,7 +55,7 @@ export const postApiFiles = (options) => (options.client ?? client).post({
53
55
  /**
54
56
  * 预签名直传
55
57
  *
56
- * 需编辑者及以上。返回对象存储 PUT 地址。
58
+ * 需编辑者及以上。为每个文件创建 pending 记录并返回对象存储 PUT 地址;客户端上传完成后需调用 /api/files/complete 确认。
57
59
  */
58
60
  export const postApiFilesPresign = (options) => (options.client ?? client).post({
59
61
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -71,7 +73,7 @@ export const postApiFilesPresign = (options) => (options.client ?? client).post(
71
73
  /**
72
74
  * 确认预签名上传完成
73
75
  *
74
- * 需编辑者及以上。
76
+ * 需编辑者及以上。检查对象是否已上传,存在则标记为 ready,否则标记为 failed。
75
77
  */
76
78
  export const postApiFilesComplete = (options) => (options.client ?? client).post({
77
79
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -107,7 +109,7 @@ export const postApiFilesCleanup = (options) => (options.client ?? client).post(
107
109
  /**
108
110
  * 删除文件
109
111
  *
110
- * 需管理员及以上。force=true 时坚持删除被引用文件。
112
+ * 需管理员及以上。未传 force 时若仍被引用则返回 409 与引用列表;force=true 时坚持删除被引用文件。
111
113
  */
112
114
  export const deleteApiFilesById = (options) => (options.client ?? client).delete({
113
115
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -120,6 +122,8 @@ export const deleteApiFilesById = (options) => (options.client ?? client).delete
120
122
  });
121
123
  /**
122
124
  * 获取文件元数据
125
+ *
126
+ * 不存在时返回 404。
123
127
  */
124
128
  export const getApiFilesById = (options) => (options.client ?? client).get({
125
129
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -132,6 +136,8 @@ export const getApiFilesById = (options) => (options.client ?? client).get({
132
136
  });
133
137
  /**
134
138
  * 读取文件原始内容
139
+ *
140
+ * 以文件 MIME 返回二进制流,可长期缓存。文件不存在返回 404,尚未就绪返回 400。
135
141
  */
136
142
  export const getApiFilesByIdRaw = (options) => (options.client ?? client).get({
137
143
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -144,6 +150,8 @@ export const getApiFilesByIdRaw = (options) => (options.client ?? client).get({
144
150
  });
145
151
  /**
146
152
  * 获取文件下载地址
153
+ *
154
+ * 知识库文档图片(scope=knowledge)返回长期有效的公开地址,其余返回带有效期的预签名地址。文件不存在返回 404,尚未就绪返回 400。
147
155
  */
148
156
  export const getApiFilesByIdUrl = (options) => (options.client ?? client).get({
149
157
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -155,9 +163,9 @@ export const getApiFilesByIdUrl = (options) => (options.client ?? client).get({
155
163
  ...options
156
164
  });
157
165
  /**
158
- * RAG 问答
166
+ * 问答
159
167
  *
160
- * stream 默认 true,返回 NDJSON 事件流:token / node / references / done / error。stream=false 时返回 JSON 信封,data 为完整回答与引用。attachments 为已上传的对话图片 fileId,实际上限由配置决定,默认 4。content 与 attachments 至少传一项。排队已满或等待超时时返回 429,响应头带 Retry-After。
168
+ * stream 默认 true,返回 NDJSON 事件流:route / token / node / references / done / error。stream=false 时返回 JSON 信封,data 为完整回答与引用。会话绑定智能路由且尚未绑定助手时,首问会先分析意图并绑定助手,流式返回 route 事件(ragId / ragName),非流式在 data.route 返回;其余情况 data.route 为 null。attachments 为已上传的对话图片 fileId,实际上限由配置决定,默认 4。content 与 attachments 至少传一项。排队已满或等待超时时返回 429,响应头带 Retry-After。
161
169
  */
162
170
  export const postApiChat = (options) => (options.client ?? client).post({
163
171
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -173,9 +181,9 @@ export const postApiChat = (options) => (options.client ?? client).post({
173
181
  }
174
182
  });
175
183
  /**
176
- * 读取会话生效的图片限制与欢迎语
184
+ * 获取会话配置
177
185
  *
178
- * 按 RAG 配置 > 全局 > 代码默认合并图片数量上限与压缩最长边;并返回生效的欢迎语与推荐问题(RAG > 全局)。
186
+ * 返回会话生效的图片限制、欢迎语与推荐问题,优先级为问答助手 > 全局 > 默认值。
179
187
  */
180
188
  export const getApiChatLimits = (options) => (options.client ?? client).get({
181
189
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -189,7 +197,7 @@ export const getApiChatLimits = (options) => (options.client ?? client).get({
189
197
  /**
190
198
  * 列出会话
191
199
  *
192
- * 管理员可传 userId 查看指定用户会话;ragId 可按 RAG 过滤。
200
+ * 按创建时间倒序返回。编辑者及以下仅返回自己的会话;管理员及以上默认返回全部会话,可传 userId 查看指定用户会话。ragId 可按问答助手过滤,routerId 可按智能路由过滤。
193
201
  */
194
202
  export const getApiChatConversations = (options) => (options?.client ?? client).get({
195
203
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -202,6 +210,8 @@ export const getApiChatConversations = (options) => (options?.client ?? client).
202
210
  });
203
211
  /**
204
212
  * 创建会话
213
+ *
214
+ * ragId / mark 直接绑定问答助手;routerId / routerMark 绑定智能路由,ragId 暂为 null,首次问答时按意图自动绑定问答助手,之后固定使用该助手。两组参数必须且只能传一组。
205
215
  */
206
216
  export const postApiChatConversations = (options) => (options?.client ?? client).post({
207
217
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -218,6 +228,8 @@ export const postApiChatConversations = (options) => (options?.client ?? client)
218
228
  });
219
229
  /**
220
230
  * 删除会话
231
+ *
232
+ * 连同消息一并删除。编辑者及以下仅能删除自己的会话,否则返回 404。
221
233
  */
222
234
  export const deleteApiChatConversationsById = (options) => (options.client ?? client).delete({
223
235
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -230,6 +242,8 @@ export const deleteApiChatConversationsById = (options) => (options.client ?? cl
230
242
  });
231
243
  /**
232
244
  * 获取会话与消息
245
+ *
246
+ * 返回会话及其全部消息,消息图片会回填当前有效的下载地址。编辑者及以下仅能访问自己的会话,否则返回 404。
233
247
  */
234
248
  export const getApiChatConversationsById = (options) => (options.client ?? client).get({
235
249
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -243,7 +257,7 @@ export const getApiChatConversationsById = (options) => (options.client ?? clien
243
257
  /**
244
258
  * 更新会话
245
259
  *
246
- * 需编辑者及以上。
260
+ * 需编辑者及以上。仅支持修改标题,title 为空时保持原标题。
247
261
  */
248
262
  export const patchApiChatConversationsById = (options) => (options.client ?? client).patch({
249
263
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -258,6 +272,84 @@ export const patchApiChatConversationsById = (options) => (options.client ?? cli
258
272
  ...options.headers
259
273
  }
260
274
  });
275
+ /**
276
+ * 列出智能路由
277
+ *
278
+ * 返回全部智能路由及其候选问答助手配置。
279
+ */
280
+ export const getApiChatRouters = (options) => (options?.client ?? client).get({
281
+ security: [{ scheme: 'bearer', type: 'http' }, {
282
+ in: 'cookie',
283
+ name: 'authjs.session-token',
284
+ type: 'apiKey'
285
+ }],
286
+ url: '/api/chat/routers',
287
+ ...options
288
+ });
289
+ /**
290
+ * 创建智能路由
291
+ *
292
+ * 需编辑者及以上。routes 为候选问答助手,不能重复,intent 为空时取问答助手描述作为意图描述;未命中任何候选时路由到 fallbackRagId。intentPrompt 为空使用默认提示词,自定义时必须包含 {{assistants}} 变量,模型需只输出命中助手的 id。textProviderId 与 textModel 需同时填写,为空使用全局文本模型。mark 重复时返回 400。
293
+ */
294
+ export const postApiChatRouters = (options) => (options.client ?? client).post({
295
+ security: [{ scheme: 'bearer', type: 'http' }, {
296
+ in: 'cookie',
297
+ name: 'authjs.session-token',
298
+ type: 'apiKey'
299
+ }],
300
+ url: '/api/chat/routers',
301
+ ...options,
302
+ headers: {
303
+ 'Content-Type': 'application/json',
304
+ ...options.headers
305
+ }
306
+ });
307
+ /**
308
+ * 删除智能路由
309
+ *
310
+ * 需编辑者及以上。已绑定问答助手的会话保留助手,routerId 置空。
311
+ */
312
+ export const deleteApiChatRoutersById = (options) => (options.client ?? client).delete({
313
+ security: [{ scheme: 'bearer', type: 'http' }, {
314
+ in: 'cookie',
315
+ name: 'authjs.session-token',
316
+ type: 'apiKey'
317
+ }],
318
+ url: '/api/chat/routers/{id}',
319
+ ...options
320
+ });
321
+ /**
322
+ * 获取智能路由
323
+ *
324
+ * 不存在时返回 404。
325
+ */
326
+ export const getApiChatRoutersById = (options) => (options.client ?? client).get({
327
+ security: [{ scheme: 'bearer', type: 'http' }, {
328
+ in: 'cookie',
329
+ name: 'authjs.session-token',
330
+ type: 'apiKey'
331
+ }],
332
+ url: '/api/chat/routers/{id}',
333
+ ...options
334
+ });
335
+ /**
336
+ * 更新智能路由
337
+ *
338
+ * 需编辑者及以上。仅更新传入字段,校验规则同创建。已绑定问答助手的会话不受影响。
339
+ */
340
+ export const patchApiChatRoutersById = (options) => (options.client ?? client).patch({
341
+ security: [{ scheme: 'bearer', type: 'http' }, {
342
+ in: 'cookie',
343
+ name: 'authjs.session-token',
344
+ type: 'apiKey'
345
+ }],
346
+ url: '/api/chat/routers/{id}',
347
+ ...options,
348
+ headers: {
349
+ 'Content-Type': 'application/json',
350
+ ...options.headers
351
+ }
352
+ });
261
353
  /**
262
354
  * 关键词检索文档
263
355
  *
@@ -274,6 +366,8 @@ export const getApiSearch = (options) => (options.client ?? client).get({
274
366
  });
275
367
  /**
276
368
  * 上报检索结果点击
369
+ *
370
+ * 记录检索词与被点击文档,用于检索效果统计。
277
371
  */
278
372
  export const postApiSearchClick = (options) => (options.client ?? client).post({
279
373
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -305,7 +399,7 @@ export const getApiKnowledgeBases = (options) => (options?.client ?? client).get
305
399
  /**
306
400
  * 创建知识库
307
401
  *
308
- * 需编辑者及以上。mark 为知识库唯一标识,不可包含逗号。
402
+ * 需编辑者及以上。mark 为知识库唯一标识,不可包含逗号。分块参数为空时继承全局默认。
309
403
  */
310
404
  export const postApiKnowledgeBases = (options) => (options.client ?? client).post({
311
405
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -336,6 +430,8 @@ export const deleteApiKnowledgeBasesById = (options) => (options.client ?? clien
336
430
  });
337
431
  /**
338
432
  * 获取知识库
433
+ *
434
+ * 不存在时返回 404。
339
435
  */
340
436
  export const getApiKnowledgeBasesById = (options) => (options.client ?? client).get({
341
437
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -349,7 +445,7 @@ export const getApiKnowledgeBasesById = (options) => (options.client ?? client).
349
445
  /**
350
446
  * 更新知识库
351
447
  *
352
- * 需编辑者及以上。
448
+ * 需编辑者及以上。仅更新传入字段。mark 不可包含逗号,重复时返回 400。
353
449
  */
354
450
  export const patchApiKnowledgeBasesById = (options) => (options.client ?? client).patch({
355
451
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -365,7 +461,23 @@ export const patchApiKnowledgeBasesById = (options) => (options.client ?? client
365
461
  }
366
462
  });
367
463
  /**
368
- * 列出 RAG 配置
464
+ * 导出知识库
465
+ *
466
+ * 将当前角色可见的文档导出为 Zip:Markdown 按文件夹树存放,根目录 manifest.json 记录各文档的路径、可见性与排序(结构见 KnowledgeBaseManifest)。阅览者仅导出公开且所在文件夹链路均公开的文档。导出包可通过 POST /api/documents 的 archive 字段导入。
467
+ */
468
+ export const getApiKnowledgeBasesByIdExport = (options) => (options.client ?? client).get({
469
+ security: [{ scheme: 'bearer', type: 'http' }, {
470
+ in: 'cookie',
471
+ name: 'authjs.session-token',
472
+ type: 'apiKey'
473
+ }],
474
+ url: '/api/knowledge-bases/{id}/export',
475
+ ...options
476
+ });
477
+ /**
478
+ * 列出问答助手
479
+ *
480
+ * 返回全部问答助手的完整配置,欢迎语图片会回填当前有效的下载地址。
369
481
  */
370
482
  export const getApiRags = (options) => (options?.client ?? client).get({
371
483
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -377,9 +489,9 @@ export const getApiRags = (options) => (options?.client ?? client).get({
377
489
  ...options
378
490
  });
379
491
  /**
380
- * 创建 RAG 配置
492
+ * 创建问答助手
381
493
  *
382
- * 绑定知识库与对话模块配置。mark 不可包含逗号。
494
+ * 需编辑者及以上。绑定知识库与对话参数,对话参数为空时继承全局默认。textProviderId 与 textModel 需同时填写。mark 不可包含逗号且全局唯一,重复时返回 400。
383
495
  */
384
496
  export const postApiRags = (options) => (options.client ?? client).post({
385
497
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -395,7 +507,9 @@ export const postApiRags = (options) => (options.client ?? client).post({
395
507
  }
396
508
  });
397
509
  /**
398
- * 删除 RAG 配置
510
+ * 删除问答助手
511
+ *
512
+ * 需编辑者及以上。被智能路由设为兜底助手时返回 400;已绑定该助手的会话保留,ragId 置空。
399
513
  */
400
514
  export const deleteApiRagsById = (options) => (options.client ?? client).delete({
401
515
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -407,7 +521,9 @@ export const deleteApiRagsById = (options) => (options.client ?? client).delete(
407
521
  ...options
408
522
  });
409
523
  /**
410
- * 获取 RAG 配置
524
+ * 获取问答助手
525
+ *
526
+ * 返回问答助手完整配置,欢迎语图片会回填当前有效的下载地址。不存在时返回 404。
411
527
  */
412
528
  export const getApiRagsById = (options) => (options.client ?? client).get({
413
529
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -419,9 +535,9 @@ export const getApiRagsById = (options) => (options.client ?? client).get({
419
535
  ...options
420
536
  });
421
537
  /**
422
- * 更新 RAG 配置
538
+ * 更新问答助手
423
539
  *
424
- * 空字段表示继承全局默认。
540
+ * 需编辑者及以上。除 name / kbId 外,未传字段会被置为 null(对话参数为 null 即继承全局默认),请提交完整配置。textProviderId 与 textModel 需同时填写。mark 重复时返回 400。
425
541
  */
426
542
  export const patchApiRagsById = (options) => (options.client ?? client).patch({
427
543
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -437,7 +553,7 @@ export const patchApiRagsById = (options) => (options.client ?? client).patch({
437
553
  }
438
554
  });
439
555
  /**
440
- * 按 id / mark 获取 RAG 配置摘要
556
+ * 按 id / mark 获取问答助手摘要
441
557
  *
442
558
  * id 与 mark 不能同时为空,同时传入按 AND 匹配。返回 id/name/mark/welcome/recommendedQuestions。
443
559
  */
@@ -466,6 +582,8 @@ export const deleteApiDocuments = (options) => (options.client ?? client).delete
466
582
  });
467
583
  /**
468
584
  * 列出知识库文档
585
+ *
586
+ * 返回文档摘要(不含正文)。阅览者仅能看到公开文档,且所在文件夹链路均需公开。
469
587
  */
470
588
  export const getApiDocuments = (options) => (options.client ?? client).get({
471
589
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -479,7 +597,7 @@ export const getApiDocuments = (options) => (options.client ?? client).get({
479
597
  /**
480
598
  * 创建空白文档或上传 Markdown
481
599
  *
482
- * Content-Type 为 application/json 时创建空白文档(kbId 由 query 传入);为 multipart/form-data 时上传 Markdown 文件,返回 NDJSON 进度事件流。需编辑者及以上。
600
+ * Content-Type 为 application/json 时创建空白文档(kbId 由 query 传入);为 multipart/form-data 时上传 Markdown 文件(files)或知识库导出 Zip(archive),返回 NDJSON 进度事件流。同级重名的文档记为失败并跳过。需编辑者及以上。
483
601
  */
484
602
  export const postApiDocuments = (options) => (options.client ?? client).post({
485
603
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -529,7 +647,7 @@ export const patchApiDocumentsByPath = (options) => (options.client ?? client).p
529
647
  /**
530
648
  * 删除文档
531
649
  *
532
- * 需编辑者及以上。
650
+ * 需编辑者及以上。同时删除文档分块。
533
651
  */
534
652
  export const deleteApiDocumentsById = (options) => (options.client ?? client).delete({
535
653
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -542,6 +660,8 @@ export const deleteApiDocumentsById = (options) => (options.client ?? client).de
542
660
  });
543
661
  /**
544
662
  * 获取文档
663
+ *
664
+ * 返回文档完整内容并记录一次访问。阅览者仅能访问公开且所在文件夹链路均公开的文档,否则返回 403;文档不存在返回 404。
545
665
  */
546
666
  export const getApiDocumentsById = (options) => (options.client ?? client).get({
547
667
  security: [{ scheme: 'bearer', type: 'http' }, {