Bti - Mosquito Bits (top dress and water in) by Summit in north america (maybe elsewhere?). Mosquito dunks for a rez, but better get some sort of mesh bag if you use that form.
This sort of thing is better to use pre-emptively. It may take 3 weeks to get an ongoing problem under control. Get some sticky traps to kill off adults -- the adults don't damage your plants but are annoying. Could technically spread something, but they don't eat or directly damage your plants like the larva does da,age dorectly to the roots.
You invariably bring in gnats with a substrate -- even if the store you bought it from doesn't store it outside, it was probably stored outside at some point and that means many of the bags come with gnats.
Start with Bti right away, and even if you do get a bale with gnats, you will only see 1-2 mature ones here or there and the plants won't show signs of root damage etc.. all good. Of all the things i've done to avoid pests and pathogens, this is one of the few things i still do years later. They need to be applied every 7-10 days (top dress). I've used dunks in 55-gallon rez before and it also was effective. 1/4 'dunk' and replacing it every couple weeks worked fine, but didn't do it enough to really map it out.
Gnats are never a concern. Luckily i never see anyhthing else. Pyrethrines are a good option for a kill on contact for non-gnat issues and also biodegrades quickly. Better to buy a concentrate and mix some up than buying the pre-mix bottles.