package verdict

  1. Overview
  2. Docs

Verdict: an OCaml client for the TypeSafe AI evaluation API

An Eio-native client for the TypeSafe AI evaluation API. Questions carry their answer type, so answers cannot be read as the wrong kind of answer:

let ( let* ) = Result.bind
let* spam = Verdict.Question.noul ~id:"spam" () in
let* request =
  Verdict.Request.create ~state:(Verdict.Content.text "...") [Verdict.Question.pack spam]
in
let* responses = Verdict.Client.evaluate client ~sw request in
Option.map
  (fun (answer : Verdict.Answer.Noul.t) ->
     Verdict.Probability.to_float answer.probability)
  (Verdict.Response.find responses spam)

Modules

Errors

Every failure is an Verdict.Error value. Timeout, Connection and retryable Api statuses are retried according to Verdict.Retry; Configuration, Tls, Decode, Response_too_large and other Api errors are returned immediately. Error.Api and Error.Decode carry the x-typesafe-request-id header when the server provides one.

Safety

Response bodies are capped by Verdict.Config.max_response_bytes, each attempt runs under Verdict.Config.timeout on its own connection, and the API key is never included in error messages or logs.