This commit is contained in:
2026-01-12 03:16:35 +08:00
parent c2dcc53018
commit 5310ff28ae
48 changed files with 1349 additions and 254 deletions

View File

@@ -1,13 +1,8 @@
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
import { CNBCore, CNBCoreOptions, Result } from "../cnb-core.ts";
type RepoOptions = CNBCoreOptions<{
group?: string;
}>
export class KnowledgeBase extends CNBCore {
group: string;
constructor(options: RepoOptions) {
constructor(options: CNBCoreOptions) {
super({ token: options.token, cookie: options.cookie });
this.group = options.group || '';
}
queryKnowledgeBase(repo: string, data: {
@@ -16,28 +11,24 @@ export class KnowledgeBase extends CNBCore {
top_k?: number,
metadata_filtering_conditions?: MetadataFilteringConditions
}): Promise<any> {
const group = this.group || '';
const url = `/${group}/${repo}/-/knowledge/base/query`;
const url = `/${repo}/-/knowledge/base/query`;
let postData = {
query: data.query,
};
return this.post({ url, data: postData });
}
getEmbeddingModels(repo: string): Promise<Result<Array<{ name: string, dimensions: number }>>> {
const group = this.group || '';
const url = `/${group}/${repo}/-/knowledge/embedding/models`;
const url = `/${repo}/-/knowledge/embedding/models`;
// bg3-m3 1024
// hunyuan 1024
return this.get({ url });
}
getBase(repo: string): Promise<Result<any>> {
const group = this.group || '';
const url = `/${group}/${repo}/-/knowledge/base`;
const url = `/${repo}/-/knowledge/base`;
return this.get({ url });
}
deleteBase(repo: string): Promise<Result<any>> {
const group = this.group || '';
const url = `/${group}/${repo}/-/knowledge/base`;
const url = `/${repo}/-/knowledge/base`;
return this.request({ url, method: 'DELETE' });
}
}