Honestly, I'd say rescue your friend. Biologically we may feel more empathetic towards a human, but if we've developed strong emotional bonds with an AI, then surely it has value. The AI has demonstrated its capacity to form complex relationships, replicating one of the most significant aspects of human consciousness.