Bash · Recipes
Label a JSON file and keep its ids
Label every ticket in a JSON array by kind and urgency. --field /body sends only the body. The id and the date stay in each record. Run it again, and the answers come from the answer cache with no request sent.
tickets.json, a file the script reads
[
{
"id": "T-101",
"created": "2026-09-20",
"body": "The login page rejects my new password after a reset."
},
{
"id": "T-102",
"created": "2026-09-21",
"body": "The export button does nothing in Safari."
},
{
"id": "T-103",
"created": "2026-09-21",
"body": "How do I add a second admin?"
},
{
"id": "T-104",
"created": "2026-09-22",
"body": "The site has been down for our whole team since 9am."
},
{
"id": "T-105",
"created": "2026-09-22",
"body": "I was billed twice in September."
}
]triage.json, a file the script reads
{
"version": 1,
"questions": {
"kind": {
"choose": "What kind of message is this?",
"options": [
"billing",
"bug",
"question"
]
},
"urgency": {
"score": "How urgent is this?",
"levels": [
"Routine.",
"Soon.",
"Immediate."
]
}
}
}Each ticket keeps its id and date, and gains a kind and an urgency from 0 to 2. The double bill in September is billing.
jq -c '.[]' tickets.json |
thinkthen annotate triage.json \
--batch 1 \
--jsonl \
--field /body \
--jobs 16 |
jq 'del(.body)'Output
{
"id": "T-101",
"created": "2026-09-20",
"kind": "bug",
"urgency": 1.16
}
{
"id": "T-102",
"created": "2026-09-21",
"kind": "bug",
"urgency": 0.88
}
{
"id": "T-103",
"created": "2026-09-21",
"kind": "question",
"urgency": 0.01
}
{
"id": "T-104",
"created": "2026-09-22",
"kind": "bug",
"urgency": 1.99
}
{
"id": "T-105",
"created": "2026-09-22",
"kind": "billing",
"urgency": 0.77
}exit 0
On GitHub: github.com/botassembly/thinkthen