@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
51 lines (50 loc) • 2.75 kB
TypeScript
import type { DecisionError, DecisionPreparedMedia, DecisionState, NeurolinkCredentials } from "../types/index.js";
import { SystemOneDecisionProvider } from "./systemOneDecision.js";
/**
* Perplexity Provider — the `decide` inference type only.
*
* `pplx-decider-v1-27b` answers the same typed `noul` / `choice` / `score`
* questions as the other decision providers, in one batched pass, and also reads
* images. It is a hosted API with a public endpoint, so unlike the self-hosted
* providers it needs only a key. The request loop, retries, auth circuit
* breaker and answer parsing are shared with every decision provider in
* {@link SystemOneDecisionProvider}.
*
* The key is the same `PERPLEXITY_API_KEY` the Sonar text provider reads, so a
* host that has configured that provider has also configured this one.
*
* @see https://docs.perplexity.ai/api-reference/decisions-post
*/
export declare class PerplexityDeciderProvider extends SystemOneDecisionProvider {
private readonly apiKey;
private readonly baseURL;
constructor(modelName?: string, sdk?: unknown, _region?: string, credentials?: NeurolinkCredentials["perplexityDecider"]);
protected getDefaultModel(): string;
protected vendorLabel(): string;
protected vendorDisplayName(): string;
protected decisionApiKey(): string;
protected missingKeyMessage(): string;
protected missingConfigMessage(): string | undefined;
protected decisionEndpoint(): string;
protected decisionHeaders(): Record<string, string>;
/**
* `model` is always sent: the API answers 400 to a request that names none.
* Images travel inside `state`, which becomes an array of the caller's state
* followed by one OpenAI-style `image_url` part per image; the API has no
* separate images field and rejects unknown ones.
*/
protected buildDecisionBody(state: DecisionState, questions: Record<string, Record<string, unknown>>, model: string, media?: DecisionPreparedMedia): Record<string, unknown>;
protected parseDecisionError(status: number, payload: unknown, requestId: string | undefined): DecisionError;
/**
* A 401, a 404 and a 504 carry no request id, so this is undefined for them.
*/
protected readRequestId(headers: Headers): string | undefined;
protected defaultTimeoutMs(questionCount: number): number | undefined;
/**
* `Retry-After` is whole seconds on a 429, or an HTTP date. Anything else, a
* zero and a date already past all read as undefined, so the retry takes the
* default backoff instead of going out at once. `Number()` is not used: it
* reads "0x10" as 16 and "1e3" as 1,000.
*/
protected readRetryAfterMs(headers: Headers): number | undefined;
}