Create tokensize calculator by integrating some library. Use this and save it in database. Also use it before sending request to chatgpt as need to be below 4000 tokens always.