TypeSafeDecisionModel
A DecisionModel that calls Jev, the decision model of TypeSafe AI, through its System One API. Jev does not write text: it picks an option, answers yes or no, or rates on a scale, in a fraction of the time and the price of a chat model. It is built on Ktor, so it runs on every Kotlin target.
val client = HttpClient()
val jev = TypeSafeDecisionModel(client, apiKey = System.getenv("TYPESAFE_API_KEY"))
val answer = jev.choose(email.body, "Which team should handle this email?", mapOf("refund" to null, "technical" to null))HttpClient() uses the Ktor engine among your dependencies. The client is yours: share one between models, and close it when your app is done with it. A call may take one minute, whatever limits the client and its engine have. Change the limit with timeout.
The API answers 429 or 529 when it has too much to do. This class does not try again by itself: install the HttpRequestRetry plugin of Ktor in client to retry those with a pause.
All questions of one request are answered together, so several questions about the same state cost one call. Question.YesNo is what TypeSafe calls a Noul.
Parameters
the Ktor client that sends the requests.
the TypeSafe API key.
the id of the model. jev-latest moves to each new release; give a version such as jev-1.13.0 when you have set confidence limits for it.
more headers for every request.
where the API lives. Change it to go through a proxy or a gateway.
how long one call may take. It replaces the limits of client and of its engine for the requests of this model. null leaves those limits in place.
Throws
if timeout is not positive.
Constructors
Functions
Sends the questions of request to the System One API and returns Jev's answers.