LAMMPS Dump to VASP POSCAR results into elements Type_1 Type_2

Dear OVITO Community,

Whenever I converts LAMMPS dump format to VASP POSCAR(either GU or Scripting Interface), it shows "Type_1 Type_2 Type_3 Type_4 Type_5 Type_6 " as sixth line instead of real element type names in POSCAR. I know there is no way for OVITO to know the elements names since the source LAMMPS dump files has element types as numeral IDs.

Can anybody please guide how I can gets the elements names if I want to use python scripting interface.
Thank you.

Please see this code example.

Thanks Alex, this was useful and I also found one solution in LAMMPS itself i.e. use cfg file format to dump the frames from LAMMPS, which will write the atom types and that can be read and converted into POSCAR through OVITO scripting interface.

Thank you.