UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

36 lines (35 loc) • 1.84 kB
/** * Decision-model guard for dictionary substitutions. * * An alias is usually an ordinary word as well ("part" is how engines hear a * name that sounds like it), so applying the dictionary blindly rewrites the * literal word every time it is said. The guard asks a decision model, in one * request, one question per candidate: did the speaker mean the term, or the * word as written? * * Why a `choice` and not a yes/no: a boolean "is this the name X?" question * was measured to be leading — it said yes to nearly everything. A choice * between the term and the literal reading, each with its own rubric, * discriminates: "my name is part" → the term at 97%, "part of the plan" → * literal. Answers are matched by position (`candidate__N`), never by the * alias text, so an alias the wire normalises cannot misroute an answer. * * Fail-open, like every other `decide` consumer: with no decision provider, * on timeout (default 4 s) or on any error the dictionary is applied as is, * and each record says why in `note`. * * @module voice/correction/guard */ import type { STTCorrectionDeps, STTDecisionRecord, STTDictionaryCandidate } from "../../types/index.js"; /** Default guard timeout; on expiry the dictionary is applied as is. */ export declare const DEFAULT_DECIDE_TIMEOUT_MS = 4000; /** * Judge every candidate in one decision request. Returns one record per * candidate, in candidate order; a candidate the guard could not judge is * recorded as `"term"` with a `note` saying why, so `applyDictionary` applies * it exactly as it would without a guard. */ export declare function decideCandidates(text: string, candidates: readonly STTDictionaryCandidate[], decide: STTCorrectionDeps["decide"] | undefined, options?: { context?: string; timeoutMs?: number; }): Promise<STTDecisionRecord[]>;