The way I would build a DM with GPT4 is with a few external tools: the character sheets, random dice, and perhaps other things should be available on the side, and fed to the chatbot when needed.
Same for a summary of the campaign, so that previous events are not forgotten.