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.

fix(laya-ts): match min_confidence bucket-key error text to Python and Java (#1100)

Bhargav Mehtac5b4fa7f48ed
diff --git a/laya-ts/src/common.ts b/laya-ts/src/common.ts
index 0bd44472..6a099b76 100644
--- a/laya-ts/src/common.ts
+++ b/laya-ts/src/common.ts
@@ -274,7 +274,7 @@ export function checkMinConfidenceMap(m: unknown): MinConfidenceMap {
const out: Record<string, number> = {};
for (const [key, val] of Object.entries(m as Record<string, unknown>)) {
if (key !== "default" && !BUCKET_KEY.test(key)) {
- throw new Error(`min_confidence map keys must be strings like 'choice:3-5', got ${pyRepr(key)}`);
+ throw new Error(`min_confidence map keys must be a bucket like 'choice:3-5' or 'default', got ${pyRepr(key)}`);
}
if (typeof val === "boolean" || typeof val !== "number" || !Number.isFinite(val) || val < 0.0 || val > 1.0) {
throw new Error(`min_confidence must be a float in [0.0, 1.0], got ${pyRepr(val)}`);
diff --git a/laya-ts/tests/confidence-gating.test.ts b/laya-ts/tests/confidence-gating.test.ts
index 5f29e7e2..52161f64 100644
--- a/laya-ts/tests/confidence-gating.test.ts
+++ b/laya-ts/tests/confidence-gating.test.ts
@@ -87,7 +87,7 @@ describe("checkMinConfidenceMap", () => {
it("rejects unknown bucket keys and typos", () => {
for (const typo of ["choice:3_5", "choice:2-5", "Choice:2", "invalid", "score:1", "foo:2", "choice:12"]) {
expect(() => checkMinConfidenceMap({ [typo]: 0.5 })).toThrowError(
- /min_confidence map keys must be strings like 'choice:3-5'/,
+ /^min_confidence map keys must be a bucket like 'choice:3-5' or 'default', got /,
);
}
});