def messages_to_cohere_documents(
    messages: List[DocumentMessage],
) -> Optional[List[Dict[str, str]]]:
    """
    Splits out individual documents from `messages` in the format expected by Cohere.chat's `documents`.
    Returns None if `messages` is an empty list for compatibility with co.chat (where `documents` is None by default).
    """
    if messages == []:
        return None
    documents = []
    for msg in messages:
        documents.extend(document_message_to_cohere_document(msg))
    return documents

    Splits out individual documents from `messages` in the format expected by Cohere.chat's `documents`.
    Returns None if `messages` is an empty list for compatibility with co.chat (where `documents` is None by default).
    
llama-index-integrations/llms/llama-index-llms-cohere/llama_index/llms/cohere/utils.py