A generalized RPA theory of the nuclear response function