Verdict4sClient

com.softinio.verdict4s.Verdict4sClient
See theVerdict4sClient companion object
trait Verdict4sClient[F[_]]

A client for a decision API: Jev, OpenAI Decisions, or any other Vendor.

Code written against this trait works with every vendor. The questions, Ask and the typed answers are the same whichever one answers them:

def triage[F[_]](
   client: Verdict4sClient[F]
): F[(NoulAnswer, ChoiceAnswer[Dept])] =
 client.ask(
   Ask(
     Question.noul("Does this convey urgency?"),
     Question.choice[Dept]("Which team should handle this?")
   ),
   "Help! My payouts have been failing for 3 days."
 )

triage(Verdict4sClient.jev[IO](httpClient, typesafeKey))
triage(Verdict4sClient.openAI[IO](httpClient, openAIKey))

What only one vendor offers is a separate capability trait, mixed into that vendor's client: ModelCatalog on JevClient, SafetyIdentity on OpenAIClient. Ask for exactly what you use, and the compiler stops a call the chosen vendor cannot serve:

def report[F[_]](using c: Verdict4sClient[F] & ModelCatalog[F]) = c.models

Takes an http4s Client[F] rather than building one. That single decision buys every backend and every platform without this library owning any of them — Ember, Fetch, Blaze, Netty, the JDK client — and it is why the test suite needs no network: Client.fromHttpApp serves routes in memory, so the same tests run on the JVM and on Node.

Retries are on by default, matching the official SDKs; see algebra.RetryPolicy to tune or disable them.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class JevClient[F]
class OpenAIClient[F]

Members list

Value members

Abstract methods

def ask[Q <: Tuple, S : Encoder](questions: Ask[Q], state: S): F[Answers[Q]]

Ask a set of questions and get back exactly typed answers.

Ask a set of questions and get back exactly typed answers.

val (urgent, dept, mood) = client.ask(Ask(q1, q2, q3), state)

Fails with Verdict4sError.Refused if the vendor declines a question that was not built with orRefused.

Attributes

The settings this client applies to every request.

The settings this client applies to every request.

Attributes

Evaluate a request built by hand.

Evaluate a request built by hand.

The escape hatch: answers come back in the map-based algebra.Evaluation, keyed by whatever question names you chose. Use ask when the questions are known statically. The request is checked against the vendor's own limits before it is sent.

Attributes

def vendor: Vendor

The vendor this client speaks to.

The vendor this client speaks to.

Attributes

A copy with different settings.

A copy with different settings.

Attributes

A copy drawing retry jitter differently. Mostly useful in tests.

A copy drawing retry jitter differently. Mostly useful in tests.

Attributes