A General Framework for the Semantics of Type Theory