Avançado: estrutura
Instruções, opções de Choice, níveis de Score e criteria de Noul aceitam todos estrutura JSON.
Os modelos System One são treinados para compreender estrutura.
Onde a estrutura é permitida
Cada um destes campos é um EntryType.
| Campo | Aplica-se a | Forma aceite |
|---|---|---|
instructions |
Choice, Score, Noul | string, object, array ou null |
valores de criteria (descrições das opções) |
Choice | string, object, array ou null |
entradas de criteria (descrições dos níveis) |
Score | string, object, array ou null |
criteria.true e criteria.false |
Noul | string, object, array ou null |
Quando estruturar uma pergunta
- Quando ajuda na clareza. Quando uma pergunta tem várias partes, colocá-las na forma de JSON ajuda na clareza porque as chaves estão etiquetadas.
- Quando a pergunta precisa de dados de apoio. Um esquema, uma taxonomia ou uma linha de uma base de dados já são JSON. Usa o JSON por inteiro ou passa apenas os subcampos relevantes, em vez de os serializar para um modelo de string.
Instruções estruturadas
Um objeto field descreve o campo que está a ser verificado, e cada pergunta refere-o pela chave. A mesma forma serve um Noul que verifica um valor, um Choice que escolhe um entre candidatos e dois Scores que colocam um valor numa escala.
{
"state": {
"source_text": "Invoice #4471 issued March 3, 2026 to Beaver Dam Logistics for $12,840.00, net 30."
},
"questions": {
"invoice_number_is_correct": {
"type": "noul",
"instructions": {
"field": {
"name": "invoice_number",
"type": "string",
"description": "The identifier printed on the invoice."
},
"extracted_value": "4471",
"question": "Does `extracted_value` match the `field` as it appears in `source_text`?"
}
},
"customer_name": {
"type": "choice",
"instructions": {
"field": {
"name": "customer_name",
"type": "string",
"description": "The organization the invoice was issued to."
},
"question": "Which option is the value of `field` in `source_text`?"
},
"criteria": {
"Beaver Logistics": null,
"Dam Logistics": null,
"Beaver Dam Logistics": null,
"Beaver": null,
"Dam": null
}
},
"amount_due": {
"type": "score",
"instructions": {
"field": {
"name": "amount_due",
"type": "number",
"unit": "USD",
"description": "The total the invoice asks to be paid."
},
"question": "How large is the `field` value in `source_text`?"
},
"criteria": [
"Under $1,000",
"$1,000 to $10,000",
"$10,000 to $100,000",
"$100,000 to $1,000,000",
"Over $1,000,000"
]
},
"payment_terms": {
"type": "score",
"instructions": {
"field": {
"name": "payment_terms",
"type": "integer",
"unit": "days",
"description": "Days allowed for payment, from terms such as \"net 30\"."
},
"question": "How many days does the `field` in `source_text` allow for payment?"
},
"criteria": [
"Due on receipt",
"Net 10",
"Net 30",
"Net 60",
"Net 90"
]
}
}
}Em código, podes iterar sobre os registos potenciais e construir uma destas perguntas por campo, todas enviadas numa única chamada. O cookbook de cascata SDE faz algo semelhante a isto.
Os arrays também funcionam. Usa um quando a instrução é uma lista de coisas a verificar ou a comparar:
"instructions": {
"question": "Does the claimed sender identity conflict with the sending domain?",
"compare": ["ticket.sender.display_name", "ticket.sender.email"],
"focus": "Compare the named organization with the email domain."
}
Opções de Choice estruturadas
A descrição de uma opção de Choice também pode ser um objeto estruturado.
Rubrica JSON para clarificar fronteiras
{
"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"
]
}
}
}
}
}O exemplo diz ao modelo o que cada opção abrange e o que não abrange. Afina a fronteira entre as opções.
Percorrer uma taxonomia
Para classificar numa taxonomia profunda, faz um Choice por nível e percorre a árvore em código. A cada passo, as opções são os filhos do nó atual e o valor de cada opção é a subárvore do filho. Fazer isto permite ao modelo ver o que existe sob um ramo antes de se comprometer com ele, o que é importante quando o item pertence a uma folha cujo nome não é óbvio só pelo nome do ramo.
Aqui o estado é uma listagem de produto e a primeira pergunta escolhe um departamento de topo.
{
"state": "32oz plastic bottle with a flip straw lid. Fits most bike cages.",
"questions": {
"department": {
"type": "choice",
"instructions": "Which top-level department does this product belong to?",
"criteria": {
"Sporting Goods": {
"Cycling": [
"Bike Bottles & Cages",
"Bike Lights",
"Helmets"
],
"Fitness": [
"Yoga Mats",
"Resistance Bands"
],
"Outdoor": [
"Tents",
"Sleeping Bags",
"Hydration Packs"
]
},
"Home & Kitchen": {
"Drinkware": [
"Water Bottles",
"Travel Mugs",
"Tumblers"
],
"Cookware": [
"Pots & Pans",
"Bakeware"
]
},
"Baby & Toddler": [
"Sippy Cups",
"Bottle Warmers",
"Bibs"
]
}
}
}
}O frasco encaixa plausivelmente em dois departamentos. Mostrar as subárvores permite ao modelo ver que existem tanto Sporting Goods > Cycling > Bike Bottles & Cages como Home & Kitchen > Drinkware > Water Bottles, e pesar a ênfase da listagem nos suportes de garrafa para bicicleta contra os recipientes de bebida do dia a dia. As probabilities nesta resposta dizem-te se a divisão está suficientemente próxima para explorar os dois ramos.
Depois de escolhido um departamento, faz o Choice seguinte com os filhos desse departamento como opções e as respetivas subárvores como valores, e repete até chegares a uma folha. Em código, isto pode ser um ciclo sobre um dicionário aninhado, em que o criteria de cada pergunta é simplesmente o nó atual. O cookbook de classificação hierárquica mostra um exemplo de uma travessia semelhante da árvore, incluindo uma pesquisa em feixe que mantém vários caminhos candidatos vivos quando as probabilidades estão próximas.
Níveis de Score estruturados
Cada entrada de um array criteria de Score pode ser um objeto.
{
"state": "Fixed the null check in the payment handler. Also refactored the retry loop while I was in there, and bumped the SDK version since the old one had that timeout bug.",
"questions": {
"pr_scope": {
"type": "score",
"instructions": {
"question": "How focused is this pull request description on a single change?",
"note": "Judge the number of independent changes, not the size of any one change."
},
"criteria": [
{
"summary": "One change, clearly stated",
"signals": [
"A single fix or feature",
"Nothing described as \"also\" or \"while I was in there\""
]
},
{
"summary": "One main change plus a small related tweak",
"signals": [
"A primary change and one minor adjacent edit",
"The tweak supports the main change"
]
},
{
"summary": "Several independent changes bundled together",
"signals": [
"Two or more unrelated fixes or features",
"Changes that could each be their own PR"
]
}
]
}
}
}Criteria de Noul estruturados
Os criteria de Noul são opcionais e, quando a fronteira sim/não é subtil, descrições estruturadas de true e false permitem-te fixá-la com uma definição e exemplos de cada lado.
{
"state": {
"sender": {
"display_name": "Beaver Dam Builders Ltd.",
"email": "donotreply@payroll.example"
},
"message": "Your Q3 bonus is ready. Reply with your login password so we can verify your identity and release the funds."
},
"questions": {
"requests_credentials": {
"type": "noul",
"instructions": {
"question": "Does the `message` ask the recipient to disclose a sensitive credential?",
"inspect": "message",
"focus": "Look for a request to send the credential itself, not a request to change or reset it."
},
"criteria": {
"true": {
"what": "Asks the recipient to reply with, type, or send a password, PIN, one-time code, or other security sensitive answer",
"examples": [
"Reply with your password",
"Send us the 6-digit code you just received"
]
},
"false": {
"what": "No sensitive credential is requested",
"examples": [
"Reset your password from the settings page",
"Your statement is ready"
]
}
}
}
}
}