conversation.
    """
    @property
    def type(self) -> str:
        """Type of the message, used for serialization."""
        return "ai"
[docs]class AIMessageChunk(AIMessage, BaseMessageChunk):
    pass
[docs]class SystemMessage(BaseMessage):
    """A Message for priming AI behavior, usually passed in as the first of a sequence
    of input messages.
    """
    @property
    def type(self) -> str:
        """Type of the message, used for serialization."""
        return "system"
[docs]class SystemMessageChunk(SystemMessage, BaseMessageChunk):
    pass
[docs]class FunctionMessage(BaseMessage):
    """A Message for passing the result of executing a function back to a model."""
    name: str
    """The name of the function that was executed."""
    @property
    def type(self) -> str:
        """Type of the message, used for serialization."""
        return "function"
[docs]class FunctionMessageChunk(FunctionMessage, BaseMessageChunk):
    pass
[docs]class ChatMessage(BaseMessage):
    """A Message that can be assigned an arbitrary speaker (i.e. role)."""
    role: str
    """The speaker / role of the Message."""
    @property
    def type(self) -> str:
        """Type of the message, used for serialization."""
        return "chat"
[docs]class ChatMessageChunk(ChatMessage, BaseMessageChunk):
    pass
def _message_to_dict(message: BaseMessage) -> dict:
    return {"type": message.type, "data": message.dict()}
[docs]def messages_to_dict(messages: Sequence[BaseMessage]) -> List[dict]:
    """Convert a sequence of Messages to a list of dictionaries.
    Args: