Resolve a household request against an inventory of devices.
Prepare the input
Keep the user request and the record it applies to in separate fields. Repeat the same question for each record in the workflow.
Model request
{
"model": "ngila-judge",
"state": {
"request": "Turn on the lamp in the reading corner.",
"source": "Devices: reading lamp, kitchen light, fan. The reading lamp is off."
},
"questions": {
"decision": {
"type": "choice",
"instructions": "Which device does the request name?",
"criteria": {
"reading lamp": "",
"kitchen light": "",
"fan": "",
"unclear": ""
}
}
}
}Run locally
Save ngila.py next to your script and set NGILA_API_KEY.
import json
from ngila import NgilaClient
state = {'request': 'Turn on the lamp in the reading corner.',
'source': 'Devices: reading lamp, kitchen light, fan. The reading lamp is '
'off.'}
questions = {'decision': {'type': 'choice',
'instructions': 'Which device does the request name?',
'criteria': {'reading lamp': '',
'kitchen light': '',
'fan': '',
'unclear': ''}}}
response = NgilaClient().system_one(state, questions)
a = response["answers"]
print(json.dumps(a, indent=2, ensure_ascii=False))Wire the application
Look up the returned label in the device inventory, then validate the requested state change. Present ambiguous targets for clarification. Test with a simulated switch before connecting an actuator.