DeTeCtive: Detecting AI-generated Text via Multi-Level Contrastive Learning