Nonlinear optical response of molecules in a nonequilibrium solvation model