o
    ̳i	                     @   s0   d dl mZ d dlmZmZ G dd deZdS )    )List)MessagePromptTemplateInterfacec                   @   s8   e Zd ZdZdddddZdee dee fdd	ZdS )
MistralChatTemplatea  
    Formats according to Mistral's `instruct model
    <https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1#instruction-format>`_.

    It is identical to :class:`~torchtune.data.Llama2ChatTemplate`, except it does not support system
    prompts.

    Note:
        This template is only recommended for Mistral's Instruct-v0.1 and Instruct-v0.2 models.
        Instruct-v0.3 adds additional tags for tool calls, which is not yet supported by this
        template.

    .. code-block:: text

        "[INST] I am going to Paris, what should I see? [/INST] Paris, the capital
        of France, is known for its stunning architecture..."

    N)z[INST] z	 [/INST] ) r   )systemuser	assistantipythonmessagesreturnc              
   C   sz   g }|D ]6}|j dkrtdd| j|j  d dg|j d| j|j  d dg }|t|j ||j|j|jd q|S )aS  
        Format user and system messages with appropriate tags.

        Args:
            messages (List[Message]): a single conversation, structured as a list
                of `Message` objects

        Returns:
            The formatted list of messages

        Raises:
            ValueError: If system prompts are provided
        r   z7System prompts are not supported in MistralChatTemplatetextr   )typecontent   )roler   maskedr
   eot)	r   
ValueErrortemplater   appendr   r   r
   r   )selfr   formatted_dialoguemessager    r   ]/home/ubuntu/.local/lib/python3.10/site-packages/torchtune/models/mistral/_prompt_template.py__call__&   s,   
	zMistralChatTemplate.__call__)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r      s    r   N)typingr   torchtune.datar   r   r   r   r   r   r   <module>   s   