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

64 lines (63 loc) • 3.65 kB
import type { STTCredentials, STTEndpointConfig, STTProviderDescriptor } from "../types/index.js"; /** * Every shipped speech-to-text provider — the single source of truth for its * name, aliases, credentials slice, env vars and capabilities. Pure data, like * `PROVIDER_DESCRIPTORS` for text providers; the handler classes are wired to * these names in `voice/index.ts`, and `MEDIA_HANDLER_CATALOG`'s STT rows are * derived from this list so the two cannot drift. * * **Order is precedence.** `resolveDefaultSTTProvider()` returns the first * entry that is configured, so reordering changes which engine every * `transcribe()` / `generate({ stt })` without an explicit provider uses. * `whistle` is last on purpose: it runs on this machine and needs no key, so * it is what a caller gets when nothing else is configured. */ export declare const STT_PROVIDER_DESCRIPTORS: readonly STTProviderDescriptor[]; /** The provider used when nothing else is configured. */ export declare const DEFAULT_LOCAL_STT_PROVIDER = "whistle"; /** * Canonical descriptor name for a provider name or alias (case-insensitive), * or `undefined` when it is not a shipped STT provider — a caller may still * have registered a handler of its own under that name. */ export declare function resolveSTTProviderName(name: string | undefined): string | undefined; /** The descriptor for a provider name or alias, if it is a shipped one. */ export declare function getSTTProviderDescriptor(name: string): STTProviderDescriptor | undefined; /** * Whether a provider can run with these credentials and the environment. The * local engine needs no configuration and always counts. Unknown names are * not configured. */ export declare function isSTTProviderConfigured(name: string, credentials?: STTCredentials): boolean; /** Configured providers, in precedence order (the local engine last). */ export declare function listConfiguredSTTProviders(credentials?: STTCredentials): string[]; /** * Named OpenAI-compatible endpoints: `credentials.stt.endpoints` over the * `NEUROLINK_STT_ENDPOINTS` JSON object. Keys are lowercased; one that * collides with a shipped provider name or alias is dropped with a warning, * as is an entry without a `baseURL`. Malformed JSON is reported once and * ignored. */ export declare function resolveSTTEndpoints(credentials?: STTCredentials): Record<string, STTEndpointConfig>; /** * The per-call endpoints alone (`credentials.stt.endpoints`), validated * exactly as the env map is: names lower-cased, a name that collides with a * shipped provider or alias dropped, an entry without a `baseURL` dropped. * Every per-call lookup goes through this so a request can neither replace a * shipped handler nor build an endpoint the env form would have refused. */ export declare function resolveCallSTTEndpoints(credentials?: STTCredentials): Record<string, STTEndpointConfig>; /** * The provider a transcription without an explicit one goes to: * `NEUROLINK_STT_PROVIDER` when it names a known provider or alias, else the * first configured provider in descriptor order, else the built-in local * engine. Never throws, never returns an empty string. */ export declare function resolveDefaultSTTProvider(credentials?: STTCredentials): string; /** * The variables that would configure each hosted STT provider, one clause per * provider in precedence order, e.g. "OPENAI_STT_API_KEY or OPENAI_API_KEY for * whisper, or DEEPGRAM_API_KEY for deepgram". Derived from the descriptors so * a new provider appears in every "nothing is configured" message. */ export declare function describeSTTProviderKeys(): string;