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(sdk): type the mixed_segment every routing detection answer carries

Aashish233f6476da00
diff --git a/sdk/typescript/src/response.ts b/sdk/typescript/src/response.ts
index d6eb8468..546f5c02 100644
--- a/sdk/typescript/src/response.ts
+++ b/sdk/typescript/src/response.ts
@@ -21,6 +21,14 @@ export function validateRoute(value: unknown): void {
expect(detection.language === null || typeof detection.language === 'string', 'detected language');
expect(typeof detection.is_english === 'boolean' && typeof detection.language_undecided === 'boolean', 'language flags');
expect(probability(detection.diacritic_rate) && probability(detection.non_latin_fraction), 'language fractions');
+ // Checked when the server sends it, like the optional fields of `health` and of `usage`: one
+ // field the route report added (#384) must not fail every prediction on a deployment that
+ // predates it. When it is there it is `null` or the segment text, as every branch of
+ // `laya.lang.analyse()` reports it.
+ if (detection.mixed_segment !== undefined) {
+ expect(detection.mixed_segment === null || typeof detection.mixed_segment === 'string',
+ 'detection mixed segment');
+ }
}
export function validateHealth(value: unknown): void {
diff --git a/sdk/typescript/src/types.ts b/sdk/typescript/src/types.ts
index 5a0b62a3..2a37a156 100644
--- a/sdk/typescript/src/types.ts
+++ b/sdk/typescript/src/types.ts
@@ -89,6 +89,10 @@ export interface LanguageDetection {
language_undecided: boolean;
diacritic_rate: number;
non_latin_fraction: number;
+ /** The line or field that made a mostly-English state non-English (#384), null otherwise.
+ * A state can read as English overall because an English stack trace or template is longer
+ * than the customer's message; this names the segment that was not. */
+ mixed_segment: string | null;
}
export interface RouteDecision {
model: ModelName;