llm_wire/classify

Bounded, typed classification beside chat generation.

Build questions with classify/question, prepare without I/O, then run through your application-owned HTTP Gun client. TypeSafe System One is the first wire. wire accepts another provider’s encoding and decoding; transport, limits, failures and correlated telemetry stay shared. Confidence is provider concentration evidence, not answer correctness.

Types

pub type Config =
  @internal Config
pub type Decoded =
  @internal Decoded
pub type Outcome(a) =
  @internal Outcome(a)
pub type Prepared(a) =
  @internal Prepared(a)
pub type Request(a) =
  @internal Request(a)
pub type Wire =
  @internal Wire

Values

pub fn config(reveal: fn() -> String) -> Config

Live settings contain no protocol. The key is a reveal closure and is validated during preparation only after pure configuration admission.

pub fn decoded(
  model: String,
  answers: List(#(String, protocol.Answer)),
  usage: option.Option(message.Usage),
) -> Decoded
pub fn prepare(
  wire: Wire,
  config: Config,
  request: Request(a),
) -> Result(Prepared(a), error.PrepareError)

Reject incompatible live limits before revealing credentials or making I/O.

pub fn receipt_codec(
  wire: Wire,
  questions: question.Batch(a),
) -> codec.Codec(Outcome(a))

A durable receipt codec captures only pure wire projections. It reads the original bridge receipts as well as the provider-neutral receipt format. The wire’s fixed receipt request and response byte limits bound the saved protocol evidence on encode and decode. The storage reader separately owns the limit for the enclosing record, including escaping and stored state.

pub fn request(
  model: String,
  state: value.Value,
  questions: question.Batch(a),
) -> Request(a)
pub fn run(
  client: http_gun.Client,
  prepared: Prepared(a),
) -> Result(Outcome(a), llm_wire.Failure)
pub fn typesafe() -> Wire

The pure TypeSafe protocol, including stable receipt bounds.

pub fn wire(
  provider: message.Provider,
  endpoint: String,
  encode: fn(
    String,
    value.Value,
    List(#(String, protocol.QuestionView)),
  ) -> Result(String, error.PrepareError),
  decode: fn(String) -> Result(Decoded, error.Error),
) -> Wire

Another wire projects the question vocabulary into its own protocol. Both callbacks must be pure and must not capture credentials. Shared JSON syntax and duplicate-key checks precede decoding within the admitted byte allowance. No depth, value-count or numeric-token limit is added here. The wire checks its own mandatory fields and precise numbers before Float conversion; shared admission checks candidate evidence against the authored questions.

pub fn with_endpoint(config: Config, url: String) -> Config
pub fn with_headers(
  config: Config,
  headers: fn() -> List(#(String, String)),
) -> Config

Replace Bearer authentication. The unused API key is never revealed.

pub fn with_receipt_request_limit(wire: Wire, bytes: Int) -> Wire

Stable request evidence allowance for this wire/operation version.

pub fn with_receipt_response_limit(
  wire: Wire,
  bytes: Int,
) -> Wire

Stable response evidence allowance for this wire/operation version.

pub fn with_request_limit(config: Config, bytes: Int) -> Config
pub fn with_response_limit(config: Config, bytes: Int) -> Config
pub fn with_timeout(
  config: Config,
  timeout: llm_wire.Bound,
) -> Config
✨ Search Document