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):

QuestionAnswerUse it when
NoulNoulAnswer: the probability of yesa yes/no condition
ChoiceChoiceAnswer: the option chosen, per-option probabilities, confidenceone of a known set of options
ScoreScoreAnswer: a probability-weighted level, per-level probabilities, confidencea position on ordered, described levels
BoxBoxAnswer: a bounding box, as fractions of the image, and a confidencewhere 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").noul

Entry points

  • JevClient is the client, configured with JevConfigBuilder or the TYPESAFE_API_KEY, TYPESAFE_BASE_URL and TYPESAFE_DEFAULT_MODEL environment 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.

Packages

Link copied to clipboard
common
native
web