Refactor chat_process.py