Expert gardener I am not by any means, but neem oil is a safe product you may wish to try.
I've had perfect luck with diluted neem oil for gnats and fruit flies flying around & living in the soil of indoor food plants. Outdoors, it works well for larvae, leaf eating insects, fungus and mildew.
Neem oil is from the nuts of the neem tree. The product is a very safe broad spectrum fungicide, mitecide & insecticide. It repels most insects, too. (But bees & butterflies seem attracted to it. After spraying outdoors, they show up out of nowhere & hang around all day.)
Pure neem oil is composed of natural azadirachtin, fatty acids and essential oils; each of which is classified Generally Recognized As Safe by the U.S. FDA. No chemicals are added if you buy the "clean" stuff. (Check the SDS or MSDS for ingredients.)
Southern AG Triple Action is an example of one with no chemicals added. Neem oil can be used up to the day of harvest.
I'll mix using the fungicide ratio according to directions for the specific brand. The leaves, top and bottom, get sprayed and the soil surface (damp or dry) gets a light spritz to destroy the eggs & larvae. Any gnats or fruit flies that are actively flying suddenly stay away from the plants. Indoors, one treatment lasts for months, despite watering the soil. I've even lightly sprayed around trays of tomaotes or peppers that are inside ripening. The fruit flies vanish.
Outside when I see any signs of mildew, fungus, eggs or insect holes, the leaves get sprayed. If the problems aren't solved by the next watering, re-spraying is done.
Whether this upsets Mother Nature's microbiome is beyond me, but the plants haven't gone on strike.
Here is a link with a brief fact sheet from the National Pesticide Information Center about neem oil:
http://npic.orst.edu/factsheets/neemgen.html
I hope this is helpful and please enjoy today!
Paul