messages function

Extract messages from a response object or a chatlog object