Just put out a glass of wine and they will fly into it....that's what happens when I'm drinking, anyway.
Seriously though, put out a small glass of apple cider vinegar and they fly into it.
If you have indoor plants, mix a small amount of dish detergent with water and water the plants. The gnats live in the moist soil and lay eggs. The soap kills them. Do NOT use dishwasher detergent. Use something like Dawn.