Many years ago, pre-kitties, I used to have houseplants and indoor herbs... and all it took was one gnat slipping into the house (well, actually two, I guess
) and taking up residence in my basil to create an infestation. I tried everything, including the vinegar trick, soapy water on the soil surface, letting the pots sit submerged in soapy water for a day, a food-safe pesticide made from chrysanthemums... nothing worked. I finally had to give up and put all my plants out to live on the balcony.
Even then, a dwindling population of the dratted gnats found ways to linger until my furnace broke down for a few days while it was below freezing. By the time I got it fixed, they'd finally
been frozen out!
To keep them from coming back, make sure you put all incoming produce into the refrigerator immediately, in case there are gnat eggs on your nanners.