jev4k
A Kotlin Multiplatform DSL and client for TypeSafe's Jev "System One" model, built on the Ktor client and kotlinx.serialization. It runs on the JVM, Apple platforms, Linux, Windows, and Node.js (js and wasmJs). You send a state (text, JSON, or any @Serializable value) and a set of typed questions. Jev answers each question with a typed judgment and probabilities that code can branch on, without generating any text.
jev4k supports three question types, and experimentally a fourth, Box, over images (see JevImage):
| Question | Answer | Use it when |
|---|---|---|
| Noul | NoulAnswer: the probability of yes | a yes/no condition |
| Choice | ChoiceAnswer: the option chosen, per-option probabilities, confidence | one of a known set of options |
| Score | ScoreAnswer: a probability-weighted level, per-level probabilities, confidence | a position on ordered, described levels |
| Box | BoxAnswer: a bounding box, as fractions of the image, and a confidence | where something is in an image |
Two ways to ask
Declare a reusable JevQuery, where property names become question ids and handles read typed answers:
object Triage : JevQuery() {
val urgent by noul("Does this message convey urgency?")
val department by choice<Dept>("Which team should handle this?")
val frustration by score("How frustrated is the customer?") {
levels("Calm", "Frustrated but civil", "Very angry")
}
}
JevClient().use { jev ->
val result = jev.ask(Triage, state = ticket)
when (result[Triage.department].choice) { /* ... */ }
}Or ask inline with string ids through query:
val result = jev.query(state = ticket) {
noul("refund", "Does the customer explicitly request a refund?")
include(Triage)
}
result.noul("refund").noulEntry points
JevClient is the client, configured with JevConfigBuilder or the
TYPESAFE_API_KEY,TYPESAFE_BASE_URLandTYPESAFE_DEFAULT_MODELenvironment variables. On the JVM, JevClient.blocking offers the same calls without coroutines.JevApi is the interface to depend on (and mock in tests); evaluate is the call every question goes through, and models is its only other network call.
JevResult holds the answers, the reported model, token usage and the request id.
RetryPolicy sets retries; the defaults match the official JS SDK's.
JevException is the base of every error: local validation, API status errors, malformed responses and connection failures.