Member Junction
    Preparing search index...

    Class BaseSystemOneDecisionAbstract

    A BaseDecision driver for an API that speaks the System One decisions wire format. It maps MJ's questions onto the wire (a Likelihood as noul, a Choice's options as { value: description }, a Score's levels as an array), maps the typed answers back, and records the dated model and usage. Choice and Score distributions are renormalised, because these APIs round each probability.

    A subclass supplies, through protected hooks:

    Credential is the API key read with ParseSystemOneCredential, so a credential resolved from an AI Credential sends its apiKey, not its JSON.

    SendRequest is the one network call, so a test double overrides only it.

    An HTTP or network error is thrown, carrying the HTTP status, so Decide() classifies it and rate limits and server errors allow failover. A 2xx response that cannot be mapped fails the result with a failover-eligible error (see FailResult).

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    Methods

    • The message of the error thrown for a non-2xx response. Defaults to the status and the first 500 characters of the body.

      Parameters

      • status: number

        The HTTP status.

      • bodyText: string

        The response body as text, possibly empty, with the API key already redacted (RedactSecret).

      Returns string

    • The error type for a non-2xx status whose ErrorAnalyzer reading is wrong for this API, or undefined (the default) to leave it to ErrorAnalyzer, which reads the message and the status. A type returned here is attached to the thrown error as a Retriable error that allows failover: another candidate may answer what this API refused.

      Parameters

      • _status: number

        The HTTP status.

      Returns AIErrorType

    • The request headers. Defaults to the credential's API key as a bearer token and a JSON content type.

      Parameters

      • _model: string

        The model being asked.

      Returns Record<string, string>

    • Sends the request. This is the driver's only network call; a test double overrides it to stand in for the network.

      Parameters

      • url: string

        The endpoint from GetEndpointURL.

      • init: RequestInit

        The POST: method, headers, JSON body and the caller's cancellation signal.

      Returns Promise<Response>

    • Returns the System One response ({ model, answers, usage }) from a parsed 2xx body. Defaults to the body itself. A vendor that wraps the response in an envelope unwraps it here, and throws (with CreateSystemOneHTTPError) when the envelope reports a failure.

      Parameters

      • body: unknown

        The parsed JSON body.

      • _status: number

        The HTTP status, for an error thrown from here.

      Returns unknown