A Choice must select among its options. Add a separate coverage question to catch inputs that fall outside the taxonomy.
Input and workflow
Check coverage before dispatching a request. On low coverage, present an unclassified case even when the top candidate beats the others.
Request
{
"model": "ngila-judge",
"state": "Can you recommend a nearby restaurant?",
"questions": {
"queue": {
"type": "choice",
"instructions": "Pick the closest support queue.",
"criteria": {
"Billing": "",
"Technical support": ""
}
},
"covered": {
"type": "noul",
"instructions": "Does the message concern a bill or a technical problem?"
}
}
}Run locally
Save ngila.py alongside your script and set NGILA_API_KEY. Save any linked input images in the same directory.
import json
from ngila import NgilaClient
state = 'Can you recommend a nearby restaurant?'
questions = {'queue': {'type': 'choice',
'instructions': 'Pick the closest support queue.',
'criteria': {'Billing': '', 'Technical support': ''}},
'covered': {'type': 'noul',
'instructions': 'Does the message concern a bill or a technical '
'problem?'}}
response = NgilaClient().system_one(state, questions)
a = response["answers"]
print(json.dumps(a, indent=2, ensure_ascii=False))Use the answers
The following application fragment uses a = response["answers"]. Supply any thresholds, lookup tables, or previous results from your workflow before applying it.
covered = a["covered"]["noul"]
queue = a["queue"]["choice"] if covered >= threshold else None