@openbkn/bkn-sdk 0.1.1-alpha.13 → 0.1.1-alpha.14
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/{chunk-RSX5YMFM.js → chunk-2GNQU4XH.js} +26 -3
- package/dist/chunk-2GNQU4XH.js.map +1 -0
- package/dist/cli.js +46 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-RSX5YMFM.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
use,
|
|
38
38
|
whoami,
|
|
39
39
|
writePlatformConfig
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-2GNQU4XH.js";
|
|
41
41
|
|
|
42
42
|
// src/cli.ts
|
|
43
43
|
import { Command as Command17 } from "commander";
|
|
@@ -45,7 +45,7 @@ import { Command as Command17 } from "commander";
|
|
|
45
45
|
// package.json
|
|
46
46
|
var package_default = {
|
|
47
47
|
name: "@openbkn/bkn-sdk",
|
|
48
|
-
version: "0.1.1-alpha.
|
|
48
|
+
version: "0.1.1-alpha.14",
|
|
49
49
|
description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
|
|
50
50
|
type: "module",
|
|
51
51
|
license: "Apache-2.0",
|
|
@@ -1983,6 +1983,12 @@ async function handle(client, reqMsg, res) {
|
|
|
1983
1983
|
// src/commands/model.ts
|
|
1984
1984
|
import { Command as Command11 } from "commander";
|
|
1985
1985
|
var int8 = (v) => Number.parseInt(v, 10);
|
|
1986
|
+
async function resolveLlmModelName(client, model) {
|
|
1987
|
+
if (!/^\d+$/.test(model)) return model;
|
|
1988
|
+
const detail = await client.models.llm.get(model);
|
|
1989
|
+
if (!detail?.model_name) throw new InputError(`No LLM found with id ${model}.`);
|
|
1990
|
+
return detail.model_name;
|
|
1991
|
+
}
|
|
1986
1992
|
function addManagementCommands(parent, kind) {
|
|
1987
1993
|
parent.command("add").description("Register a model (definition JSON via --body / --body-file)").option("--body <json>", "model definition JSON").option("--body-file <path>", "read model definition JSON from a file").action(async (opts, cmd) => {
|
|
1988
1994
|
printJson(await clientFrom(cmd).models[kind].add(readBody(opts)), outputOptions(cmd));
|
|
@@ -1998,7 +2004,9 @@ function addManagementCommands(parent, kind) {
|
|
|
1998
2004
|
});
|
|
1999
2005
|
}
|
|
2000
2006
|
function modelCommand() {
|
|
2001
|
-
const model = new Command11("model").description(
|
|
2007
|
+
const model = new Command11("model").description(
|
|
2008
|
+
"Model factory \u2014 LLM / small-model CRUD, chat / embeddings / rerank, default selection"
|
|
2009
|
+
);
|
|
2002
2010
|
const llm = model.command("llm").description("Large language models");
|
|
2003
2011
|
llm.command("list").description("List LLM models").option("--name <s>", "filter by name").option("--type <t>", "model type filter").option("--limit <n>", "page size", int8, DEFAULT_LIST_LIMIT).option("--page <n>", "page", int8, 1).action(async (opts, cmd) => {
|
|
2004
2012
|
printJson(
|
|
@@ -2014,14 +2022,22 @@ function modelCommand() {
|
|
|
2014
2022
|
llm.command("get <modelId>").description("Get an LLM model").action(async (id, _opts, cmd) => {
|
|
2015
2023
|
printJson(await clientFrom(cmd).models.llm.get(id), outputOptions(cmd));
|
|
2016
2024
|
});
|
|
2017
|
-
llm.command("chat <
|
|
2025
|
+
llm.command("chat <model>").description("OpenAI-compatible chat completion (<model> = model name or numeric id)").requiredOption("-m, --message <text>", "user message").option("--stream", "stream the reply token-by-token to stdout").action(async (model2, opts, cmd) => {
|
|
2026
|
+
const client = clientFrom(cmd);
|
|
2027
|
+
const name = await resolveLlmModelName(client, model2);
|
|
2018
2028
|
const messages = [{ role: "user", content: opts.message }];
|
|
2019
2029
|
if (opts.stream) {
|
|
2020
|
-
await
|
|
2030
|
+
await client.models.llm.chatStream(name, messages, (t) => process.stdout.write(t));
|
|
2021
2031
|
process.stdout.write("\n");
|
|
2022
2032
|
return;
|
|
2023
2033
|
}
|
|
2024
|
-
printJson(await
|
|
2034
|
+
printJson(await client.models.llm.chat(name, messages), outputOptions(cmd));
|
|
2035
|
+
});
|
|
2036
|
+
llm.command("set-default <modelId>").description("Set this LLM as the system default (admin)").action(async (id, _opts, cmd) => {
|
|
2037
|
+
printJson(await clientFrom(cmd).models.llm.setDefault(id, true), outputOptions(cmd));
|
|
2038
|
+
});
|
|
2039
|
+
llm.command("unset-default <modelId>").description("Clear this LLM as the system default (admin)").action(async (id, _opts, cmd) => {
|
|
2040
|
+
printJson(await clientFrom(cmd).models.llm.setDefault(id, false), outputOptions(cmd));
|
|
2025
2041
|
});
|
|
2026
2042
|
addManagementCommands(llm, "llm");
|
|
2027
2043
|
const small = model.command("small").description("Small models (embedding / reranker)");
|
|
@@ -2051,7 +2067,31 @@ function modelCommand() {
|
|
|
2051
2067
|
outputOptions(cmd)
|
|
2052
2068
|
);
|
|
2053
2069
|
});
|
|
2070
|
+
small.command("get-default").description("Show the system default small model for a type").option("--type <t>", "model type: embedding | reranker", "embedding").action(async (opts, cmd) => {
|
|
2071
|
+
printJson(await clientFrom(cmd).models.small.getDefault(opts.type), outputOptions(cmd));
|
|
2072
|
+
});
|
|
2073
|
+
small.command("set-default <modelId>").description("Set this small model as the system default for its type (admin)").action(async (id, _opts, cmd) => {
|
|
2074
|
+
printJson(await clientFrom(cmd).models.small.setDefault(id, true), outputOptions(cmd));
|
|
2075
|
+
});
|
|
2076
|
+
small.command("unset-default <modelId>").description("Clear this small model as the system default (admin)").action(async (id, _opts, cmd) => {
|
|
2077
|
+
printJson(await clientFrom(cmd).models.small.setDefault(id, false), outputOptions(cmd));
|
|
2078
|
+
});
|
|
2054
2079
|
addManagementCommands(small, "small");
|
|
2080
|
+
model.addHelpText(
|
|
2081
|
+
"after",
|
|
2082
|
+
`
|
|
2083
|
+
Identifiers:
|
|
2084
|
+
\u2022 get / set-default / delete take the numeric model id (e.g. 2071747547839467520).
|
|
2085
|
+
\u2022 chat takes a model NAME, but also accepts a numeric id (resolved to its name).
|
|
2086
|
+
|
|
2087
|
+
Examples:
|
|
2088
|
+
$ openbkn model llm list # ids + the 'default' flag
|
|
2089
|
+
$ openbkn model llm chat deepseek_v4_flash -m hi # by name
|
|
2090
|
+
$ openbkn model llm chat 2071747547839467520 -m hi --stream # by id, streamed
|
|
2091
|
+
$ openbkn model llm set-default 2071747547839467520 # system default LLM
|
|
2092
|
+
$ openbkn model small get-default --type embedding # current default
|
|
2093
|
+
$ openbkn model small set-default <id> # default embedding/reranker`
|
|
2094
|
+
);
|
|
2055
2095
|
return group(model, "MODELS & SKILLS");
|
|
2056
2096
|
}
|
|
2057
2097
|
|