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.96 kB
/** * What a failed request may tell the client. * * An exception's text names environment variables, provider wiring, file * paths and upstream response bodies; none of that belongs in a response to * an unknown caller. A route therefore answers with one of a few fixed * messages plus the request id, and the detail goes to the server log under * that id, where the operator can find it. The pattern is the one the OpenAI * proxy route already followed. * * What is passed through: a `ServerAdapterError` below 500, whose message * this server composed (a validation failure, a missing route), and the * category of a provider that is missing credentials, without saying which * credential. * * @module server/utils/clientError */ import type { ServerClientFacingError } from "../../types/index.js"; export declare const GENERIC_ERROR_MESSAGE = "An internal error occurred"; export declare const PROVIDER_NOT_CONFIGURED_MESSAGE = "The requested provider is not configured on this server"; export declare const UPSTREAM_RATE_LIMITED_MESSAGE = "The upstream provider is rate limiting this server; retry later"; export declare const REQUEST_TIMEOUT_MESSAGE = "The request timed out"; /** * The response for `error`. Never the exception's own text unless this * server wrote it (a `ServerAdapterError` below 500). */ export declare function clientFacingError(error: unknown): ServerClientFacingError; /** * Log the detail the client does not get, under the request id the client * does get. A client error is routine traffic and logs as one line; anything * else keeps its stack. */ export declare function logClientFacingError(source: string, requestId: string | undefined, error: unknown, shaped: ServerClientFacingError): void; /** {@link clientFacingError} and {@link logClientFacingError} in one step. */ export declare function shapeRouteError(source: string, requestId: string | undefined, error: unknown): ServerClientFacingError;