def from_litellm_message(message: Message) -> ChatMessage:
    """Convert litellm.utils.Message instance to generic message."""
    role = message.get("role")
    # NOTE: Azure OpenAI returns function calling messages without a content key
    content = message.get("content", None)
    tool_calls = message.get("tool_calls")
    additional_kwargs = {}
    if tool_calls:
        additional_kwargs["tool_calls"] = tool_calls

    return ChatMessage(role=role, content=content, additional_kwargs=additional_kwargs)
Convert litellm.utils.Message instance to generic message.
llama-index-integrations/llms/llama-index-llms-litellm/llama_index/llms/litellm/utils.py