Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
fix(ts): reject choice labels that share an answer key, as Python does (#496 parity)
divit aggarwalb26433fb408a
diff --git a/laya-ts/src/agent.ts b/laya-ts/src/agent.tsindex 9d44168b..c705e19e 100644--- a/laya-ts/src/agent.ts+++ b/laya-ts/src/agent.ts@@ -178,6 +178,21 @@ export function checkQuestion(qid: string, qdef: unknown): void {`bool), got ${JSON.stringify(label)}`,);}+ // toInternal turns the list into an object, so each label's String() is its answer key;+ // two labels on one key would silently drop an option. Python rejects them (#496).+ const seen = new Map<string, number>();+ crit.forEach((label: unknown, i) => {+ const key = String(label);+ const first = seen.get(key);+ if (first === undefined) {+ seen.set(key, i);+ return;+ }+ throw new Error(+ `question ${qidStr(qid)}: choice label ${i} (${JSON.stringify(label)}) repeats label ${first}; the ` ++ `labels are the answer keys, so every option needs its own (1 and "1" are one key)`,+ );+ });}} else if (t === "score") {if (!Array.isArray(crit)) {diff --git a/laya-ts/tests/audit-regressions.test.ts b/laya-ts/tests/audit-regressions.test.tsindex b01c68ec..b0140fd0 100644--- a/laya-ts/tests/audit-regressions.test.ts+++ b/laya-ts/tests/audit-regressions.test.ts@@ -98,6 +98,14 @@ describe("audit regressions", () => {expect(() => checkQuestion("q", { type: "choice", instructions: "?", criteria: { a: null, b: null } })).not.toThrow();});+ it("rejects choice labels that share an answer key, as Python does (#496)", () => {+ const check = (criteria: unknown[]) => () => checkQuestion("q", { type: "choice", instructions: "?", criteria });+ expect(check(["a", "b", "a"])).toThrow('question "q": choice label 2 ("a") repeats label 0');+ expect(check([1, "1"])).toThrow("choice label 1 (\"1\") repeats label 0");+ expect(check([true, "true"])).toThrow("repeats label 0");+ expect(check(["a", "A", 1, 2, true, false])).not.toThrow();+ });+it("rejects malformed provider output", async () => {const agent = new Agent({ provider: {async runEncoder(_batch: any) { return { lastHidden: [[[0, 0]]] }; },