("human", "{input}"),
                    ]
                )
                template2 = template.partial(user="Lucy", name="R2D2")
                template2.format_messages(input="hello")
        """
        prompt_dict = self.__dict__.copy()
        prompt_dict["input_variables"] = list(
            set(self.input_variables).difference(kwargs)
        )
        prompt_dict["partial_variables"] = {**self.partial_variables, **kwargs}
        return type(self)(**prompt_dict)
[docs]    def append(self, message: MessageLikeRepresentation) -> None:
        """Append message to the end of the chat template.
        Args:
            message: representation of a message to append.
        """
        self.messages.append(_convert_to_message(message))
[docs]    def extend(self, messages: Sequence[MessageLikeRepresentation]) -> None:
        """Extend the chat template with a sequence of messages."""
        self.messages.extend([_convert_to_message(message) for message in messages])
    @overload
    def __getitem__(self, index: int) -> MessageLike:
        ...
    @overload
    def __getitem__(self, index: slice) -> ChatPromptTemplate:
        ...
    def __getitem__(
        self, index: Union[int, slice]
    ) -> Union[MessageLike, ChatPromptTemplate]:
        """Use to index into the chat template."""
        if isinstance(index, slice):
            start, stop, step = index.indices(len(self.messages))
            messages = self.messages[start:stop:step]
            return ChatPromptTemplate.from_messages(messages)
        else:
            return self.messages[index]
    def __len__(self) -> int:
        """Get the length of the chat template."""
        return len(self.messages)
    @property