To rid your house of gnats, put away any food that you have out, including fruits and vegetables. Another way to get rid of gnats is to poke holes in the lid of a container and fill the container with vinegar. The gnats will be attracted to the vinegar and climb into the container.
The best way to get rid of gnats that are in your home, is to remove any houseplants that might be harboring the insects, and put any fruits in the refrigerator. Pour some vinegar down the sink drains, and make sure you don't have any old garbage laying around.