OpenAIVendor

com.softinio.verdict4s.openai.OpenAIVendor
See theOpenAIVendor companion object
final case class OpenAIVendor(safetyIdentifier: Option[String] = ...) extends Vendor

OpenAI Decisions.

POST https://api.openai.com/v1/decisions
{"model": "gpt-6-luna", "input": ..., "questions": [{"type": "predicate", "name": "q00", ...}]}

The base URL includes /v1, as it does in OpenAI's own SDKs, so that an OPENAI_BASE_URL set for them works here unchanged.

Stricter than Jev in three ways, each checked by validate before a request is sent: a Choice needs at least two options, a request carries at most 200 questions, and a Noul cannot describe what yes and no mean. And it may refuse a question, which Ask reports as Verdict4sError.Refused.

Value parameters

safetyIdentifier

an opaque identifier for your end user, which OpenAI uses to detect abuse; at most 128 characters. Never your own account identity.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Vendor
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Read a successful response body.

Read a successful response body.

Attributes

The service's address. A String because core must not depend on http4s; the client turns it into a Uri.

The service's address. A String because core must not depend on http4s; the client turns it into a Uri.

Attributes

gpt-6-luna, the only model OpenAI Decisions supports.

gpt-6-luna, the only model OpenAI Decisions supports.

Attributes

def encode(request: EvaluationRequest): Json

The request body. Does not validate; see validate.

The request body. Does not validate; see validate.

Attributes

Path segments of the evaluation endpoint, relative to the base URL.

Path segments of the evaluation endpoint, relative to the base URL.

Attributes

def name: String

A human-readable name, for logs and error messages.

A human-readable name, for logs and error messages.

Attributes

Response header carrying the per-request correlation id.

Response header carrying the per-request correlation id.

Attributes

A response header giving the retry delay in milliseconds, consulted before the standard Retry-After.

A response header giving the retry delay in milliseconds, consulted before the standard Retry-After.

Attributes

Definition Classes
override def retryable(error: Api): Boolean

An exhausted credit balance comes back as a 429, like a rate limit, but waiting does not fix it. Seen live: {"error": {"type": "insufficient_quota", "code": "credit_balance_exhausted", ...}}, with no x-should-retry header to say so.

An exhausted credit balance comes back as a 429, like a rate limit, but waiting does not fix it. Seen live: {"error": {"type": "insufficient_quota", "code": "credit_balance_exhausted", ...}}, with no x-should-retry header to say so.

Attributes

Definition Classes

Reject requests this vendor cannot serve, such as a feature only the other vendor has, before they cost a round trip. Every problem is reported at once.

Reject requests this vendor cannot serve, such as a feature only the other vendor has, before they cost a round trip. Every problem is reported at once.

Attributes

Definition Classes

The same vendor, sending safety_identifier with every request.

The same vendor, sending safety_identifier with every request.

Attributes

Inherited methods

final def authorization(apiKey: ApiKey): String

The Authorization header value for a key.

The Authorization header value for a key.

Attributes

Inherited from:
Vendor
final def evaluateUrl: String

Where to POST an evaluation, using the default base URL.

Where to POST an evaluation, using the default base URL.

Attributes

Inherited from:
Vendor
final def headers(apiKey: ApiKey): List[(String, String)]

The headers every request needs, as plain pairs.

The headers every request needs, as plain pairs.

Attributes

Inherited from:
Vendor

Parse a successful response body.

Parse a successful response body.

Attributes

Inherited from:
Vendor
final def parseAsk[Q <: Tuple](ask: Ask[Q], body: String): Either[Verdict4sError, Answers[Q]]

Parse a response and project it through the questions that produced it.

Parse a response and project it through the questions that produced it.

Attributes

Inherited from:
Vendor
final def parseError(status: Int, body: String, headers: Map[String, String] = ...): Api

Turn an unsuccessful response into a typed error.

Turn an unsuccessful response into a typed error.

Value parameters

body

the raw body, which need not be JSON

headers

the response headers, for the request id and the retry delay

status

the HTTP status code

Attributes

Inherited from:
Vendor

Validate and encode in one step.

Validate and encode in one step.

Attributes

Inherited from:
Vendor

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product
final def render(request: EvaluationRequest): String

Render a request as the JSON to send. Does not validate; see renderAsk or prepare.

Render a request as the JSON to send. Does not validate; see renderAsk or prepare.

Attributes

Inherited from:
Vendor
final def renderAsk[Q <: Tuple, S : Encoder](ask: Ask[Q], state: S, model: Model = ...): Either[Verdict4sError, String]

Build, validate and render in one step, reporting every problem at once.

Build, validate and render in one step, reporting every problem at once.

Vendor.Jev.renderAsk(Ask(q1, q2), state)

Attributes

Inherited from:
Vendor
final def renderPretty(request: EvaluationRequest): String

Render a request indented, for logs and documentation.

Render a request indented, for logs and documentation.

Attributes

Inherited from:
Vendor