def to_inference_message(
    messages: Sequence[ChatMessage],
) -> List[ChatRequestMessage]:
    """
    Converts a sequence of `ChatMessage` to a list of `ChatRequestMessage`
    which can be used for Azure AI model inference.

    Args:
        messages (Sequence[ChatMessage]): The messages to convert.

    Returns:
        List[ChatRequestMessage]: The converted messages.

    """
    new_messages = []
    for m in messages:
        message_dict = {
            "role": m.role.value,
            "content": m.content,
        }

        message_dict.update(
            {k: v for k, v in m.additional_kwargs.items() if v is not None}
        )
        new_messages.append(ChatRequestMessage(message_dict))
    return new_messages

    Converts a sequence of `ChatMessage` to a list of `ChatRequestMessage`
    which can be used for Azure AI model inference.

    Args:
        messages (Sequence[ChatMessage]): The messages to convert.

    Returns:
        List[ChatRequestMessage]: The converted messages.

    
llama-index-integrations/llms/llama-index-llms-azure-inference/llama_index/llms/azure_inference/base.py