@answerlayer/cli 0.1.19 → 0.2.0
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 -1
- package/package.json +1 -1
- package/src/cli.js +84 -0
package/README.md
CHANGED
|
@@ -284,6 +284,13 @@ answerlayer evals runs compare <run-id> --baseline <baseline-run-id>
|
|
|
284
284
|
answerlayer evals runs analyze <run-id> --json
|
|
285
285
|
answerlayer generation start --connection <connection-id> --component-type metrics --eval-suite <suite-id> --eval-case <authoring-case-id> --prompt "Improve these concepts"
|
|
286
286
|
|
|
287
|
+
answerlayer ontologies create --domain-key exoplanet-archive --name "Exoplanet Archive"
|
|
288
|
+
answerlayer ontologies version create <ontology-id> --file ./ontology.tff
|
|
289
|
+
answerlayer ontologies version validate <version-id>
|
|
290
|
+
answerlayer ontologies version review <version-id> # admin-only
|
|
291
|
+
answerlayer ontologies version freeze <version-id> # admin-only
|
|
292
|
+
answerlayer ontologies version export <version-id> --output ./ontology.tff
|
|
293
|
+
|
|
287
294
|
answerlayer dashboards create --title "Executive overview" --visibility org
|
|
288
295
|
answerlayer tiles create --title "Revenue" --source-type saved_query --source <saved-query-id>
|
|
289
296
|
answerlayer dashboards attach-tile <dashboard-id> --tile <tile-id> --x 0 --y 0 --w 6 --h 4
|
|
@@ -307,7 +314,7 @@ answerlayer branding update --data-file ./branding.json
|
|
|
307
314
|
## Command groups
|
|
308
315
|
|
|
309
316
|
- Core: `api-keys`, `connections`, `metadata`, `query`, `query-results`
|
|
310
|
-
- Data products: `saved-queries`, `semantic`, `inquiry`, `evals`, `generation`, `tiles`, `dashboards`
|
|
317
|
+
- Data products: `saved-queries`, `semantic`, `inquiry`, `evals`, `ontologies`, `generation`, `tiles`, `dashboards`
|
|
311
318
|
- Supporting resources: `documents`, `branding`, `uploads`, `chains`, `users`, `org`, `roles`, `billing`, `stats`
|
|
312
319
|
|
|
313
320
|
## Development
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -56,6 +56,7 @@ export async function main(argv, io) {
|
|
|
56
56
|
if (group === "semantic") return handleSemantic(client, command, positionals, parsed, io);
|
|
57
57
|
if (group === "inquiry") return handleInquiry(client, command, positionals, parsed, io);
|
|
58
58
|
if (group === "evals" || group === "evaluations") return handleEvals(client, command, positionals, parsed, io);
|
|
59
|
+
if (group === "ontologies" || group === "ontology") return handleOntologies(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);
|
|
@@ -736,6 +737,69 @@ async function handleEvals(client, resource, positionals, parsed, io) {
|
|
|
736
737
|
throw usage(`Expected evals resource: suites, cases, or runs`);
|
|
737
738
|
}
|
|
738
739
|
|
|
740
|
+
async function handleOntologies(client, command, positionals, parsed, io) {
|
|
741
|
+
const base = "/api/v1/ontologies";
|
|
742
|
+
if (command === "list" || !command) {
|
|
743
|
+
return requestAndPrint(client, "GET", base, parsed, io, {
|
|
744
|
+
table: [
|
|
745
|
+
{ key: "id", label: "ID" },
|
|
746
|
+
{ key: "domain_key", label: "Domain" },
|
|
747
|
+
{ key: "name", label: "Name" },
|
|
748
|
+
{ key: "version_count", label: "Versions" },
|
|
749
|
+
{ key: "latest_version.status", label: "Latest" },
|
|
750
|
+
{ key: "latest_version.validation_status", label: "Validation" },
|
|
751
|
+
],
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
if (command === "create") {
|
|
756
|
+
const payload = await readData(parsed.flags, io, {
|
|
757
|
+
domain_key: firstValue(parsed.flags.domainKey),
|
|
758
|
+
name: firstValue(parsed.flags.name),
|
|
759
|
+
description: firstValue(parsed.flags.description),
|
|
760
|
+
});
|
|
761
|
+
requirePayloadValue(payload, "domain_key", "ontologies create requires --domain-key");
|
|
762
|
+
requirePayloadValue(payload, "name", "ontologies create requires --name");
|
|
763
|
+
return requestAndPrint(client, "POST", base, parsed, io, { body: payload });
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (command === "get") {
|
|
767
|
+
const ontologyId = requirePositional(positionals, 0, "ontology id");
|
|
768
|
+
return requestAndPrint(client, "GET", `${base}/${encodeURIComponent(ontologyId)}`, parsed, io);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
if (command === "validate") {
|
|
772
|
+
const sourceText = await readTff(parsed.flags, io);
|
|
773
|
+
return requestAndPrint(client, "POST", `${base}/validate`, parsed, io, {
|
|
774
|
+
body: { source_text: sourceText },
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
if (command === "version" || command === "versions") {
|
|
779
|
+
const [action, id] = positionals;
|
|
780
|
+
if (action === "create") {
|
|
781
|
+
const ontologyId = requirePositional(positionals, 1, "ontology id");
|
|
782
|
+
const sourceText = await readTff(parsed.flags, io);
|
|
783
|
+
return requestAndPrint(client, "POST", `${base}/${encodeURIComponent(ontologyId)}/versions`, parsed, io, {
|
|
784
|
+
body: {
|
|
785
|
+
source_text: sourceText,
|
|
786
|
+
predecessor_version_id: firstValue(parsed.flags.predecessor),
|
|
787
|
+
},
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
const versionId = id || requirePositional(positionals, 1, "ontology version id");
|
|
791
|
+
if (["validate", "review", "freeze"].includes(action)) {
|
|
792
|
+
return requestAndPrint(client, "POST", `${base}/versions/${encodeURIComponent(versionId)}/${action}`, parsed, io);
|
|
793
|
+
}
|
|
794
|
+
if (action === "export") {
|
|
795
|
+
return requestAndPrint(client, "GET", `${base}/versions/${encodeURIComponent(versionId)}/source`, parsed, io, { rawDefault: true });
|
|
796
|
+
}
|
|
797
|
+
throw usage("Expected ontologies version create|validate|review|freeze|export");
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
throw usage(`Unknown ontologies command: ${command}`);
|
|
801
|
+
}
|
|
802
|
+
|
|
739
803
|
async function handleGeneration(client, command, positionals, parsed, io) {
|
|
740
804
|
const base = "/api/v1/semantic/jobs";
|
|
741
805
|
if (command === "start" || command === "create") {
|
|
@@ -1240,6 +1304,18 @@ async function readSql(flags, positionals, io) {
|
|
|
1240
1304
|
throw usage("SQL is required. Pass --sql, --file, a positional SQL string, or stdin.");
|
|
1241
1305
|
}
|
|
1242
1306
|
|
|
1307
|
+
async function readTff(flags, io) {
|
|
1308
|
+
const inline = firstValue(flags.tff);
|
|
1309
|
+
const file = firstValue(flags.file);
|
|
1310
|
+
if (inline) return inline;
|
|
1311
|
+
if (file) return fs.readFileSync(file, "utf8");
|
|
1312
|
+
if (!io.stdin.isTTY) {
|
|
1313
|
+
const source = await readAll(io.stdin);
|
|
1314
|
+
if (source.trim()) return source;
|
|
1315
|
+
}
|
|
1316
|
+
throw usage("TFF0 source is required. Pass --file, --tff, or stdin.");
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1243
1319
|
async function optionalSql(flags, positionals, io) {
|
|
1244
1320
|
if (firstValue(flags.sql) || firstValue(flags.file) || positionals.length > 0) {
|
|
1245
1321
|
return readSql(flags, positionals, io);
|
|
@@ -1429,6 +1505,9 @@ function normalizeFlagName(rawName) {
|
|
|
1429
1505
|
"--expression": "expression",
|
|
1430
1506
|
"--source-type": "sourceType",
|
|
1431
1507
|
"--source": "source",
|
|
1508
|
+
"--domain-key": "domainKey",
|
|
1509
|
+
"--predecessor": "predecessor",
|
|
1510
|
+
"--tff": "tff",
|
|
1432
1511
|
"--visualization": "visualization",
|
|
1433
1512
|
"--dashboard": "dashboard",
|
|
1434
1513
|
"--tile": "tile",
|
|
@@ -1683,6 +1762,11 @@ Data products:
|
|
|
1683
1762
|
--suite values, plus shared --label, --model, --concurrency <1-8>,
|
|
1684
1763
|
and --use-semantic-layer or --no-semantic-layer
|
|
1685
1764
|
update accepts --label <name>
|
|
1765
|
+
answerlayer ontologies list|create|get|validate
|
|
1766
|
+
validate accepts --file <ontology.tff>, --tff <source>, or stdin
|
|
1767
|
+
answerlayer ontologies version create|validate|review|freeze|export
|
|
1768
|
+
version create accepts an ontology id, --file <ontology.tff>, --tff <source>,
|
|
1769
|
+
or stdin, plus optional --predecessor <version-id>
|
|
1686
1770
|
answerlayer generation start|list|get|status|stream|cancel|questions|guidance|delete
|
|
1687
1771
|
start accepts --connection, --component-type, --prompt, --model,
|
|
1688
1772
|
--eval-suite, and repeatable or comma-separated --eval-case values;
|