Oh, I see.
One guess for GPT4 is that it's an amalgamation of models. So you would have various models trained more specifically like the ones you mentioned, and you ask them all to start answering the query, then you choose which one produces better results, and then you present that to the user.
Alternatively you can have a decider model that knows what kind of queries goes to what specialised one, then have that as a "hidden layer", whether it be in the application level or "neuron layers".