Advanced: structure - TypeSafe AI
Where structure is allowed
Every one of these fields is an EntryType.
| Field | Applies to | Accepted shape |
|---|---|---|
instructions |
Choice, Score, Noul | string, object, array, or null |
criteria values (option descriptions) |
Choice | string, object, array, or null |
criteria entries (level descriptions) |
Score | string, object, array, or null |
criteria.true and criteria.false |
Noul | string, object, array, or null |
When to structure a question
- When it helps with clarity. When a question has multiple parts, putting them in the form of JSON helps with clarity because the keys are labeled.
- When question needs supporting data. A schema, a taxonomy, or a database row is already JSON. Use the JSON entirely or pass in the relevant subfields instead of serializing them into a string template.
Structured instructions
One field object describes the field being checked, and each question refers to it by key. The same shape drives a Noul that verifies a value, a Choice that picks one from candidates, and two Scores that place a value on a scale.
Structured Choice options
A Choice option description can be a structured object as well.
JSON rubric for boundary clarification
request
{
"state": "I ordered the standing desk two weeks ago and tracking still says label created. Was I even charged?",
"questions": {
"department": {
"type": "choice",
"instructions": {
"question": "Which team should handle this message?",
"focus": "Classify the customer's primary request, not every topic mentioned."
},
"criteria": {
"billing": {
"what": "Charges, invoices, refunds, or subscriptions",
"not_for": "Order tracking or account access",
"examples": [
"I was charged twice",
"Where is my refund?"
]
},
"orders": {
"what": "Order status, delivery, cancellation, or returns",
"not_for": "Charges or account access",
"examples": [
"Where is my package?",
"Cancel my order"
]
},
"account": {
"what": "Login, password, profile, or security",
"not_for": "Charges or delivery",
"examples": [
"I can't log in",
"Change my email"
]
}
}
}
}
}
This structured approach allows for a clear, systematic method of documenting complex functionalities in a way that can be easily interpreted and implemented.