Skip to main content

Module request

Module request 

Source
Expand description

classify.run requests and their validators.

A runner validates a request completely before it records anything or calls a provider: parse_request decodes the request text naming the first malformed field, check_request_bytes checks its size, check_catalog_row the model’s catalog row, and check_request every limit the model’s role.describe entry states. Each refusal carries its code and detail.field.

Structs§

ClassifyRequest
The classify.run request.
Item
One item: {state, images?}.

Constants§

BATCH_ID_MAX_LEN
Longest batch_id, in bytes.
CLASSIFIER_KIND
The catalog kind of a classifier model.

Functions§

check_catalog_row
Check the model’s catalog row: None when the model is not in the catalog (model_unknown), else its kind, which must be CLASSIFIER_KIND (model_not_classifier). The model is never substituted.
check_request
Check every limit of request against the model’s role.describe entry: the batch id, question count and each question, item count, each item’s state and images, and max_cost_usd. Returns the first refusal.
check_request_bytes
Check the request body’s size against the module’s limit. The refusal names params and the limit: the size belongs to the request as a whole, so no narrower path applies.
effective_ceiling
The ceiling a call works under, and the batch’s recorded ceiling from then on: the lower of the ceiling recorded so far and the one this call carries. None when neither names one.
is_batch_id
Whether batch_id is 1 to BATCH_ID_MAX_LEN printable ASCII characters (space through tilde).
is_state
Whether state is a kind the role forwards: a string, an object or an array.
parse_request
Decode a classify.run request from its JSON text, refusing a malformed one invalid_params naming the first malformed field. Decoding from the text keeps the order of the questions and of each choice’s options.