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 PR #1338

Nandakishorbba03bc8e8ab
diff --cc laya-ts/src/router.ts
index 7799aaab,7f696eae..8f7e1723
--- a/laya-ts/src/router.ts
+++ b/laya-ts/src/router.ts
@@@ -639,15 -645,19 +645,19 @@@ export class Router extends HookRegistr
checkQuestion(qid, qdef);
}
// Python parity (router.py predict): the request's language also shapes the answer
- // distribution through the agent's lang_temperatures. An explicit lang wins;
- // otherwise forward the language the router detected for the routing decision.
- // TS analyse() names English "en" where Python's analyse returns None (it only
- // ever names non-English), so a detected "en" forwards as null — in Python only an
- // explicit lang="en" can select an "en" override.
+ // distribution through the agent's lang_temperatures. An explicit lang wins; otherwise
+ // forward the language the router detected for the routing decision, "en" included --
+ // Python's `analyse` names English "en" too (laya/lang.py, `_latin_profile`), and
+ // `lang_temperatures` may carry an "en" entry, so replacing it with null made that
+ // override dead code on this path while the same agent honoured it when called directly.
const detected = decision.detection?.language;
- const effectiveLang = opts.lang ?? (detected && detected !== "en" ? detected : null);
+ const effectiveLang = opts.lang ?? detected ?? null;
const agentOpts: PredictOptions = { lang: effectiveLang };
if (mc !== null) agentOpts.minConfidence = mc;
+ // Forwarded only when set, as Python does: an absent override means "the agent's own
+ // config", and `null`/`undefined` must not overwrite a deployment's configured budget.
+ if (ctx.maxLen !== null && ctx.maxLen !== undefined) agentOpts.maxLen = ctx.maxLen;
+ if (ctx.headMaxLen !== null && ctx.headMaxLen !== undefined) agentOpts.headMaxLen = ctx.headMaxLen;
markDefaultsRan(agentOpts);
const result = (await agent.systemOne(
ctx.states[0],