Skip to main content

Module question

Module question 

Source
Expand description

The providers’ shared question shape, and the images an item may carry.

Both starting providers (Cloudflare Workers AI @cf/cloudflare/clef and TypeSafe jev-latest) take the same question object, and a runner forwards each question to the provider as the caller wrote it. The field names are the providers’ own; see CONTRACT.md for the sources.

Modules§

content_types
Image content types a provider accepts in the object form.
types
Question type names.

Structs§

InlineImage
An image in its object form: {content_type, base64}.
Question
One question: {type, instructions, criteria?}.

Enums§

Criteria
A question’s criteria, as the providers document it per type:
Image
An image: a data: URL string, or {content_type, base64}. Remote URLs are never accepted.
QuestionType
A question type. Decodes open: a value other than types is kept in QuestionType::Other. The open variant is for decoding a reply, where a provider’s new type passes through as given; in a request, check_question refuses it invalid_params naming questions.<id>.type, because a runner can neither validate nor map a type it does not know.

Constants§

CHOICE_MAX_OPTIONS
Most options a choice question may have.
CHOICE_MIN_OPTIONS
Fewest options a choice question may have.
IMAGES_MAX_TOTAL_BYTES
Largest total of an item’s images, in decoded bytes (8 MiB).
IMAGE_MAX_BYTES
Largest image, in decoded bytes (4 MiB).
IMAGE_MAX_PIXELS
Largest image, in pixels (16 megapixels). The role crate does not decode images, so this is a runner’s check, not check_image’s.
NOUL_CRITERIA_KEYS
The two keys of a noul question’s optional criteria.
QUESTION_ID_MAX_LEN
Longest question id, in bytes. Ids are caller-chosen, [a-z0-9_-].
SCORE_MAX_LEVELS
Most levels a score question may have.
SCORE_MIN_LEVELS
Fewest levels a score question may have.

Functions§

check_image
Check one image’s form and size. The error says why it is refused.
check_question
Check one question against the role’s limits. A refusal names questions.<id> (the id), questions.<id>.type (a type this crate does not name, checked before anything else about the question, since the rest depends on the type), questions.<id>.instructions or questions.<id>.criteria.
is_question_id
Whether id is a valid question id: 1 to QUESTION_ID_MAX_LEN characters of [a-z0-9_-].