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): refuse a temperature that is not a list of 3 at construction, as Python does (#502 parity)
divit aggarwal53ac09903812
diff --git a/laya-ts/src/agent.ts b/laya-ts/src/agent.tsindex 6a8c8566..ba120199 100644--- a/laya-ts/src/agent.ts+++ b/laya-ts/src/agent.ts@@ -305,8 +305,13 @@ export class Agent extends HookRegistry {this.tok = opts.tok ?? defaultTokenizer();const raw = (cfg.temperature ?? [1.0, 1.0, 1.0]) as unknown;this.temperatureRaw = raw;- const rawList = Array.isArray(raw) ? raw : [raw, raw, raw];- this.temperature = [0, 1, 2].map((i) => clampTemperature(rawList[i] ?? 1.0));+ // The decode indexes this by question type, so refuse any other shape here, as Python's+ // Agent.__init__ does (#502): a short list silently fell back to 1.0 per missing type.+ if (!Array.isArray(raw) || raw.length !== 3) {+ throw new Error(`Incompatible model: temperature must be a list of 3 floats, got ${JSON.stringify(raw)}`);+ }+ const rawList: unknown[] = raw;+ this.temperature = rawList.map((t) => clampTemperature(t));this.temperatureByOptionsRaw = (cfg.temperature_by_options ?? {}) as Record<string, unknown>;this.temperatureByOptions = Object.fromEntries(Object.entries(this.temperatureByOptionsRaw).map(([k, v]) => [k, clampTemperature(v)]),@@ -316,7 +321,7 @@ export class Agent extends HookRegistry {([k, v]) => [k, v, this.temperatureByOptions[k]] as [string, unknown, number],),...[0, 1, 2].map(- (i) => [`temperature[${i}]`, rawList[i] ?? 1.0, this.temperature[i]] as [string, unknown, number],+ (i) => [`temperature[${i}]`, rawList[i], this.temperature[i]] as [string, unknown, number],),];const rejected: string[] = [];diff --git a/laya-ts/tests/lang-temperature.test.ts b/laya-ts/tests/lang-temperature.test.tsindex a8603199..d815245d 100644--- a/laya-ts/tests/lang-temperature.test.ts+++ b/laya-ts/tests/lang-temperature.test.ts@@ -81,6 +81,16 @@ describe("lang_temperatures", () => {).toThrow('Language override "de" temperature must be a list of 3 floats');});+ it("rejects a base temperature that is not a list of 3 floats, as Python does (#502)", () => {+ for (const temperature of [[1, 1], [1, 1, 1, 1], 2, "1"]) {+ expect(() => new Agent({ provider: fakeProvider(), temperature } as any)).toThrow(+ "Incompatible model: temperature must be a list of 3 floats",+ );+ }+ expect(() => new Agent({ provider: fakeProvider(), cfg: { temperature: [1, 2] } } as any)).toThrow("list of 3");+ expect(new Agent({ provider: fakeProvider(), temperature: [1, 2, 3] } as any).temperature).toEqual([1, 2, 3]);+ });+it("a null entry is an empty override (base raw temperature, no buckets)", async () => {const a = new Agent({provider: fakeProvider(),