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§
- Inline
Image - 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. - Question
Type - A question type. Decodes open: a value other than
typesis kept inQuestionType::Other. The open variant is for decoding a reply, where a provider’s new type passes through as given; in a request,check_questionrefuses itinvalid_paramsnamingquestions.<id>.type, because a runner can neither validate nor map a type it does not know.
Constants§
- CHOICE_
MAX_ OPTIONS - Most options a
choicequestion may have. - CHOICE_
MIN_ OPTIONS - Fewest options a
choicequestion 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
noulquestion’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
scorequestion may have. - SCORE_
MIN_ LEVELS - Fewest levels a
scorequestion 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>.instructionsorquestions.<id>.criteria. - is_
question_ id - Whether
idis a valid question id: 1 toQUESTION_ID_MAX_LENcharacters of[a-z0-9_-].