@2kw/ai 6.1.0-dev.7 → 6.1.0-dev.8
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 +1 -1
- package/dist/commands/ai.d.ts +1 -1
- package/dist/commands/ai.js +1 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ kubectl-style contexts switch between organizations and environments:
|
|
|
99
99
|
| `prompts` | Versioned prompt management, labels, compilation, testing |
|
|
100
100
|
| `extractions` | Create extractions (text, file, images), list, re-run, estimate tokens |
|
|
101
101
|
| `convert` | Convert PDF, DOCX, XLSX, images, and 20+ formats to Markdown/text/HTML/JSON |
|
|
102
|
-
| `ai` | Chat completions, Responses (agent or direct model, streaming),
|
|
102
|
+
| `ai` | Chat completions, Responses (agent or direct model, streaming), and model listing via the OpenAI-compatible gateway |
|
|
103
103
|
| `transcribe` | Transcribe audio (FLAC, MP3, MP4, OGG, WAV, WebM) |
|
|
104
104
|
| `datasets` | Build datasets and dataset versions for evaluation |
|
|
105
105
|
| `experiments` | Run experiments against datasets |
|
package/dist/commands/ai.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Command } from "commander";
|
|
|
3
3
|
* Reads a single text input from stdin, or `undefined` when stdin is a TTY
|
|
4
4
|
* (nothing was piped in) or empty. Mirrors the `-` stdin convention used by
|
|
5
5
|
* `bb convert file`, but always reads stdin implicitly (there is no `-`
|
|
6
|
-
* sentinel here since
|
|
6
|
+
* sentinel here since `respond` takes a plain input string).
|
|
7
7
|
*/
|
|
8
8
|
export declare function readStdinInput(): string | undefined;
|
|
9
9
|
/**
|
package/dist/commands/ai.js
CHANGED
|
@@ -9,7 +9,7 @@ import chalk from "chalk";
|
|
|
9
9
|
* Reads a single text input from stdin, or `undefined` when stdin is a TTY
|
|
10
10
|
* (nothing was piped in) or empty. Mirrors the `-` stdin convention used by
|
|
11
11
|
* `bb convert file`, but always reads stdin implicitly (there is no `-`
|
|
12
|
-
* sentinel here since
|
|
12
|
+
* sentinel here since `respond` takes a plain input string).
|
|
13
13
|
*/
|
|
14
14
|
export function readStdinInput() {
|
|
15
15
|
if (process.stdin.isTTY)
|
|
@@ -157,21 +157,6 @@ async function streamResponse(command, body) {
|
|
|
157
157
|
process.stdout.write("\n");
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
function printEmbeddingResult(result, command) {
|
|
161
|
-
if (isJsonOutput(command)) {
|
|
162
|
-
console.log(JSON.stringify(result, null, 2));
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const items = result?.data ?? [];
|
|
166
|
-
console.log(chalk.green(`Received ${items.length} embedding${items.length !== 1 ? "s" : ""}.`));
|
|
167
|
-
items.forEach((item, i) => {
|
|
168
|
-
const dims = item.embedding?.length ?? 0;
|
|
169
|
-
console.log(` [${item.index ?? i}] ${dims} dimensions`);
|
|
170
|
-
});
|
|
171
|
-
if (result?.usage) {
|
|
172
|
-
console.log(chalk.dim(`\n[${result.model} | ${result.usage.prompt_tokens} prompt / ${result.usage.total_tokens} total tokens]`));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
160
|
export function makeAiCommand() {
|
|
176
161
|
const cmd = new Command("ai").description("AI gateway operations");
|
|
177
162
|
cmd
|
|
@@ -257,28 +242,6 @@ export function makeAiCommand() {
|
|
|
257
242
|
}
|
|
258
243
|
});
|
|
259
244
|
});
|
|
260
|
-
cmd
|
|
261
|
-
.command("embed")
|
|
262
|
-
.description("Create embeddings for input text")
|
|
263
|
-
.argument("[input]", "Text to embed (reads stdin if omitted)")
|
|
264
|
-
.requiredOption("-m, --model <model>", "Model (provider/model format)")
|
|
265
|
-
.action(async (input, opts, command) => {
|
|
266
|
-
await runAction(command, async () => {
|
|
267
|
-
const inputText = input ?? readStdinInput();
|
|
268
|
-
if (!inputText) {
|
|
269
|
-
throw new Error("Input is required as an argument or via stdin.");
|
|
270
|
-
}
|
|
271
|
-
const client = getClient(command);
|
|
272
|
-
const body = { model: opts.model, input: inputText };
|
|
273
|
-
const { data } = await withSpinner("Embedding...", () =>
|
|
274
|
-
// POST /v1/embeddings has no request body in the generated spec
|
|
275
|
-
// (backend: "Not yet implemented"); cast, same as the untyped
|
|
276
|
-
// convert.ts source-conversion calls.
|
|
277
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
278
|
-
client.POST("/v1/embeddings", { body }));
|
|
279
|
-
printEmbeddingResult(data, command);
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
245
|
cmd
|
|
283
246
|
.command("models")
|
|
284
247
|
.description("List available AI models")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2kw/ai",
|
|
3
|
-
"version": "6.1.0-dev.
|
|
3
|
+
"version": "6.1.0-dev.8",
|
|
4
4
|
"description": "CLI for 2kw.ai — schema-driven document extraction, an OpenAI-compatible EU LLM gateway, transcription, prompts, datasets, and experiments from your terminal or agentic workflows. Ships as 2kw, backbone, and bb.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|