def _get_message_cohere_format(
    message: ChatMessage, tool_results: Optional[List[Dict[Any, Any]]]
) -> Dict[
    str,
    Union[
        str,
        List[Union[str, Dict[Any, Any]]],
        List[Dict[Any, Any]],
        None,
    ],
]:
    """
    Get the formatted message as required in cohere's api.

    Args:
        message: The BaseMessage.
        tool_results: The tool results if any

    Returns:
        The formatted message as required in cohere's api.

    """
    if message.role == MessageRole.CHATBOT or message.role == MessageRole.ASSISTANT:
        return {
            "role": get_role(message),
            "message": message.content,
            "tool_calls": message.additional_kwargs.get("tool_calls"),
        }
    elif message.role in (MessageRole.USER, MessageRole.SYSTEM):
        return {"role": get_role(message), "message": message.content}
    elif message.role == MessageRole.TOOL:
        return {"role": get_role(message), "tool_results": tool_results}
    else:
        raise ValueError(f"Got unknown type {message}")

    Get the formatted message as required in cohere's api.

    Args:
        message: The BaseMessage.
        tool_results: The tool results if any

    Returns:
        The formatted message as required in cohere's api.

    
llama-index-integrations/llms/llama-index-llms-cohere/llama_index/llms/cohere/utils.py