@kweaver-ai/kweaver-sdk 0.7.2 → 0.7.4
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 +35 -1
- package/README.zh.md +26 -0
- package/bin/kweaver.js +12 -11
- package/dist/api/bkn-backend.d.ts +1 -0
- package/dist/api/bkn-backend.js +1 -1
- package/dist/api/bkn-metrics.d.ts +59 -0
- package/dist/api/bkn-metrics.js +129 -0
- package/dist/api/conversations.d.ts +47 -2
- package/dist/api/conversations.js +113 -17
- package/dist/api/datasources.d.ts +7 -0
- package/dist/api/datasources.js +51 -6
- package/dist/api/model-invocation.d.ts +58 -0
- package/dist/api/model-invocation.js +203 -0
- package/dist/api/models.d.ts +79 -0
- package/dist/api/models.js +183 -0
- package/dist/api/ontology-query-metrics.d.ts +14 -0
- package/dist/api/ontology-query-metrics.js +30 -0
- package/dist/api/toolboxes.d.ts +2 -0
- package/dist/api/toolboxes.js +2 -1
- package/dist/bundled-model-templates.d.ts +17 -0
- package/dist/bundled-model-templates.js +24 -0
- package/dist/cli.js +28 -2
- package/dist/client.d.ts +3 -0
- package/dist/client.js +5 -0
- package/dist/commands/agent.d.ts +7 -1
- package/dist/commands/agent.js +75 -21
- package/dist/commands/auth.js +42 -7
- package/dist/commands/bkn-metric.d.ts +1 -0
- package/dist/commands/bkn-metric.js +406 -0
- package/dist/commands/bkn-ops.d.ts +2 -1
- package/dist/commands/bkn-ops.js +75 -34
- package/dist/commands/bkn-utils.d.ts +55 -2
- package/dist/commands/bkn-utils.js +103 -9
- package/dist/commands/bkn.js +4 -0
- package/dist/commands/dataflow.js +194 -20
- package/dist/commands/ds.d.ts +0 -1
- package/dist/commands/ds.js +26 -10
- package/dist/commands/explore-chat.js +2 -2
- package/dist/commands/import-csv.d.ts +0 -2
- package/dist/commands/import-csv.js +2 -4
- package/dist/commands/model.d.ts +72 -0
- package/dist/commands/model.js +1315 -0
- package/dist/commands/tool.d.ts +1 -0
- package/dist/commands/tool.js +12 -0
- package/dist/config/store.d.ts +1 -0
- package/dist/config/store.js +17 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +5 -0
- package/dist/resources/models.d.ts +40 -0
- package/dist/resources/models.js +88 -0
- package/dist/resources/toolboxes.d.ts +2 -0
- package/dist/templates/bkn/document/manifest.json +12 -0
- package/dist/templates/bkn/document/template.json +757 -0
- package/dist/templates/dataflow/unstructured/manifest.json +11 -0
- package/dist/templates/dataflow/unstructured/template.json +63 -0
- package/dist/templates/dataset/document/manifest.json +10 -0
- package/dist/templates/dataset/document/template.json +23 -0
- package/dist/templates/dataset/document-content/manifest.json +10 -0
- package/dist/templates/dataset/document-content/template.json +29 -0
- package/dist/templates/dataset/document-element/manifest.json +10 -0
- package/dist/templates/dataset/document-element/template.json +21 -0
- package/dist/templates/model/llm-basic.json +13 -0
- package/dist/templates/model/manifest.json +16 -0
- package/dist/templates/model/small-basic.json +6 -0
- package/dist/utils/template-loader.d.ts +40 -0
- package/dist/utils/template-loader.js +129 -0
- package/dist/utils/trace-views.d.ts +44 -0
- package/dist/utils/trace-views.js +425 -0
- package/package.json +3 -3
package/dist/commands/tool.d.ts
CHANGED
package/dist/commands/tool.js
CHANGED
|
@@ -12,8 +12,10 @@ Subcommands:
|
|
|
12
12
|
enable --toolbox <box-id> <tool-id>... Enable one or more tools
|
|
13
13
|
disable --toolbox <box-id> <tool-id>... Disable one or more tools
|
|
14
14
|
execute --toolbox <box-id> <tool-id> [--body '<json>'|--body-file <path>]
|
|
15
|
+
[--header|--query|--path '<json>']
|
|
15
16
|
Invoke a published+enabled tool
|
|
16
17
|
debug --toolbox <box-id> <tool-id> [--body '<json>'|--body-file <path>]
|
|
18
|
+
[--header|--query|--path '<json>']
|
|
17
19
|
Invoke a tool (works on draft/disabled too)
|
|
18
20
|
|
|
19
21
|
Options for execute/debug:
|
|
@@ -21,6 +23,9 @@ Options for execute/debug:
|
|
|
21
23
|
(Authorization is auto-injected from current session
|
|
22
24
|
when --header omits it; pass {} to send none)
|
|
23
25
|
--query '<json>' Query params map forwarded to the downstream tool
|
|
26
|
+
--path '<json>' Path parameter map for OpenAPI path placeholders (e.g. {id})
|
|
27
|
+
(JSON object: quote id and UUID, e.g. key id for get_dataview_detail /
|
|
28
|
+
query_dataview_sql)
|
|
24
29
|
--timeout <seconds> Per-call timeout (backend default applies when omitted)
|
|
25
30
|
|
|
26
31
|
Common options:
|
|
@@ -241,6 +246,7 @@ export function parseToolInvokeArgs(args) {
|
|
|
241
246
|
let pretty = true;
|
|
242
247
|
let header;
|
|
243
248
|
let query;
|
|
249
|
+
let path;
|
|
244
250
|
let body;
|
|
245
251
|
let bodyProvided = false;
|
|
246
252
|
let bodyFile;
|
|
@@ -259,6 +265,10 @@ export function parseToolInvokeArgs(args) {
|
|
|
259
265
|
query = parseJsonOption("--query", args[++i]);
|
|
260
266
|
continue;
|
|
261
267
|
}
|
|
268
|
+
if (a === "--path" && args[i + 1]) {
|
|
269
|
+
path = parseJsonOption("--path", args[++i]);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
262
272
|
if (a === "--body" && args[i + 1]) {
|
|
263
273
|
const raw = args[++i];
|
|
264
274
|
try {
|
|
@@ -312,6 +322,7 @@ export function parseToolInvokeArgs(args) {
|
|
|
312
322
|
toolId,
|
|
313
323
|
header,
|
|
314
324
|
query,
|
|
325
|
+
path,
|
|
315
326
|
body: bodyProvided ? body : undefined,
|
|
316
327
|
bodyFile,
|
|
317
328
|
timeout,
|
|
@@ -370,6 +381,7 @@ async function runToolInvoke(args, action) {
|
|
|
370
381
|
toolId: opts.toolId,
|
|
371
382
|
header,
|
|
372
383
|
query: opts.query,
|
|
384
|
+
path: opts.path,
|
|
373
385
|
body,
|
|
374
386
|
timeout: opts.timeout,
|
|
375
387
|
});
|
package/dist/config/store.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface PlatformSummary {
|
|
|
53
53
|
/** Human-readable name persisted from /oauth2/userinfo at login time. */
|
|
54
54
|
displayName?: string;
|
|
55
55
|
}
|
|
56
|
+
export declare function getProfileName(): string | null;
|
|
56
57
|
/** Extract userId from a TokenConfig (try idToken, then accessToken, fallback "default"). */
|
|
57
58
|
export declare function extractUserId(token: TokenConfig): string;
|
|
58
59
|
/** Get the active userId for a platform. */
|
package/dist/config/store.js
CHANGED
|
@@ -29,6 +29,19 @@ const MCP_PATH = "/api/agent-retrieval/v1/mcp";
|
|
|
29
29
|
function buildMcpUrl(baseUrl) {
|
|
30
30
|
return baseUrl.replace(/\/+$/, "") + MCP_PATH;
|
|
31
31
|
}
|
|
32
|
+
const PROFILE_NAME_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
33
|
+
export function getProfileName() {
|
|
34
|
+
const raw = process.env.KWEAVER_PROFILE;
|
|
35
|
+
if (!raw)
|
|
36
|
+
return null;
|
|
37
|
+
const trimmed = raw.trim();
|
|
38
|
+
if (!trimmed)
|
|
39
|
+
return null;
|
|
40
|
+
if (!PROFILE_NAME_RE.test(trimmed)) {
|
|
41
|
+
throw new Error(`KWEAVER_PROFILE='${raw}' is invalid. Use 1-64 chars from [A-Za-z0-9_-].`);
|
|
42
|
+
}
|
|
43
|
+
return trimmed;
|
|
44
|
+
}
|
|
32
45
|
function getConfigDirPath() {
|
|
33
46
|
return process.env.KWEAVERC_CONFIG_DIR || join(homedir(), ".kweaver");
|
|
34
47
|
}
|
|
@@ -36,6 +49,10 @@ function getPlatformsDirPath() {
|
|
|
36
49
|
return join(getConfigDirPath(), "platforms");
|
|
37
50
|
}
|
|
38
51
|
function getStateFilePath() {
|
|
52
|
+
const profile = getProfileName();
|
|
53
|
+
if (profile) {
|
|
54
|
+
return join(getConfigDirPath(), "profiles", profile, "state.json");
|
|
55
|
+
}
|
|
39
56
|
return join(getConfigDirPath(), "state.json");
|
|
40
57
|
}
|
|
41
58
|
function getLegacyClientFilePath() {
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,10 @@ export type { ListKnowledgeNetworksOptions, GetKnowledgeNetworkOptions, CreateKn
|
|
|
29
29
|
export { listKnowledgeNetworks, getKnowledgeNetwork, createKnowledgeNetwork, updateKnowledgeNetwork, deleteKnowledgeNetwork, listObjectTypes, listRelationTypes, listActionTypes, } from "./api/knowledge-networks.js";
|
|
30
30
|
export type { OntologyQueryBaseOptions, ObjectTypeQueryOptions, ObjectTypePropertiesOptions, SubgraphOptions, ActionTypeQueryOptions, ActionTypeExecuteOptions, ActionExecutionGetOptions, ActionLogsListOptions, ActionLogGetOptions, ActionLogCancelOptions, } from "./api/ontology-query.js";
|
|
31
31
|
export { objectTypeQuery, objectTypeProperties, subgraph, actionTypeQuery, actionTypeExecute, actionExecutionGet, actionLogsList, actionLogGet, actionLogCancel, } from "./api/ontology-query.js";
|
|
32
|
+
export type { MetricQueryDataOptions, MetricDryRunOptions } from "./api/ontology-query-metrics.js";
|
|
33
|
+
export { metricQueryData, metricDryRun } from "./api/ontology-query-metrics.js";
|
|
34
|
+
export type { ListMetricsOptions, CreateMetricsOptions, SearchMetricsOptions, ValidateMetricsOptions, GetMetricOptions, UpdateMetricOptions, DeleteMetricOptions, GetMetricsByIdsOptions, DeleteMetricsByIdsOptions, } from "./api/bkn-metrics.js";
|
|
35
|
+
export { listMetrics, createMetrics, searchMetrics, validateMetrics, getMetric, updateMetric, deleteMetric, getMetrics, deleteMetrics, } from "./api/bkn-metrics.js";
|
|
32
36
|
export type { SendChatRequestOptions, SendChatRequestStreamCallbacks, ChatResult, ProgressItem, AgentInfo, } from "./api/agent-chat.js";
|
|
33
37
|
export { sendChatRequest, sendChatRequestStream, fetchAgentInfo, buildChatUrl, buildAgentInfoUrl, extractText, } from "./api/agent-chat.js";
|
|
34
38
|
export type { ListAgentsOptions, GetAgentOptions, GetAgentByKeyOptions, CreateAgentOptions, UpdateAgentOptions, DeleteAgentOptions, PublishAgentOptions, UnpublishAgentOptions, } from "./api/agent-list.js";
|
|
@@ -52,11 +56,16 @@ export { ContextLoaderResource } from "./resources/context-loader.js";
|
|
|
52
56
|
export { SkillsResource } from "./resources/skills.js";
|
|
53
57
|
export { ToolboxesResource } from "./resources/toolboxes.js";
|
|
54
58
|
export type { InvokeToolArgs } from "./resources/toolboxes.js";
|
|
59
|
+
export { ModelsResource, LlmModelsSubresource, SmallModelsSubresource, ModelInvocationSubresource, } from "./resources/models.js";
|
|
55
60
|
export type { SkillStatus, SkillSummary, SkillInfo, SkillFileSummary, SkillContentIndex, SkillFileReadResult, RegisterSkillResult, DeleteSkillResult, UpdateSkillStatusResult, SkillListResult, ListSkillsOptions, ListSkillMarketOptions, GetSkillOptions, RegisterSkillContentOptions, RegisterSkillZipOptions, UpdateSkillStatusOptions, ReadSkillFileOptions, DownloadSkillOptions, DownloadedSkillArchive, } from "./api/skills.js";
|
|
56
61
|
export { listSkills, listSkillMarket, getSkill, deleteSkill, updateSkillStatus, registerSkillContent, registerSkillZip, getSkillContentIndex, fetchSkillContent, readSkillFile, fetchSkillFile, downloadSkill, installSkillArchive, } from "./api/skills.js";
|
|
57
62
|
export type { ViewField, DataView, CreateDataViewOptions, GetDataViewOptions, ListDataViewsOptions, DeleteDataViewOptions, FindDataViewOptions, QueryDataViewOptions, DataViewQueryResult, } from "./api/dataviews.js";
|
|
58
63
|
export { parseDataView, createDataView, getDataView, listDataViews, deleteDataView, findDataView, queryDataView, } from "./api/dataviews.js";
|
|
59
64
|
export { DataViewsResource } from "./resources/dataviews.js";
|
|
65
|
+
export type { MfManagerBaseOptions, ListLlmModelsOptions, GetLlmModelOptions, AddLlmModelOptions, EditLlmModelOptions, DeleteLlmModelsOptions, TestLlmModelOptions, ListSmallModelsOptions, GetSmallModelOptions, AddSmallModelOptions, EditSmallModelOptions, DeleteSmallModelsOptions, TestSmallModelOptions, } from "./api/models.js";
|
|
66
|
+
export { MF_MODEL_MANAGER_PATH_PREFIX, assertSmallModelConfigAdapterExclusive, assertSmallModelEditBody, listLlmModels, getLlmModel, addLlmModel, editLlmModel, deleteLlmModels, testLlmModel, listSmallModels, getSmallModel, addSmallModel, editSmallModel, deleteSmallModels, testSmallModel, } from "./api/models.js";
|
|
67
|
+
export type { MfApiBaseOptions, ChatMessage, ModelChatCompletionsOptions, ModelChatResult, ModelEmbeddingOptions, ModelRerankOptions, } from "./api/model-invocation.js";
|
|
68
|
+
export { MF_MODEL_API_PATH_PREFIX, consumeOpenAiSseText, modelChatCompletions, modelEmbedding, modelEmbeddings, modelRerank, } from "./api/model-invocation.js";
|
|
60
69
|
export type { BusinessDomain, ListBusinessDomainsOptions } from "./api/business-domains.js";
|
|
61
70
|
export { listBusinessDomains } from "./api/business-domains.js";
|
|
62
71
|
export type { CreateToolboxOptions, DeleteToolboxOptions, SetToolboxStatusOptions, UploadToolOptions, SetToolStatusesOptions, ListToolboxesOptions, ListToolsOptions, InvokeToolOptions, } from "./api/toolboxes.js";
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
*/
|
|
28
28
|
export { listKnowledgeNetworks, getKnowledgeNetwork, createKnowledgeNetwork, updateKnowledgeNetwork, deleteKnowledgeNetwork, listObjectTypes, listRelationTypes, listActionTypes, } from "./api/knowledge-networks.js";
|
|
29
29
|
export { objectTypeQuery, objectTypeProperties, subgraph, actionTypeQuery, actionTypeExecute, actionExecutionGet, actionLogsList, actionLogGet, actionLogCancel, } from "./api/ontology-query.js";
|
|
30
|
+
export { metricQueryData, metricDryRun } from "./api/ontology-query-metrics.js";
|
|
31
|
+
export { listMetrics, createMetrics, searchMetrics, validateMetrics, getMetric, updateMetric, deleteMetric, getMetrics, deleteMetrics, } from "./api/bkn-metrics.js";
|
|
30
32
|
export { sendChatRequest, sendChatRequestStream, fetchAgentInfo, buildChatUrl, buildAgentInfoUrl, extractText, } from "./api/agent-chat.js";
|
|
31
33
|
export { listAgents, getAgent, getAgentByKey, createAgent, updateAgent, deleteAgent, publishAgent, unpublishAgent, } from "./api/agent-list.js";
|
|
32
34
|
export { listConversations, listMessages } from "./api/conversations.js";
|
|
@@ -41,9 +43,12 @@ export { ConversationsResource } from "./resources/conversations.js";
|
|
|
41
43
|
export { ContextLoaderResource } from "./resources/context-loader.js";
|
|
42
44
|
export { SkillsResource } from "./resources/skills.js";
|
|
43
45
|
export { ToolboxesResource } from "./resources/toolboxes.js";
|
|
46
|
+
export { ModelsResource, LlmModelsSubresource, SmallModelsSubresource, ModelInvocationSubresource, } from "./resources/models.js";
|
|
44
47
|
export { listSkills, listSkillMarket, getSkill, deleteSkill, updateSkillStatus, registerSkillContent, registerSkillZip, getSkillContentIndex, fetchSkillContent, readSkillFile, fetchSkillFile, downloadSkill, installSkillArchive, } from "./api/skills.js";
|
|
45
48
|
export { parseDataView, createDataView, getDataView, listDataViews, deleteDataView, findDataView, queryDataView, } from "./api/dataviews.js";
|
|
46
49
|
export { DataViewsResource } from "./resources/dataviews.js";
|
|
50
|
+
export { MF_MODEL_MANAGER_PATH_PREFIX, assertSmallModelConfigAdapterExclusive, assertSmallModelEditBody, listLlmModels, getLlmModel, addLlmModel, editLlmModel, deleteLlmModels, testLlmModel, listSmallModels, getSmallModel, addSmallModel, editSmallModel, deleteSmallModels, testSmallModel, } from "./api/models.js";
|
|
51
|
+
export { MF_MODEL_API_PATH_PREFIX, consumeOpenAiSseText, modelChatCompletions, modelEmbedding, modelEmbeddings, modelRerank, } from "./api/model-invocation.js";
|
|
47
52
|
export { listBusinessDomains } from "./api/business-domains.js";
|
|
48
53
|
export { createToolbox, deleteToolbox, setToolboxStatus, uploadTool, setToolStatuses, listToolboxes, listTools, executeTool, debugTool, } from "./api/toolboxes.js";
|
|
49
54
|
// ── HTTP utilities ────────────────────────────────────────────────────────────
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ClientContext } from "../client.js";
|
|
2
|
+
import { type ListLlmModelsOptions, type ListSmallModelsOptions, type MfManagerBaseOptions } from "../api/models.js";
|
|
3
|
+
import { type MfApiBaseOptions, type ModelChatCompletionsOptions, type ModelEmbeddingOptions, type ModelRerankOptions } from "../api/model-invocation.js";
|
|
4
|
+
type Base = MfManagerBaseOptions;
|
|
5
|
+
export declare class LlmModelsSubresource {
|
|
6
|
+
private readonly ctx;
|
|
7
|
+
constructor(ctx: ClientContext);
|
|
8
|
+
list(opts: Omit<ListLlmModelsOptions, keyof Base> & Partial<MfManagerBaseOptions>): Promise<unknown>;
|
|
9
|
+
get(modelId: string, opts?: Partial<Pick<MfManagerBaseOptions, "mfManagerBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
10
|
+
add(body: Record<string, unknown>, opts?: Partial<Pick<MfManagerBaseOptions, "mfManagerBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
11
|
+
edit(body: Record<string, unknown>, opts?: Partial<Pick<MfManagerBaseOptions, "mfManagerBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
12
|
+
delete(modelIds: string[], opts?: Partial<Pick<MfManagerBaseOptions, "mfManagerBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
13
|
+
test(body: Record<string, unknown>, opts?: Partial<Pick<MfManagerBaseOptions, "mfManagerBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
14
|
+
}
|
|
15
|
+
export declare class SmallModelsSubresource {
|
|
16
|
+
private readonly ctx;
|
|
17
|
+
constructor(ctx: ClientContext);
|
|
18
|
+
list(opts: Omit<ListSmallModelsOptions, keyof Base> & Partial<MfManagerBaseOptions>): Promise<unknown>;
|
|
19
|
+
get(modelId: string, opts?: Partial<Pick<MfManagerBaseOptions, "mfManagerBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
20
|
+
add(body: Record<string, unknown>, opts?: Partial<Pick<MfManagerBaseOptions, "mfManagerBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
21
|
+
edit(body: Record<string, unknown>, opts?: Partial<Pick<MfManagerBaseOptions, "mfManagerBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
22
|
+
delete(modelIds: string[], opts?: Partial<Pick<MfManagerBaseOptions, "mfManagerBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
23
|
+
test(body: Record<string, unknown>, opts?: Partial<Pick<MfManagerBaseOptions, "mfManagerBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
export declare class ModelInvocationSubresource {
|
|
26
|
+
private readonly ctx;
|
|
27
|
+
constructor(ctx: ClientContext);
|
|
28
|
+
chat(opts: Omit<ModelChatCompletionsOptions, "baseUrl" | "accessToken" | "businessDomain"> & Partial<Pick<MfApiBaseOptions, "mfApiBaseUrl" | "businessDomain">>): Promise<import("../api/model-invocation.js").ModelChatResult>;
|
|
29
|
+
embedding(opts: Omit<ModelEmbeddingOptions, "baseUrl" | "accessToken" | "businessDomain"> & Partial<Pick<MfApiBaseOptions, "mfApiBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
30
|
+
embeddings(opts: Omit<ModelEmbeddingOptions, "baseUrl" | "accessToken" | "businessDomain"> & Partial<Pick<MfApiBaseOptions, "mfApiBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
31
|
+
rerank(opts: Omit<ModelRerankOptions, "baseUrl" | "accessToken" | "businessDomain"> & Partial<Pick<MfApiBaseOptions, "mfApiBaseUrl" | "businessDomain">>): Promise<unknown>;
|
|
32
|
+
}
|
|
33
|
+
/** Model factory: mf-model-manager (CRUD) + mf-model-api (invoke chat / embedding / rerank). */
|
|
34
|
+
export declare class ModelsResource {
|
|
35
|
+
readonly llm: LlmModelsSubresource;
|
|
36
|
+
readonly small: SmallModelsSubresource;
|
|
37
|
+
readonly invocation: ModelInvocationSubresource;
|
|
38
|
+
constructor(ctx: ClientContext);
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { addLlmModel, addSmallModel, deleteLlmModels, deleteSmallModels, editLlmModel, editSmallModel, getLlmModel, getSmallModel, listLlmModels, listSmallModels, testLlmModel, testSmallModel, } from "../api/models.js";
|
|
2
|
+
import { modelChatCompletions, modelEmbedding, modelEmbeddings, modelRerank, } from "../api/model-invocation.js";
|
|
3
|
+
export class LlmModelsSubresource {
|
|
4
|
+
ctx;
|
|
5
|
+
constructor(ctx) {
|
|
6
|
+
this.ctx = ctx;
|
|
7
|
+
}
|
|
8
|
+
list(opts) {
|
|
9
|
+
return listLlmModels({ ...this.ctx.base(), ...opts });
|
|
10
|
+
}
|
|
11
|
+
get(modelId, opts = {}) {
|
|
12
|
+
return getLlmModel({ ...this.ctx.base(), modelId, ...opts });
|
|
13
|
+
}
|
|
14
|
+
add(body, opts = {}) {
|
|
15
|
+
return addLlmModel({ ...this.ctx.base(), body, ...opts });
|
|
16
|
+
}
|
|
17
|
+
edit(body, opts = {}) {
|
|
18
|
+
return editLlmModel({ ...this.ctx.base(), body, ...opts });
|
|
19
|
+
}
|
|
20
|
+
delete(modelIds, opts = {}) {
|
|
21
|
+
return deleteLlmModels({ ...this.ctx.base(), modelIds, ...opts });
|
|
22
|
+
}
|
|
23
|
+
test(body, opts = {}) {
|
|
24
|
+
return testLlmModel({ ...this.ctx.base(), body, ...opts });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class SmallModelsSubresource {
|
|
28
|
+
ctx;
|
|
29
|
+
constructor(ctx) {
|
|
30
|
+
this.ctx = ctx;
|
|
31
|
+
}
|
|
32
|
+
list(opts) {
|
|
33
|
+
return listSmallModels({ ...this.ctx.base(), ...opts });
|
|
34
|
+
}
|
|
35
|
+
get(modelId, opts = {}) {
|
|
36
|
+
return getSmallModel({ ...this.ctx.base(), modelId, ...opts });
|
|
37
|
+
}
|
|
38
|
+
add(body, opts = {}) {
|
|
39
|
+
return addSmallModel({ ...this.ctx.base(), body, ...opts });
|
|
40
|
+
}
|
|
41
|
+
edit(body, opts = {}) {
|
|
42
|
+
return editSmallModel({ ...this.ctx.base(), body, ...opts });
|
|
43
|
+
}
|
|
44
|
+
delete(modelIds, opts = {}) {
|
|
45
|
+
return deleteSmallModels({ ...this.ctx.base(), modelIds, ...opts });
|
|
46
|
+
}
|
|
47
|
+
test(body, opts = {}) {
|
|
48
|
+
return testSmallModel({ ...this.ctx.base(), body, ...opts });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export class ModelInvocationSubresource {
|
|
52
|
+
ctx;
|
|
53
|
+
constructor(ctx) {
|
|
54
|
+
this.ctx = ctx;
|
|
55
|
+
}
|
|
56
|
+
chat(opts) {
|
|
57
|
+
const { baseUrl, accessToken, businessDomain } = this.ctx.base();
|
|
58
|
+
return modelChatCompletions({
|
|
59
|
+
baseUrl,
|
|
60
|
+
accessToken,
|
|
61
|
+
businessDomain,
|
|
62
|
+
...opts,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
embedding(opts) {
|
|
66
|
+
const { baseUrl, accessToken, businessDomain } = this.ctx.base();
|
|
67
|
+
return modelEmbedding({ baseUrl, accessToken, businessDomain, ...opts });
|
|
68
|
+
}
|
|
69
|
+
embeddings(opts) {
|
|
70
|
+
const { baseUrl, accessToken, businessDomain } = this.ctx.base();
|
|
71
|
+
return modelEmbeddings({ baseUrl, accessToken, businessDomain, ...opts });
|
|
72
|
+
}
|
|
73
|
+
rerank(opts) {
|
|
74
|
+
const { baseUrl, accessToken, businessDomain } = this.ctx.base();
|
|
75
|
+
return modelRerank({ baseUrl, accessToken, businessDomain, ...opts });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Model factory: mf-model-manager (CRUD) + mf-model-api (invoke chat / embedding / rerank). */
|
|
79
|
+
export class ModelsResource {
|
|
80
|
+
llm;
|
|
81
|
+
small;
|
|
82
|
+
invocation;
|
|
83
|
+
constructor(ctx) {
|
|
84
|
+
this.llm = new LlmModelsSubresource(ctx);
|
|
85
|
+
this.small = new SmallModelsSubresource(ctx);
|
|
86
|
+
this.invocation = new ModelInvocationSubresource(ctx);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -6,6 +6,8 @@ export interface InvokeToolArgs {
|
|
|
6
6
|
* send no headers. */
|
|
7
7
|
header?: Record<string, unknown>;
|
|
8
8
|
query?: Record<string, unknown>;
|
|
9
|
+
/** Path parameters for OpenAPI `{name}` placeholders (e.g. `{ id: "<uuid>" }`). */
|
|
10
|
+
path?: Record<string, unknown>;
|
|
9
11
|
body?: unknown;
|
|
10
12
|
/** Per-call timeout in seconds (backend default applies when omitted). */
|
|
11
13
|
timeout?: number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "document",
|
|
3
|
+
"type": "bkn",
|
|
4
|
+
"description": "文档知识网络",
|
|
5
|
+
"arguments": [
|
|
6
|
+
{ "name": "name", "required": true, "description": "BKN 名称", "type": "string" },
|
|
7
|
+
{ "name": "embedding_model_id", "required": true, "description": "向量化模型 ID", "type": "string" },
|
|
8
|
+
{ "name": "content_dataset_id", "required": true, "description": "内容数据集 ID", "type": "string" },
|
|
9
|
+
{ "name": "document_dataset_id", "required": true, "description": "文档数据集 ID", "type": "string" },
|
|
10
|
+
{ "name": "element_dataset_id", "required": true, "description": "元素数据集 ID", "type": "string" }
|
|
11
|
+
]
|
|
12
|
+
}
|