added /chat function. also refactored several functions around abstracting the local database.