The present invention relates to methods of modulating an immune response mediated by a PD-1 signaling pathway and of treating a cancer or an infectious disease. A subject is administered a compound(s) or a pharmaceutically acceptable salt or pharmaceutically acceptable composition thereof of formula (I)In the ring Q is S or O. R1 substituents are an optionally substituted side chain of the amino acid Ser or Thr and R3 substituents are a side chain of the amino acids Asn, Asp, Gln, or Glu. R2 is hydrogen or —;CO-Aaa and Aaa is Thr or Ser with a free, amidated or esterified C-terminus. R4 and R5 are independently hydrogen or absent. R6 is hydrogen, alkyl or acyl.