A client for TypeSafe's Jev decision model (https://docs.typesafe.ai/api.md).
Jev is not a chat model. It takes a state and named, typed JevQuestions and answers each with a typed JevAnswer: the probability of a yes, the selected option with a distribution, a score along ordered levels. So this client is not an LLMClient and returns no Completion; it has no streaming and no conversation.
val decision = for
config <- JevConfigLoader.default()
client <- JevClient(config)
response <- client.evaluate(JevRequest("Charged twice; please refund", Map("urgent" -> JevQuestion.noul("Is this urgent?"))))
urgent <- response.noul("urgent")
yield urgent.probability
evaluate is blocking and returns every failure as a org.llm4s.types.Result: an invalid request is a ValidationError before anything is sent, a rejected key an AuthenticationError, a rate limit a RateLimitError carrying the delay the server asked for, an outage a ServiceError, a transport failure a NetworkError or TimeoutError, a response that does not match the API a ProcessingError, and an interrupt a CancelledError. Transient failures are retried as the config's JevRetryPolicy says. The API key is never printed or logged, and is masked in an error wherever the server echoed it verbatim, JSON-escaped or URL-encoded (a partial echo of the key is not recognised).
'''No idempotency key.''' TypeSafe's documentation describes no idempotency key or other de-duplication mechanism, so this client does not invent one: each attempt of a retried request is a new, billable call. A header the caller attaches with JevRequest#withHeader is sent unchanged on every attempt.
The client is thread-safe. close releases the HTTP connections it owns.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait AutoCloseableclass Objecttrait Matchableclass Any