A US teenager was handcuffed by armed police after an artificial intelligence (AI) system mistakenly said he was carrying a gun - when really he was holding a packet of crisps.