@kevisual/cnb 0.0.76 → 0.0.77

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/routes.d.ts CHANGED
@@ -13,6 +13,7 @@ type CNBCoreOptions<T = {}> = {
13
13
  cors?: {
14
14
  baseUrl?: string;
15
15
  };
16
+ openapi?: boolean;
16
17
  } & T;
17
18
  type RequestOptions = {
18
19
  url?: string;
@@ -21,6 +22,7 @@ type RequestOptions = {
21
22
  body?: any;
22
23
  params?: Record<string, any>;
23
24
  headers?: Record<string, any>;
25
+ token?: string;
24
26
  useCookie?: boolean;
25
27
  useOrigin?: boolean;
26
28
  };
@@ -30,8 +32,9 @@ declare class CNBCore {
30
32
  token: string;
31
33
  cookie?: string;
32
34
  isCors: boolean;
35
+ openapi?: boolean;
33
36
  constructor(options: CNBCoreOptions);
34
- request({ url, method, data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any>;
37
+ request({ url, method, data, params, headers, body, useCookie, useOrigin, ...rest }: RequestOptions): Promise<any>;
35
38
  makeUrl(url?: string): string;
36
39
  get<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
37
40
  post<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
@@ -39,10 +42,11 @@ declare class CNBCore {
39
42
  delete<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
40
43
  patch<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
41
44
  /**
42
- * 通过 PUT 请求上传文件内容
43
- * @param data 包含 URL、token 和文件内容
44
- * @returns 上传结果
45
- */
45
+ * 通过 PUT 请求上传文件内容
46
+ * assets上传的时候,第一次会获取到一个上传 URL token,然后使用这个方法将文件内容上传到指定的 URL
47
+ * @param data 包含 URL、token 和文件内容
48
+ * @returns 上传结果
49
+ */
46
50
  putFile(data: {
47
51
  url: string;
48
52
  token: string;
@@ -249,24 +253,26 @@ declare class KnowledgeBase extends CNBCore {
249
253
  deleteBase(repo: string): Promise<Result<any>>;
250
254
  /**
251
255
  * 未暴露
256
+ *
257
+ * 创建知识库接口,cnb 界面操作定制模块功能依赖该接口实现
252
258
  * @param repo
253
259
  * @param data
254
260
  * @returns
255
261
  */
256
- createKnowledgeBase(repo: string, data: {
257
- embedding_model_name: string;
262
+ createKnowledgeBase(repo: string, params: {
263
+ /**
264
+ * hunyuan | bge-m3
265
+ */
266
+ model_name: string;
258
267
  include: string;
259
268
  exclude: string;
269
+ chunk_size: number;
270
+ chunk_overlap: number;
271
+ text_separator: string;
260
272
  issue_sync_enabled?: boolean;
261
- processing?: {
262
- chunk_size: number;
263
- chunk_overlap: number;
264
- text_separator: string;
265
- };
266
- issue?: {
267
- labels: string;
268
- state: string;
269
- };
273
+ issue_labels?: string;
274
+ issue_exclude_labels?: string;
275
+ issue_state?: string;
270
276
  }): Promise<Result<any>>;
271
277
  /**
272
278
  * 未暴露
@@ -285,23 +291,28 @@ declare class KnowledgeBase extends CNBCore {
285
291
  * @returns
286
292
  */
287
293
  getEmbedding(repo: string, text: string): Promise<Result<{
288
- embedding: number[];
294
+ embeddings: number[];
289
295
  }>>;
290
296
  /**
291
- * 未暴露
297
+ * 未暴露
298
+ * 只能运行在流水线,使用流水线的CNB_TOKEN去使用
299
+ * 否则会报错:sn not found in meta
300
+ * opts的token必须是流水线的CNB_TOKEN,不能是用户的token
292
301
  * @param repo
293
302
  * @param chunksData
294
303
  * @returns
295
304
  */
296
- addDocument(repo: string, chunksData: {
297
- path: string;
298
- chunks: Array<{
299
- content: string;
300
- hash: string;
301
- offset: number;
302
- size: number;
303
- }>;
304
- }): Promise<Result<any>>;
305
+ addDocument(repo: string, AddDocument: AddDocument, opts?: RequestOptions): Promise<Result<null>>;
306
+ /**
307
+ * 未暴露
308
+ * @param repo
309
+ * @param paths
310
+ size: number;
311
+ }>;
312
+ }): Promise<Result<any>> {
313
+ const url = `/${repo}/-/knowledge/documents/upsert-document-with-chunks`;
314
+ return this.post({ url, data: chunksData });
315
+ }
305
316
  /**
306
317
  * 未暴露
307
318
  * @param repo
@@ -316,7 +327,7 @@ declare class KnowledgeBase extends CNBCore {
316
327
  * @param page_size
317
328
  * @returns
318
329
  */
319
- listDocument(repo: string, page?: number, page_size?: number): Promise<Result<any[]>>;
330
+ listDocuments(repo: string, page?: number, page_size?: number): Promise<Result<any[]>>;
320
331
  }
321
332
  type MetadataFilteringConditions = {
322
333
  conditions: Array<{
@@ -341,6 +352,24 @@ type QueryRag = {
341
352
  url: string;
342
353
  };
343
354
  };
355
+ type AddDocument = {
356
+ path: string;
357
+ name: string;
358
+ extension: string;
359
+ size: number;
360
+ hash: string;
361
+ type: "code" | "issue";
362
+ url: string;
363
+ chunks: Array<{
364
+ "content": string;
365
+ "hash": string;
366
+ "position": number;
367
+ "embedding": number[];
368
+ }>;
369
+ batch_index: number;
370
+ batch_count: number;
371
+ is_last_batch: boolean;
372
+ };
344
373
 
345
374
  declare class Repo extends CNBCore {
346
375
  constructor(options: CNBCoreOptions);
@@ -1182,6 +1211,10 @@ declare class RepoLabel extends CNBCore {
1182
1211
  * @param name 标签名称
1183
1212
  */
1184
1213
  remove(repo: string, name: string): Promise<Result<void>>;
1214
+ removeLabels(opts: {
1215
+ repo: string;
1216
+ labels: string[];
1217
+ }): Promise<Result>;
1185
1218
  }
1186
1219
  type ListLabelsParams = {
1187
1220
  /** 分页页码 */