[docs]    @classmethod
    def from_messages(
        cls,
        messages: Sequence[
            Union[
                BaseMessagePromptTemplate,
                BaseChatPromptTemplate,
                BaseMessage,
                Tuple[str, str],
                Tuple[Type, str],
                str,
            ]
        ],
    ) -> ChatPromptTemplate:
        """Create a chat prompt template from a variety of message formats.
        Examples:
            Instantiation from a list of message templates:
            .. code-block:: python
                template = ChatPromptTemplate.from_messages([
                    ("human", "Hello, how are you?"),
                    ("ai", "I'm doing well, thanks!"),
                    ("human", "That's good to hear."),
                ])
            Instantiation from mixed message formats:
            .. code-block:: python
                template = ChatPromptTemplate.from_messages([
                    SystemMessage(content="hello"),
                    ("human", "Hello, how are you?"),
                ])
        Args:
            messages: sequence of message representations.
                  A message can be represented using the following formats:
                  (1) BaseMessagePromptTemplate, (2) BaseMessage, (3) 2-tuple of
                  (message type, template); e.g., ("human", "{user_input}"),
                  (4) 2-tuple of (message class, template), (4) a string which is
                  shorthand for ("human", template); e.g., "{user_input}"
        Returns:
            a chat prompt template
        """
        _messages = [_convert_to_message(message) for message in messages]
        # Automatically infer input variables from messages
        input_vars = set()
        for _message in _messages:
            if isinstance(
                _message, (BaseChatPromptTemplate, BaseMessagePromptTemplate)