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

63 lines (62 loc) • 3.26 kB
import { AIProviderName } from "../constants/enums.js"; import type { DecideCatalogJson, NeurolinkCredentials, ProviderDescriptor } from "../types/index.js"; /** * Builds the ProviderDescriptor of a JSON `decide` provider. It serves only * `decide`, so it declares no auto-select, preference or health-sweep rank: * those feed generation fallback chains a text-less provider must never join. */ export declare function buildDecideDescriptor(entry: DecideCatalogJson): ProviderDescriptor; /** * Single source of truth for provider identity, credentials, defaults, and * runtime behavior classification — the hand-maintained providers plus the * JSON-catalog providers derived above. */ export declare const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[]; /** O(1) canonical-name → descriptor lookup. */ export declare const PROVIDER_DESCRIPTORS_BY_NAME: ReadonlyMap<AIProviderName, ProviderDescriptor>; /** * O(1) alias → canonical-name lookup, covering both `aliases` and each * descriptor's own lowercased `name`. Replaces the O(n) linear scan in * ProviderFactory.normalizeProviderName(). */ export declare const PROVIDER_ALIAS_INDEX: ReadonlyMap<string, AIProviderName>; /** * Throws unless every descriptor that serves `decide` has its own finite * `decideOrder`. The order is the precedence of resolveDefaultDecisionProvider(), * so a missing or repeated number would make that choice depend on array position. */ export declare function assertUniqueDecideOrder(descriptors: readonly ProviderDescriptor[]): void; /** The descriptors that serve `decide`, lowest `decideOrder` first. */ export declare function orderDecisionProviders(descriptors: readonly ProviderDescriptor[]): readonly ProviderDescriptor[]; /** * Providers that serve the `decide` inference type, derived from each * descriptor's `inferenceKinds` and sorted by `decideOrder`, lowest first. A * provider that declares nothing is a text provider, so it is not here. */ export declare const DECISION_PROVIDERS: readonly ProviderDescriptor[]; /** * The decision provider to use when a caller names none: the first * DECISION_PROVIDERS entry that is fully configured, from the environment or * from `credentials`. * * This is where "if somebody configures it, we start using it" is * implemented. Returns undefined when none is configured, which every * internal consumer treats as "carry on exactly as before". */ export declare function resolveDefaultDecisionProvider(credentials?: NeurolinkCredentials): string | undefined; /** * Names of the decision providers that accept images, or, with `video`, the * ones that accept video too: a hint that names a provider which would refuse * the same request is worse than none. */ export declare function listMediaDecisionProviders(needs?: { video?: boolean; }): string[]; /** * The variables that would configure each decision provider, one clause per * provider in precedence order, e.g. "TYPESAFE_API_KEY or AI_GATEWAY_API_KEY * for typesafe, or LAYA_API_KEY and LAYA_BASE_URL for laya". Derived from * DECISION_PROVIDERS so a new decision provider appears in every "nothing is * configured" message without anyone editing one. */ export declare function describeDecisionProviderKeys(): string;