def control_device(command):
for device in devices:
if device in command:
if "on" in command or "start" in command:
devices[device] = True
return f"{device.capitalize()} turned ON."
elif "off" in command or "stop" in command:
devices[device] = False
return f"{device.capitalize()} turned OFF."
return "No known device mentioned."
Main loop
print("AI Controller is active. Type commands (e.g., 'Turn on the light') or 'exit' to quit.")
while True:
cmd = input("You: ")
if cmd.lower() == "exit":
break
result = classifier(cmd)[0]
if result["label"] == "NEGATIVE":
print("AI: That doesn't sound like a valid control command.")
else:
response = control_device(cmd.lower())
print("AI:", response)