embedding-studio-cli 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/studio.js +13 -0
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "embedding-studio-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "The Embedding Studio API from a terminal: push labelled data, fit and calibrate, place the review band, decide, and download the calibration file. JSON out, non-zero exit on refusal.",
5
5
  "bin": {
6
- "studio": "./studio.js"
6
+ "studio": "studio.js"
7
7
  },
8
8
  "files": [
9
9
  "studio.js"
package/studio.js CHANGED
@@ -84,6 +84,10 @@ function parse(argv, spec) {
84
84
  const out = { _: [] };
85
85
  for (let i = 0; i < argv.length; i++) {
86
86
  const a = argv[i];
87
+ if (a === "-o") { /* the one short flag argparse gives the Python side */
88
+ out.o = argv[++i];
89
+ continue;
90
+ }
87
91
  if (a.startsWith("--")) {
88
92
  const name = a.slice(2);
89
93
  if (!(name in spec)) fail(`unknown flag --${name}`, 2);
@@ -187,6 +191,15 @@ const COMMANDS = {
187
191
  if (a["idempotency-key"]) body.idempotency_key = a["idempotency-key"];
188
192
  say(await call("POST", `/v1/projects/${a._[0]}/decide`, { body }));
189
193
  },
194
+ "ask": async (argv) => {
195
+ const a = parse(argv, { "text": "value", "template": "value", "questions": "value" });
196
+ if (!a.template === !a.questions) fail("ask needs exactly one of --template or --questions", 2);
197
+ const text = a.text !== undefined ? a.text : await readStdin();
198
+ const body = { text };
199
+ if (a.template) body.template = a.template;
200
+ else body.questions = JSON.parse(fs.readFileSync(a.questions, "utf8"));
201
+ say(await call("POST", "/v1/decide", { body }));
202
+ },
190
203
  "decisions": async (argv) =>
191
204
  say(await call("GET", `/v1/projects/${parse(argv, {})._[0]}/decisions`)),
192
205
  "audit": async (argv) => say(await call("GET", `/v1/projects/${parse(argv, {})._[0]}/audit`)),