@answerlayer/cli 0.1.3 → 0.1.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 +8 -2
- package/package.json +1 -1
- package/skills/answerlayer/SKILL.md +1 -0
- package/src/cli.js +170 -1
package/README.md
CHANGED
|
@@ -130,7 +130,8 @@ Useful scopes:
|
|
|
130
130
|
- `saved_query:read`, `saved_query:execute`, and `saved_query:write` for saved-query workflows
|
|
131
131
|
- `semantic:read`, `semantic:write`, and `semantic:generate` for semantic-layer workflows
|
|
132
132
|
- `dashboard:read`, `dashboard:write`, `tile:read`, and `tile:write` for dashboard workflows
|
|
133
|
-
- `inquiry:
|
|
133
|
+
- `inquiry:read` to inspect inquiry sessions and evaluation suites/runs
|
|
134
|
+
- `inquiry:execute` for natural-language inquiry and to manage/run evaluations
|
|
134
135
|
|
|
135
136
|
## Commands
|
|
136
137
|
|
|
@@ -159,6 +160,11 @@ answerlayer semantic metrics generate --connection <connection-id> --prompt "Saa
|
|
|
159
160
|
answerlayer inquiry ask --connection <connection-id> "What changed in revenue this month?"
|
|
160
161
|
answerlayer inquiry ask --session <session-id> "Break that down by region"
|
|
161
162
|
|
|
163
|
+
answerlayer evals suites create --name "Revenue checks" --connection <connection-id>
|
|
164
|
+
answerlayer evals cases create <suite-id> --title "Monthly revenue" --question "What was revenue last month?" --expected-sql "select sum(amount) from orders where ..."
|
|
165
|
+
answerlayer evals runs create <suite-id> --label "Before prompt change"
|
|
166
|
+
answerlayer evals runs compare <run-id> --baseline <baseline-run-id>
|
|
167
|
+
|
|
162
168
|
answerlayer dashboards create --title "Executive overview" --visibility org
|
|
163
169
|
answerlayer tiles create --title "Revenue" --source-type saved_query --source <saved-query-id>
|
|
164
170
|
answerlayer dashboards attach-tile <dashboard-id> --tile <tile-id> --x 0 --y 0 --w 6 --h 4
|
|
@@ -182,7 +188,7 @@ answerlayer branding update --data-file ./branding.json
|
|
|
182
188
|
## Command groups
|
|
183
189
|
|
|
184
190
|
- Core: `api-keys`, `connections`, `metadata`, `query`, `query-results`
|
|
185
|
-
- Data products: `saved-queries`, `semantic`, `inquiry`, `generation`, `tiles`, `dashboards`
|
|
191
|
+
- Data products: `saved-queries`, `semantic`, `inquiry`, `evals`, `generation`, `tiles`, `dashboards`
|
|
186
192
|
- Supporting resources: `documents`, `branding`, `uploads`, `chains`, `users`, `org`, `roles`, `billing`, `stats`
|
|
187
193
|
|
|
188
194
|
## Development
|
package/package.json
CHANGED
|
@@ -147,6 +147,7 @@ to see exact flags before using one:
|
|
|
147
147
|
- `saved-queries` — list / get / create / execute reusable queries
|
|
148
148
|
- `semantic` — entities, relationships, measures, metrics, dimensions, filters
|
|
149
149
|
(most need `--connection <id>`)
|
|
150
|
+
- `evals` — create evaluation suites and cases, run them, and compare runs
|
|
150
151
|
- `dashboards`, `tiles` — build and read dashboards
|
|
151
152
|
- `documents` — upload business-context docs and link them to connections
|
|
152
153
|
- `connections` — create / test / inspect schema
|
package/src/cli.js
CHANGED
|
@@ -56,6 +56,7 @@ export async function main(argv, io) {
|
|
|
56
56
|
if (group === "saved-queries" || group === "saved") return handleSavedQueries(client, command, positionals, parsed, io);
|
|
57
57
|
if (group === "semantic") return handleSemantic(client, command, positionals, parsed, io);
|
|
58
58
|
if (group === "inquiry") return handleInquiry(client, command, positionals, parsed, io);
|
|
59
|
+
if (group === "evals" || group === "evaluations") return handleEvals(client, command, positionals, parsed, io);
|
|
59
60
|
if (group === "generation") return handleGeneration(client, command, positionals, parsed, io);
|
|
60
61
|
if (group === "tiles") return handleTiles(client, command, positionals, parsed, io);
|
|
61
62
|
if (group === "dashboards") return handleDashboards(client, command, positionals, parsed, io);
|
|
@@ -572,6 +573,119 @@ async function handleInquiry(client, command, positionals, parsed, io) {
|
|
|
572
573
|
throw usage(`Unknown inquiry command: ${command}`);
|
|
573
574
|
}
|
|
574
575
|
|
|
576
|
+
async function handleEvals(client, resource, positionals, parsed, io) {
|
|
577
|
+
const [command, ...rest] = positionals;
|
|
578
|
+
const base = "/api/v1/evals";
|
|
579
|
+
|
|
580
|
+
if (resource === "suites" || resource === "suite") {
|
|
581
|
+
if (command === "list" || !command) {
|
|
582
|
+
return requestAndPrint(client, "GET", `${base}/suites`, parsed, io, {
|
|
583
|
+
query: {
|
|
584
|
+
connection_id: firstValue(parsed.flags.connection),
|
|
585
|
+
include_inactive: parsed.flags.includeInactive || undefined,
|
|
586
|
+
},
|
|
587
|
+
table: [
|
|
588
|
+
{ key: "id", label: "ID" },
|
|
589
|
+
{ key: "name", label: "Name" },
|
|
590
|
+
{ key: "connection_id", label: "Connection" },
|
|
591
|
+
{ key: "version", label: "Version" },
|
|
592
|
+
{ key: "case_count", label: "Cases" },
|
|
593
|
+
{ key: "is_active", label: "Active" },
|
|
594
|
+
],
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (command === "create") {
|
|
599
|
+
const payload = await readData(parsed.flags, io, {
|
|
600
|
+
name: firstValue(parsed.flags.name),
|
|
601
|
+
connection_id: firstValue(parsed.flags.connection),
|
|
602
|
+
description: firstValue(parsed.flags.description),
|
|
603
|
+
});
|
|
604
|
+
requirePayloadValue(payload, "name", "evals suites create requires --name");
|
|
605
|
+
requirePayloadValue(payload, "connection_id", "evals suites create requires --connection");
|
|
606
|
+
return requestAndPrint(client, "POST", `${base}/suites`, parsed, io, { body: payload });
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const suiteId = requirePositional(rest, 0, "eval suite id");
|
|
610
|
+
if (command === "get") return requestAndPrint(client, "GET", `${base}/suites/${encodeURIComponent(suiteId)}`, parsed, io);
|
|
611
|
+
if (command === "update") {
|
|
612
|
+
return requestAndPrint(client, "PATCH", `${base}/suites/${encodeURIComponent(suiteId)}`, parsed, io, {
|
|
613
|
+
body: await readData(parsed.flags, io, {
|
|
614
|
+
name: firstValue(parsed.flags.name),
|
|
615
|
+
description: firstValue(parsed.flags.description),
|
|
616
|
+
is_active: activeFlag(parsed.flags),
|
|
617
|
+
}),
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
if (command === "delete") return requestAndPrint(client, "DELETE", `${base}/suites/${encodeURIComponent(suiteId)}`, parsed, io);
|
|
621
|
+
throw usage(`Unknown evals suites command: ${command}`);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (resource === "cases" || resource === "case") {
|
|
625
|
+
if (command === "create") {
|
|
626
|
+
const suiteId = firstValue(parsed.flags.suite) || requirePositional(rest, 0, "eval suite id");
|
|
627
|
+
return requestAndPrint(client, "POST", `${base}/suites/${encodeURIComponent(suiteId)}/cases`, parsed, io, {
|
|
628
|
+
body: await readData(parsed.flags, io, evalCasePayload(parsed.flags)),
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const caseId = requirePositional(rest, 0, "eval case id");
|
|
633
|
+
if (command === "update") {
|
|
634
|
+
return requestAndPrint(client, "PATCH", `${base}/cases/${encodeURIComponent(caseId)}`, parsed, io, {
|
|
635
|
+
body: await readData(parsed.flags, io, { ...evalCasePayload(parsed.flags), is_active: activeFlag(parsed.flags) }),
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
if (command === "delete") return requestAndPrint(client, "DELETE", `${base}/cases/${encodeURIComponent(caseId)}`, parsed, io);
|
|
639
|
+
throw usage(`Unknown evals cases command: ${command}`);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if (resource === "runs" || resource === "run") {
|
|
643
|
+
if (command === "list" || !command) {
|
|
644
|
+
return requestAndPrint(client, "GET", `${base}/runs`, parsed, io, {
|
|
645
|
+
query: {
|
|
646
|
+
suite_id: firstValue(parsed.flags.suite),
|
|
647
|
+
limit: firstValue(parsed.flags.limit),
|
|
648
|
+
offset: firstValue(parsed.flags.offset),
|
|
649
|
+
},
|
|
650
|
+
table: [
|
|
651
|
+
{ key: "id", label: "ID" },
|
|
652
|
+
{ key: "suite_id", label: "Suite" },
|
|
653
|
+
{ key: "label", label: "Label" },
|
|
654
|
+
{ key: "status", label: "Status" },
|
|
655
|
+
{ key: "suite_version", label: "Version" },
|
|
656
|
+
],
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
if (command === "create") {
|
|
661
|
+
const payload = await readData(parsed.flags, io, {
|
|
662
|
+
suite_id: firstValue(parsed.flags.suite) || rest[0],
|
|
663
|
+
label: firstValue(parsed.flags.label),
|
|
664
|
+
model: firstValue(parsed.flags.model),
|
|
665
|
+
baseline_run_id: firstValue(parsed.flags.baseline),
|
|
666
|
+
});
|
|
667
|
+
requirePayloadValue(payload, "suite_id", "evals runs create requires a suite id or --suite");
|
|
668
|
+
return requestAndPrint(client, "POST", `${base}/runs`, parsed, io, { body: payload });
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
const runId = requirePositional(rest, 0, "eval run id");
|
|
672
|
+
if (command === "get") {
|
|
673
|
+
return requestAndPrint(client, "GET", `${base}/runs/${encodeURIComponent(runId)}`, parsed, io, {
|
|
674
|
+
query: { include_semantic_snapshot: parsed.flags.includeSemanticSnapshot || undefined },
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
if (command === "cancel") return requestAndPrint(client, "POST", `${base}/runs/${encodeURIComponent(runId)}/cancel`, parsed, io);
|
|
678
|
+
if (command === "compare") {
|
|
679
|
+
return requestAndPrint(client, "GET", `${base}/runs/${encodeURIComponent(runId)}/compare`, parsed, io, {
|
|
680
|
+
query: { baseline_run_id: firstValue(parsed.flags.baseline) },
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
throw usage(`Unknown evals runs command: ${command}`);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
throw usage(`Expected evals resource: suites, cases, or runs`);
|
|
687
|
+
}
|
|
688
|
+
|
|
575
689
|
async function handleGeneration(client, command, positionals, parsed, io) {
|
|
576
690
|
const base = "/api/v1/semantic/jobs";
|
|
577
691
|
if (command === "start" || command === "create") {
|
|
@@ -997,6 +1111,29 @@ function queryPayload(flags, sql) {
|
|
|
997
1111
|
};
|
|
998
1112
|
}
|
|
999
1113
|
|
|
1114
|
+
function evalCasePayload(flags) {
|
|
1115
|
+
return {
|
|
1116
|
+
title: firstValue(flags.title),
|
|
1117
|
+
question: firstValue(flags.question),
|
|
1118
|
+
expected_answer: firstValue(flags.expectedAnswer),
|
|
1119
|
+
expected_sql: firstValue(flags.expectedSql) || firstValue(flags.sql),
|
|
1120
|
+
expected_values: parseJsonFlag(firstValue(flags.expectedValues), "expected-values"),
|
|
1121
|
+
required_tools: optionalCsvOrRepeated(flags.requiredTool),
|
|
1122
|
+
forbidden_tools: optionalCsvOrRepeated(flags.forbiddenTool),
|
|
1123
|
+
tags: optionalCsvOrRepeated(flags.tag),
|
|
1124
|
+
evaluator_config: parseJsonFlag(firstValue(flags.evaluatorConfig), "evaluator-config"),
|
|
1125
|
+
numeric_tolerance: parseNumber(firstValue(flags.numericTolerance), "numeric-tolerance"),
|
|
1126
|
+
pass_threshold: parseNumber(firstValue(flags.passThreshold), "pass-threshold"),
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
function activeFlag(flags) {
|
|
1131
|
+
if (flags.active && flags.inactive) throw usage("Use only one of --active or --inactive");
|
|
1132
|
+
if (flags.active) return true;
|
|
1133
|
+
if (flags.inactive) return false;
|
|
1134
|
+
return undefined;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1000
1137
|
async function semanticPayload(resource, flags, positionals, io) {
|
|
1001
1138
|
const common = {
|
|
1002
1139
|
name: firstValue(flags.name) || positionals.join(" ") || undefined,
|
|
@@ -1244,6 +1381,24 @@ function normalizeFlagName(rawName) {
|
|
|
1244
1381
|
"--summary": "summary",
|
|
1245
1382
|
"--session": "session",
|
|
1246
1383
|
"--question": "question",
|
|
1384
|
+
"--suite": "suite",
|
|
1385
|
+
"--suite-id": "suite",
|
|
1386
|
+
"--label": "label",
|
|
1387
|
+
"--baseline": "baseline",
|
|
1388
|
+
"--baseline-run": "baseline",
|
|
1389
|
+
"--expected-answer": "expectedAnswer",
|
|
1390
|
+
"--expected-sql": "expectedSql",
|
|
1391
|
+
"--expected-values": "expectedValues",
|
|
1392
|
+
"--required-tool": "requiredTool",
|
|
1393
|
+
"--forbidden-tool": "forbiddenTool",
|
|
1394
|
+
"--tag": "tag",
|
|
1395
|
+
"--evaluator-config": "evaluatorConfig",
|
|
1396
|
+
"--numeric-tolerance": "numericTolerance",
|
|
1397
|
+
"--pass-threshold": "passThreshold",
|
|
1398
|
+
"--active": "active",
|
|
1399
|
+
"--inactive": "inactive",
|
|
1400
|
+
"--include-inactive": "includeInactive",
|
|
1401
|
+
"--include-semantic-snapshot": "includeSemanticSnapshot",
|
|
1247
1402
|
"--turn": "turn",
|
|
1248
1403
|
"--from": "from",
|
|
1249
1404
|
"--to": "to",
|
|
@@ -1257,7 +1412,7 @@ function normalizeFlagName(rawName) {
|
|
|
1257
1412
|
}
|
|
1258
1413
|
|
|
1259
1414
|
function isBooleanFlag(rawName) {
|
|
1260
|
-
return ["--json", "--help", "-h", "--include", "-i", "--raw", "--admin", "--force"].includes(rawName);
|
|
1415
|
+
return ["--json", "--help", "-h", "--include", "-i", "--raw", "--admin", "--force", "--active", "--inactive", "--include-inactive", "--include-semantic-snapshot"].includes(rawName);
|
|
1261
1416
|
}
|
|
1262
1417
|
|
|
1263
1418
|
function setFlag(flags, name, value) {
|
|
@@ -1282,6 +1437,13 @@ function parseInteger(value, fallback) {
|
|
|
1282
1437
|
return parsed;
|
|
1283
1438
|
}
|
|
1284
1439
|
|
|
1440
|
+
function parseNumber(value, name) {
|
|
1441
|
+
if (value === undefined || value === null || value === "") return undefined;
|
|
1442
|
+
const parsed = Number(value);
|
|
1443
|
+
if (!Number.isFinite(parsed)) throw usage(`Expected a number for --${name}, received ${value}`);
|
|
1444
|
+
return parsed;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1285
1447
|
function requirePositional(positionals, index, label) {
|
|
1286
1448
|
const value = positionals[index];
|
|
1287
1449
|
if (!value) throw usage(`Missing ${label}`);
|
|
@@ -1301,6 +1463,10 @@ function csvOrRepeated(value) {
|
|
|
1301
1463
|
return values.flatMap((item) => String(item).split(",").map((part) => part.trim()).filter(Boolean));
|
|
1302
1464
|
}
|
|
1303
1465
|
|
|
1466
|
+
function optionalCsvOrRepeated(value) {
|
|
1467
|
+
return value === undefined ? undefined : csvOrRepeated(value);
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1304
1470
|
function firstValue(value) {
|
|
1305
1471
|
return Array.isArray(value) ? value[0] : value;
|
|
1306
1472
|
}
|
|
@@ -1361,6 +1527,9 @@ Data products:
|
|
|
1361
1527
|
answerlayer saved-queries list|get|create|update|delete|approve|unapprove|execute
|
|
1362
1528
|
answerlayer semantic <entities|relationships|measures|metrics|dimensions|filters> list|get|create|update|delete|delete-all|generate
|
|
1363
1529
|
answerlayer inquiry ask|sessions|create-session|session|update-session|delete-session|turn
|
|
1530
|
+
answerlayer evals suites list|create|get|update|delete
|
|
1531
|
+
answerlayer evals cases create|update|delete
|
|
1532
|
+
answerlayer evals runs list|create|get|cancel|compare
|
|
1364
1533
|
answerlayer generation start|list|get|status|stream|cancel|questions|guidance|delete
|
|
1365
1534
|
answerlayer tiles list|get|create|update|data|delete
|
|
1366
1535
|
answerlayer dashboards list|get|create|update|delete|duplicate|manifest|attach-tile|move-tile|detach-tile|assignments|assign|unassign|tile-data
|