/** * TypeSafe AI's decision models, Jev first, over its System One API: every question of a decision in * one call, each answered with its probabilities, or with a box around something in a picture, and no * text to parse. */ import type { MediaResolveOptions } from '../evaluate/media.js'; import type { DecisionCallContext, DecisionProvider, DecisionProviderInfo, DecisionProviderRequest, DecisionProviderResult } from './core.js'; /** Options for `TypeSafeDecisionProvider`. */ export interface TypeSafeDecisionProviderOptions { /** A TypeSafe AI API key, from its console. A tenant's resolved credential replaces it per call. */ apiKey: string; /** * The API's base URL. Defaults to `https://api.typesafe.ai`; a proxy that passes the API through, * such as LiteLLM's at `/typesafe`, works as well. */ baseUrl?: string; /** The model asked when a request names none. Defaults to `jev-latest`. */ model?: string; /** * Sends `TypeSafe-Danger-Zone-Long-Context: true`, which TypeSafe AI requires for a state longer * than its usual context, and marks as experimental. */ longContext?: boolean; /** * Reads the pictures a state holds by reference, with the media family's readers: `readFile` for a * file, `fetch` for a URL, and `assets` for a stored asset. A picture held as bytes or base64 needs * none of them. Without them, a picture by reference fails the decision, naming it. */ media?: MediaResolveOptions; /** * How a decision's pictures travel: `multipart`, the default, each as a part of its own beside the * request, as bytes; or `base64`, within the JSON request, a third larger. Either way a request * holds at most 32 MiB, so multipart carries more. */ pictures?: 'multipart' | 'base64'; /** How long a call may take before it fails, in milliseconds. Defaults to 30 seconds. */ timeoutMs?: number; /** Headers added to every request. */ headers?: Record; /** Replaces the global `fetch`. */ fetch?: typeof fetch; } /** * TypeSafe AI's System One API (`POST /v1/systemone`): Jev, a model that answers only typed * questions, a yes or no ("noul"), a choice among up to 255 options, a score on up to ten levels, or a * box around something in a picture, and bills for input tokens alone. Every question of a decision * goes in one call and is answered in isolation, against the same state. The pictures a state holds * are sent as the API's assets, each as a part of a multipart request unless `pictures` says * `base64`, with the `TypeSafe-Danger-Zone-Images` header it requires for them and for a box, both of * which it marks as experimental; a box needs Jev 1.14 or later. * * ```ts * const decisions = new DecisionManager({ providers: { jev: new TypeSafeDecisionProvider({ apiKey: process.env.TYPESAFE_API_KEY! }) } }); * ``` */ export declare class TypeSafeDecisionProvider implements DecisionProvider { private readonly options; /** Its name and what it takes: every question type, pictures, 255 options, and 10 levels. */ readonly info: DecisionProviderInfo; constructor(options: TypeSafeDecisionProviderOptions); /** Answers every question of a decision in one call. */ decide(request: DecisionProviderRequest, context: DecisionCallContext): Promise; /** The models the key may use, from `GET /v1/models`. */ listModels(context?: Partial): Promise; /** * The state with each picture replaced by a reference of its own, and the pictures as assets by those * references; a state without pictures as it was. A new reference per picture per request, as the * API advises, since it matches a reference wherever its text appears. Sent multipart, each picture's * part is named by its reference too. */ private withAssets; private call; }