try this: https://www.craftylittlegnome.com/flies-house-suddenly/
A half cup of warm water plus two tablespoons of apple cider vinegar, a tablespoon of sugar, and about six drops of liquid dish soap just might be able to cure your gnat woes. They'll be lured in by the sugary mixture, but once they dip in for a drink, the sticky dish soap will trap them.
Gnats thrive on dampness. Remove the source of the water and they should go away. Specifically look at standing water in sinks and tubs, and in the soil in house plants. Let the plants dry out completely before rewatering for best results.