TypeSafeModelFactory

@ApiStatus.Experimental
open class TypeSafeModelFactory : SystemOneModelFactory

Builds decision services for TypeSafe's Jev models. TypeSafe speaks System One, so this is a SystemOneModelFactory with TypeSafe's address, provider name and request id header.

TypeSafe always needs a key. A missing key fails each call as unavailable before anything is sent, and buildValidated rejects it. Building a service never reads the key.

Constructors

Link copied to clipboard
constructor(apiKey: Supplier<String>)
Uses TypeSafe's address and the default model.
constructor(apiKey: Supplier<String>, defaultModel: String)
Uses TypeSafe's address with another default model.
constructor(options: TypeSafeClientOptions, apiKey: Supplier<String>)
Uses the given settings and the default model.
constructor(options: TypeSafeClientOptions, apiKey: Supplier<String>, observationRegistry: ObservationRegistry)
Uses the given settings and the default model, recording observations.
constructor(options: TypeSafeClientOptions, apiKey: Supplier<String>, restClientBuilder: Builder)
Uses the given settings and the application's HTTP client.
constructor(options: TypeSafeClientOptions, apiKey: Supplier<String>, restClientBuilder: Builder, observationRegistry: ObservationRegistry)
Uses the given settings and the application's HTTP client, recording observations.
constructor(options: TypeSafeClientOptions, apiKey: Supplier<String>, restClientBuilder: Builder, observationRegistry: ObservationRegistry, defaultModel: String)
Sets every option.

Properties

Link copied to clipboard
val DEFAULT_MODEL: String = "jev-latest"
The Jev alias that always points at TypeSafe's newest model.
Link copied to clipboard
Link copied to clipboard
val PROVIDER: String = "TypeSafe"
The provider name on every service and result this factory produces.
Link copied to clipboard
val REQUEST_ID_HEADER: String = "x-typesafe-request-id"
The response header TypeSafe puts its request id in.

Functions

Link copied to clipboard

Returns a service for the default model.

Link copied to clipboard

Reads the key once, checks it by listing the endpoint's models with it, then returns a service for the default model. A missing key, a rejected listing or an unreachable endpoint all count as an invalid key. A key supplier that throws InvalidApiKeyException itself, as one that insists on a key does for a blank one, counts as a missing key. An already interrupted caller is cancelled before the key is read, including when no key is configured. An interrupted key supplier also throws a CancellationException.

Link copied to clipboard

Lists the models the endpoint serves.

Link copied to clipboard
open fun toString(): String