SystemOneModelFactory

@ApiStatus.Experimental
open class SystemOneModelFactory constructor(endpoint: SystemOneEndpoint, val defaultModel: String, apiKey: Supplier<String?>, restClientBuilder: <Error class: unknown class>? = null, observationRegistry: <Error class: unknown class> = ObservationRegistry.NOOP)

Builds decision services for the models on one System One endpoint. Every service the factory builds shares one HTTP client and one key supplier.

Building a service never resolves the key or contacts the endpoint. The key is read on each call, so a rotated key takes effect on the next call. A blank key sends no Authorization header, which suits endpoints that need none. The endpoint's binding validates the default model at construction, before credentials are read.

When restClientBuilder is given, a clone of it is used, so its transport, interceptors and timeouts apply. Otherwise the factory builds a client with the endpoint's timeouts that does not follow redirects.

Parameters

endpoint

where the models live

defaultModel

the model build and buildValidated return

apiKey

supplies the key for each call

restClientBuilder

the application's HTTP client builder, or null for the factory's own

observationRegistry

records decision and request observations

Inheritors

Constructors

Link copied to clipboard
constructor(endpoint: SystemOneEndpoint, defaultModel: String, apiKey: Supplier<String?>, restClientBuilder: <Error class: unknown class>? = null, observationRegistry: <Error class: unknown class> = ObservationRegistry.NOOP)

Properties

Link copied to clipboard

Functions

Link copied to clipboard

Returns a service for the default model.

Returns a service for the named model. The endpoint's binding checks the name first, and the endpoint decides whether a model it accepts exists.

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 override fun toString(): String