On-chip Generation of Quantum States of Photons