def parse_messages_for_model(
        self, messages: Sequence[ChatMessage]
    ) -> List[Dict[str, Union[str, List[Union[str, Dict[Any, Any]]]]]]:
        """
        Parses messages from LlamaIndex's format to the format expected by
        the MariTalk API.

        Parameters
        ----------
            messages (Sequence[ChatMessage]): A list of messages in LlamaIndex
            format to be parsed.

        Returns
        -------
            A list of messages formatted for the MariTalk API.

        """
        formatted_messages = []

        for message in messages:
            if message.role.value == MessageRole.USER:
                role = "user"
            elif message.role.value == MessageRole.ASSISTANT:
                role = "assistant"
            elif message.role.value == MessageRole.SYSTEM:
                role = "system"

            formatted_messages.append({"role": role, "content": message.content})
        return formatted_messages

        Parses messages from LlamaIndex's format to the format expected by
        the MariTalk API.

        Parameters
        ----------
            messages (Sequence[ChatMessage]): A list of messages in LlamaIndex
            format to be parsed.

        Returns
        -------
            A list of messages formatted for the MariTalk API.

        
llama-index-integrations/llms/llama-index-llms-maritalk/llama_index/llms/maritalk/base.py