Skip to content

armgit / laya

Public Imported from GitHub
0

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.

Merge pull request #553 from Divit-aggarwal/fix/ts-noul-criteria-key-case

Nandakishor79d682fa7beb
diff --cc laya-ts/tests/audit-regressions.test.ts
index eaef7958,4d9f3d3c..2b6b1f44
--- a/laya-ts/tests/audit-regressions.test.ts
+++ b/laya-ts/tests/audit-regressions.test.ts
@@@ -53,19 -53,16 +53,29 @@@ describe("audit regressions", () =>
expect(() => checkQuestion("q", { type: "choice", instructions: "?", criteria: ["yes"], labels: { false: "No", true: "Yes" } })).toThrow("labels");
});
+ it("treats a null or undefined noul `labels` as the defaults, as Python does", () => {
+ const defaults = renderOptions(toInternal({ type: "noul", instructions: "?" }));
+ for (const labels of [null, undefined]) {
+ const q = { type: "noul", instructions: "?", labels };
+ expect(() => checkQuestion("q", q)).not.toThrow();
+ expect(renderOptions(toInternal(q))).toEqual(defaults);
+ }
+ for (const labels of ["x", [], {}, 5, { false: "No" }]) {
+ expect(() => checkQuestion("q", { type: "noul", instructions: "?", labels })).toThrow("labels");
+ }
+ expect(() => checkQuestion("q", { type: "choice", instructions: "?", criteria: ["a"], labels: null })).toThrow("labels");
+ });
+
+ it("reads noul criteria keys case-insensitively, as Python does", () => {
+ const upper = { type: "noul", instructions: "?", criteria: { True: "it holds", FALSE: "it does not" } };
+ const lower = { type: "noul", instructions: "?", criteria: { true: "it holds", false: "it does not" } };
+ expect(() => checkQuestion("q", upper)).not.toThrow();
+ expect(toInternal(upper).crit).toEqual({ true: "it holds", false: "it does not" });
+ expect(renderOptions(toInternal(upper))).toEqual(renderOptions(toInternal(lower)));
+ expect(() => checkQuestion("q", { type: "noul", instructions: "?", criteria: { True: "x", maybe: "y" } })).toThrow("maybe");
+ expect(() => checkQuestion("q", { type: "noul", instructions: "?", criteria: { yes: "x" } })).toThrow("yes");
+ });
+
it("rejects a null score level, as Python does (#302)", () => {
expect(() => checkQuestion("q", { type: "score", instructions: "?", criteria: ["low", null, "high"] })).toThrow("level 1");
expect(() => checkQuestion("q", { type: "score", instructions: "?", criteria: ["low", "mid", undefined] })).toThrow("level 2");