Parsing assistant response for text and imagery responses

any idea on how to improve this generic assistant response getter to be able to handle text as well as images? (the tools I am using on the assistant is code interpreter).

def get_response(thread):
    messages = client.beta.threads.messages.list(thread_id=thread.id, order="desc", limit=1)
    last_message = messages.data[0].content[0].text.value
    return last_message

thanks.