Assign a description to a narrow catalog category, with a broader category available for uncertain cases.
Input and workflow
Use a known catalog hierarchy for fallback. When a narrow prediction has low confidence, show its parent category and keep the original ranking for review.
Request
{
"model": "ngila-judge",
"state": "A folding stand that raises a laptop above the desk.",
"questions": {
"category": {
"type": "choice",
"instructions": "Choose the product family.",
"criteria": {
"Laptop stands": "",
"Monitor arms": "",
"Other desk accessories": ""
}
}
}
}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 = 'A folding stand that raises a laptop above the desk.'
questions = {'category': {'type': 'choice',
'instructions': 'Choose the product family.',
'criteria': {'Laptop stands': '',
'Monitor arms': '',
'Other desk accessories': ''}}}
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.
label = a["category"]["choice"]
shown = label if a["category"]["confidence"] >= threshold else parents[label]