@2kw/ai 6.1.0-dev.10 → 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/dist/commands/scores.js +5 -43
- package/dist/index.js +0 -2
- package/package.json +1 -1
- package/dist/commands/queues.d.ts +0 -11
- package/dist/commands/queues.js +0 -244
package/dist/commands/scores.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { getClient, runAction } from "../lib/client.js";
|
|
3
|
-
import { formatDetail
|
|
3
|
+
import { formatDetail } from "../lib/output.js";
|
|
4
4
|
export function makeScoresCommand() {
|
|
5
|
-
const cmd = new Command("scores").description("Record
|
|
5
|
+
const cmd = new Command("scores").description("Record evaluation scores on experiment run results");
|
|
6
6
|
cmd
|
|
7
7
|
.command("human")
|
|
8
|
-
.description("Record a human score. Upserts by (
|
|
9
|
-
"--run-result
|
|
10
|
-
.option("--run-result <id>", "Run result ID (legacy shape)")
|
|
11
|
-
.option("--subject-type <type>", "RUN_RESULT | TRACE | SPAN | DATASET_ITEM")
|
|
12
|
-
.option("--subject-id <id>", "Subject ID")
|
|
13
|
-
.option("--queue-item <id>", "Annotation queue item ID this score resolves")
|
|
8
|
+
.description("Record a human score for a run result. Upserts by (runResultId, evaluatorId, annotatorId).")
|
|
9
|
+
.requiredOption("--run-result <id>", "Run result ID")
|
|
14
10
|
.requiredOption("--evaluator <id>", "Evaluator identifier (e.g. 'helpfulness' or a template id)")
|
|
15
|
-
.
|
|
11
|
+
.requiredOption("--score <number>", "Score between 0.0 and 1.0", parseFloat)
|
|
16
12
|
.option("--label <text>", "Short label (e.g. 'pass', 'fail', 'good')")
|
|
17
13
|
.option("--comment <text>", "Optional reviewer note")
|
|
18
14
|
.action(async (opts, command) => {
|
|
@@ -21,9 +17,6 @@ export function makeScoresCommand() {
|
|
|
21
17
|
const { data } = await client.POST("/v1/evaluation-scores/human", {
|
|
22
18
|
body: {
|
|
23
19
|
runResultId: opts.runResult,
|
|
24
|
-
subjectType: opts.subjectType,
|
|
25
|
-
subjectId: opts.subjectId,
|
|
26
|
-
annotationQueueItemId: opts.queueItem,
|
|
27
20
|
evaluatorId: opts.evaluator,
|
|
28
21
|
score: opts.score,
|
|
29
22
|
label: opts.label,
|
|
@@ -33,37 +26,6 @@ export function makeScoresCommand() {
|
|
|
33
26
|
formatDetail(data, command);
|
|
34
27
|
});
|
|
35
28
|
});
|
|
36
|
-
cmd
|
|
37
|
-
.command("list")
|
|
38
|
-
.description("List human scores filed against a subject. Defaults to the caller's own scores — " +
|
|
39
|
-
"pass --annotator to see another reviewer's.")
|
|
40
|
-
.requiredOption("--subject-type <type>", "RUN_RESULT | TRACE | SPAN | DATASET_ITEM")
|
|
41
|
-
.requiredOption("--subject-id <id>", "Subject ID")
|
|
42
|
-
.option("--annotator <id>", "Annotator ID (defaults to the caller)")
|
|
43
|
-
.action(async (opts, command) => {
|
|
44
|
-
await runAction(command, async () => {
|
|
45
|
-
const client = getClient(command);
|
|
46
|
-
const { data } = await client.GET("/v1/evaluation-scores/human", {
|
|
47
|
-
params: {
|
|
48
|
-
query: {
|
|
49
|
-
subjectType: opts.subjectType,
|
|
50
|
-
subjectId: opts.subjectId,
|
|
51
|
-
annotatorId: opts.annotator,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
-
formatList(data, command, [
|
|
57
|
-
"id",
|
|
58
|
-
"evaluatorId",
|
|
59
|
-
"score",
|
|
60
|
-
"label",
|
|
61
|
-
"annotatorId",
|
|
62
|
-
"comment",
|
|
63
|
-
"createdAt",
|
|
64
|
-
]);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
29
|
return cmd;
|
|
68
30
|
}
|
|
69
31
|
//# sourceMappingURL=scores.js.map
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,6 @@ import { makeExperimentsCommand } from "./commands/experiments.js";
|
|
|
21
21
|
import { makeTracingCommand } from "./commands/tracing.js";
|
|
22
22
|
import { makeEvaluatorsCommand } from "./commands/evaluators.js";
|
|
23
23
|
import { makeScoresCommand } from "./commands/scores.js";
|
|
24
|
-
import { makeQueuesCommand } from "./commands/queues.js";
|
|
25
24
|
import { makeAgentsCommand } from "./commands/agents.js";
|
|
26
25
|
import { makeConversationsCommand } from "./commands/conversations.js";
|
|
27
26
|
import { makeKnowledgeCommand } from "./commands/knowledge.js";
|
|
@@ -54,7 +53,6 @@ program.addCommand(makeDatasetsCommand());
|
|
|
54
53
|
program.addCommand(makeExperimentsCommand());
|
|
55
54
|
program.addCommand(makeEvaluatorsCommand());
|
|
56
55
|
program.addCommand(makeScoresCommand());
|
|
57
|
-
program.addCommand(makeQueuesCommand());
|
|
58
56
|
program.addCommand(makeTracingCommand());
|
|
59
57
|
program.addCommand(makeAgentsCommand());
|
|
60
58
|
program.addCommand(makeConversationsCommand());
|
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",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* Annotation queues let a human reviewer work through a curated list of
|
|
4
|
-
* subjects (run results, traces, spans, dataset items). This command group
|
|
5
|
-
* covers the queue itself plus the items inside it: creating a queue,
|
|
6
|
-
* bulk-adding subjects, claiming the next eligible item, and recording the
|
|
7
|
-
* outcome — the full loop an agent or a human reviewer needs to run review
|
|
8
|
-
* end to end from the CLI.
|
|
9
|
-
*/
|
|
10
|
-
export declare function makeQueuesCommand(): Command;
|
|
11
|
-
//# sourceMappingURL=queues.d.ts.map
|
package/dist/commands/queues.js
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { getClient, runAction } from "../lib/client.js";
|
|
4
|
-
import { isJsonOutput } from "../lib/config.js";
|
|
5
|
-
import { formatList, formatDetail, formatSuccess } from "../lib/output.js";
|
|
6
|
-
/**
|
|
7
|
-
* Annotation queues let a human reviewer work through a curated list of
|
|
8
|
-
* subjects (run results, traces, spans, dataset items). This command group
|
|
9
|
-
* covers the queue itself plus the items inside it: creating a queue,
|
|
10
|
-
* bulk-adding subjects, claiming the next eligible item, and recording the
|
|
11
|
-
* outcome — the full loop an agent or a human reviewer needs to run review
|
|
12
|
-
* end to end from the CLI.
|
|
13
|
-
*/
|
|
14
|
-
export function makeQueuesCommand() {
|
|
15
|
-
const cmd = new Command("queues").description("Manage annotation queues for human review");
|
|
16
|
-
// ── list ──────────────────────────────────────────────────────
|
|
17
|
-
cmd
|
|
18
|
-
.command("list")
|
|
19
|
-
.description("List annotation queues")
|
|
20
|
-
.option("--archived", "List archived queues instead of active ones", false)
|
|
21
|
-
.action(async (opts, command) => {
|
|
22
|
-
await runAction(command, async () => {
|
|
23
|
-
const client = getClient(command);
|
|
24
|
-
const { data } = await client.GET("/v1/annotation-queues", {
|
|
25
|
-
params: { query: { archived: opts.archived } },
|
|
26
|
-
});
|
|
27
|
-
formatList(data, command, [
|
|
28
|
-
"id",
|
|
29
|
-
"name",
|
|
30
|
-
"description",
|
|
31
|
-
"archivedAt",
|
|
32
|
-
"createdAt",
|
|
33
|
-
]);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
// ── get ───────────────────────────────────────────────────────
|
|
37
|
-
cmd
|
|
38
|
-
.command("get")
|
|
39
|
-
.description("Get an annotation queue by ID")
|
|
40
|
-
.argument("<id>", "Queue ID")
|
|
41
|
-
.action(async (id, _opts, command) => {
|
|
42
|
-
await runAction(command, async () => {
|
|
43
|
-
const client = getClient(command);
|
|
44
|
-
const { data } = await client.GET("/v1/annotation-queues/{id}", {
|
|
45
|
-
params: { path: { id } },
|
|
46
|
-
});
|
|
47
|
-
formatDetail(data, command);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
// ── create ────────────────────────────────────────────────────
|
|
51
|
-
cmd
|
|
52
|
-
.command("create")
|
|
53
|
-
.description("Create a new annotation queue")
|
|
54
|
-
.requiredOption("-n, --name <name>", "Queue name")
|
|
55
|
-
.option("-d, --description <text>", "Queue description")
|
|
56
|
-
.action(async (opts, command) => {
|
|
57
|
-
await runAction(command, async () => {
|
|
58
|
-
const client = getClient(command);
|
|
59
|
-
const { data } = await client.POST("/v1/annotation-queues", {
|
|
60
|
-
body: { name: opts.name, description: opts.description },
|
|
61
|
-
});
|
|
62
|
-
formatDetail(data, command);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
// ── update ────────────────────────────────────────────────────
|
|
66
|
-
cmd
|
|
67
|
-
.command("update")
|
|
68
|
-
.description("Update a queue's name or description")
|
|
69
|
-
.argument("<id>", "Queue ID")
|
|
70
|
-
.option("-n, --name <name>", "New name")
|
|
71
|
-
.option("-d, --description <text>", "New description")
|
|
72
|
-
.action(async (id, opts, command) => {
|
|
73
|
-
await runAction(command, async () => {
|
|
74
|
-
const client = getClient(command);
|
|
75
|
-
const body = {};
|
|
76
|
-
if (opts.name !== undefined)
|
|
77
|
-
body.name = opts.name;
|
|
78
|
-
if (opts.description !== undefined)
|
|
79
|
-
body.description = opts.description;
|
|
80
|
-
const { data } = await client.PATCH("/v1/annotation-queues/{id}", {
|
|
81
|
-
params: { path: { id } },
|
|
82
|
-
body: body,
|
|
83
|
-
});
|
|
84
|
-
formatDetail(data, command);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
// ── archive ───────────────────────────────────────────────────
|
|
88
|
-
cmd
|
|
89
|
-
.command("archive")
|
|
90
|
-
.description("Archive a queue (idempotent)")
|
|
91
|
-
.argument("<id>", "Queue ID")
|
|
92
|
-
.action(async (id, _opts, command) => {
|
|
93
|
-
await runAction(command, async () => {
|
|
94
|
-
const client = getClient(command);
|
|
95
|
-
await client.POST("/v1/annotation-queues/{id}/archive", {
|
|
96
|
-
params: { path: { id } },
|
|
97
|
-
});
|
|
98
|
-
formatSuccess(`Queue ${id} archived.`, command);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
// ── by-subject ────────────────────────────────────────────────
|
|
102
|
-
cmd
|
|
103
|
-
.command("by-subject")
|
|
104
|
-
.description("Find queue items referencing a subject, across every queue")
|
|
105
|
-
.requiredOption("--subject-type <type>", "RUN_RESULT | TRACE | SPAN | DATASET_ITEM")
|
|
106
|
-
.requiredOption("--subject-id <id>", "Subject ID")
|
|
107
|
-
.action(async (opts, command) => {
|
|
108
|
-
await runAction(command, async () => {
|
|
109
|
-
const client = getClient(command);
|
|
110
|
-
const { data } = await client.GET("/v1/annotation-queues/by-subject", {
|
|
111
|
-
params: {
|
|
112
|
-
query: { subjectType: opts.subjectType, subjectId: opts.subjectId },
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
formatList(data, command, [
|
|
116
|
-
"id",
|
|
117
|
-
"queueId",
|
|
118
|
-
"subjectType",
|
|
119
|
-
"subjectId",
|
|
120
|
-
"status",
|
|
121
|
-
"assignedTo",
|
|
122
|
-
]);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
// ── next ──────────────────────────────────────────────────────
|
|
126
|
-
cmd
|
|
127
|
-
.command("next")
|
|
128
|
-
.description("Claim the next eligible item in a queue for the caller")
|
|
129
|
-
.argument("<id>", "Queue ID")
|
|
130
|
-
.action(async (id, _opts, command) => {
|
|
131
|
-
await runAction(command, async () => {
|
|
132
|
-
const client = getClient(command);
|
|
133
|
-
const { data } = await client.GET("/v1/annotation-queues/{id}/items/next", {
|
|
134
|
-
params: { path: { id } },
|
|
135
|
-
});
|
|
136
|
-
if (!data) {
|
|
137
|
-
// 204 No Content: the queue has nothing left for this caller. A
|
|
138
|
-
// normal end state, not an error — printed plainly either way.
|
|
139
|
-
if (isJsonOutput(command)) {
|
|
140
|
-
console.log(JSON.stringify(null));
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
console.log(chalk.dim("No items available to claim — the queue is empty for you."));
|
|
144
|
-
}
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
formatDetail(data, command);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
// ── items ─────────────────────────────────────────────────────
|
|
151
|
-
const items = new Command("items").description("Manage items within an annotation queue");
|
|
152
|
-
items
|
|
153
|
-
.command("list")
|
|
154
|
-
.description("List items in a queue")
|
|
155
|
-
.requiredOption("--queue <id>", "Queue ID")
|
|
156
|
-
.option("--status <status>", "PENDING | IN_PROGRESS | DONE | SKIPPED")
|
|
157
|
-
.option("--assigned-to <userId>", "Filter by assignee")
|
|
158
|
-
.option("-p, --page <number>", "Page number (0-indexed)", "0")
|
|
159
|
-
.option("--size <number>", "Page size", "50")
|
|
160
|
-
.action(async (opts, command) => {
|
|
161
|
-
await runAction(command, async () => {
|
|
162
|
-
const client = getClient(command);
|
|
163
|
-
const { data } = await client.GET("/v1/annotation-queues/{id}/items", {
|
|
164
|
-
params: {
|
|
165
|
-
path: { id: opts.queue },
|
|
166
|
-
query: {
|
|
167
|
-
status: opts.status,
|
|
168
|
-
assignedTo: opts.assignedTo,
|
|
169
|
-
page: opts.page !== undefined ? parseInt(opts.page, 10) : undefined,
|
|
170
|
-
size: opts.size !== undefined ? parseInt(opts.size, 10) : undefined,
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
formatList(data, command, [
|
|
175
|
-
"id",
|
|
176
|
-
"subjectType",
|
|
177
|
-
"subjectId",
|
|
178
|
-
"status",
|
|
179
|
-
"assignedTo",
|
|
180
|
-
"createdAt",
|
|
181
|
-
]);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
items
|
|
185
|
-
.command("add")
|
|
186
|
-
.description("Bulk-add subjects to a queue (duplicates skipped)")
|
|
187
|
-
.requiredOption("--queue <id>", "Queue ID")
|
|
188
|
-
.requiredOption("--items <json>", 'JSON array of {"subjectType","subjectId"} objects')
|
|
189
|
-
.action(async (opts, command) => {
|
|
190
|
-
await runAction(command, async () => {
|
|
191
|
-
const client = getClient(command);
|
|
192
|
-
const parsedItems = JSON.parse(opts.items);
|
|
193
|
-
const { data } = await client.POST("/v1/annotation-queues/{id}/items", {
|
|
194
|
-
params: { path: { id: opts.queue } },
|
|
195
|
-
body: { items: parsedItems },
|
|
196
|
-
});
|
|
197
|
-
formatList(data, command, [
|
|
198
|
-
"id",
|
|
199
|
-
"subjectType",
|
|
200
|
-
"subjectId",
|
|
201
|
-
"status",
|
|
202
|
-
]);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
items
|
|
206
|
-
.command("get")
|
|
207
|
-
.description("Get a single queue item")
|
|
208
|
-
.argument("<itemId>", "Item ID")
|
|
209
|
-
.requiredOption("--queue <id>", "Queue ID")
|
|
210
|
-
.action(async (itemId, opts, command) => {
|
|
211
|
-
await runAction(command, async () => {
|
|
212
|
-
const client = getClient(command);
|
|
213
|
-
const { data } = await client.GET("/v1/annotation-queues/{id}/items/{itemId}", {
|
|
214
|
-
params: { path: { id: opts.queue, itemId } },
|
|
215
|
-
});
|
|
216
|
-
formatDetail(data, command);
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
items
|
|
220
|
-
.command("update")
|
|
221
|
-
.description("Update a queue item's status or assignee — the outcome of a review")
|
|
222
|
-
.argument("<itemId>", "Item ID")
|
|
223
|
-
.requiredOption("--queue <id>", "Queue ID")
|
|
224
|
-
.option("--status <status>", "PENDING | IN_PROGRESS | DONE | SKIPPED")
|
|
225
|
-
.option("--assigned-to <userId>", "New assignee")
|
|
226
|
-
.action(async (itemId, opts, command) => {
|
|
227
|
-
await runAction(command, async () => {
|
|
228
|
-
const client = getClient(command);
|
|
229
|
-
const body = {};
|
|
230
|
-
if (opts.status !== undefined)
|
|
231
|
-
body.status = opts.status;
|
|
232
|
-
if (opts.assignedTo !== undefined)
|
|
233
|
-
body.assignedTo = opts.assignedTo;
|
|
234
|
-
const { data } = await client.PATCH("/v1/annotation-queues/{id}/items/{itemId}", {
|
|
235
|
-
params: { path: { id: opts.queue, itemId } },
|
|
236
|
-
body: body,
|
|
237
|
-
});
|
|
238
|
-
formatDetail(data, command);
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
cmd.addCommand(items);
|
|
242
|
-
return cmd;
|
|
243
|
-
}
|
|
244
|
-
//# sourceMappingURL=queues.js.map
|