On-the-fly learning of constitutive relation from mesoscopic dynamicsfor macroscopic modeling of non-Newtonian flows