
    :i)                        % S SK r S SKJr  S SKJrJrJr  S SKJr  S SK	J
r
Jr  S SKJr  S SKJrJrJrJrJr  S SKJr  \ R,                  " S	\S
S9  S\S\4S jr " S S\\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r \
\\-  \-  \ -  \" SS94   r!\
\\-  \-  \ -  \" SS94   r"\" S\!S 9r#\" S!\S 9r$\" S"\S 9r%\" S#\ S 9r&\" S$\S 9r'\$\%-  \&-  \'-  r(\\)S%'   g)&    N)Enum)AnyLiteralTypeVar)Field)	Annotated	TypeAlias)MistralBase)ContentChunk	TextChunk
ThinkChunkUserContentChunk_convert_openai_content_chunks)ToolCalloncezN.*has moved to 'mistral_common.protocol.instruct.chunk'\. It will be removed.*)actioncategorymessagenamereturnc                 x   U  S[          S3nU S:X  a#  SSKJn  [        R                  " U[
        5        U$ U S:X  a#  SSKJn  [        R                  " U[
        5        U$ U S:X  a#  SS	KJn  [        R                  " U[
        5        U$ U S
:X  a#  SSKJn  [        R                  " U[
        5        U$ U S:X  a#  SSKJ	n  [        R                  " U[
        5        U$ U S:X  a#  SSKJ
n  [        R                  " U[
        5        U$ U S:X  a#  SSKJn  [        R                  " U[
        5        U$ U S:X  a#  SSKJn	  [        R                  " U[
        5        U	$ U S:X  a#  SSKJn
  [        R                  " U[
        5        U
$ U S:X  a#  SSKJn  [        R                  " U[
        5        U$ [        S[          SU  35      e)NzQ has moved to 'mistral_common.protocol.instruct.chunk'. It will be removed from 'z' in 1.10.0.AudioURLr   )r   AudioURLChunk)r   AudioURLType)r   
AudioChunk)r   BaseContentChunk)r   
ChunkTypes)r   ImageURL)r   ImageURLChunk)r   
ImageChunk)r    RawAudio)r!   zmodule z has no attribute )__name__&mistral_common.protocol.instruct.chunkr   warningswarnFutureWarningr   r   r   r   r   r   r   r    r!   AttributeError)r   msgr   r   r   r   r   r   r   r   r    r!   s               c/home/james-whalen/.local/lib/python3.13/site-packages/mistral_common/protocol/instruct/messages.py__getattr__r*      sj   &abjakkwx  zCc=)		 Hc=)		Gc=)		Ec=)	#	#Kc=)		Ec=)		Cc=)		 Hc=)		Ec=)		Cc=)
78*,>tfE
FF    c                   (    \ rS rSrSrSrSrSrSrSr	g)	RolesT   zEnum for the roles of the messages.

Attributes:
   system: The system role.
   user: The user role.
   assistant: The assistant role.
   tool: The tool role.

Examples:
    >>> role = Roles.user
systemuser	assistanttool N)
r"   
__module____qualname____firstlineno____doc__r/   r0   r1   r2   __static_attributes__r3   r+   r)   r-   r-   T   s    
 FDIDr+   r-   c                      \ rS rSr% Sr\\R                  \R                  \R                  \R                  4   \S'   S\\\\\\\\\\4   -  4      -  4   4S jr\S\\\\\\\\\\4   -  4      -  4   SS 4S j5       rSrg	)
BaseMessageg   zLBase class for all messages.

Attributes:
   role: The role of the message.
roler   c                 D    [        S[        U 5      R                   35      e)zQConverts the message to the OpenAI format.

Should be implemented by subclasses.
z%to_openai method not implemented for )NotImplementedErrortyper"   selfs    r)   	to_openaiBaseMessage.to_openaip   s"    
 "$I$t*J]J]I^"_``r+   openai_messagec                 4    [        SU R                   S35      e)zYConverts the OpenAI message to the Mistral format.

Should be implemented by subclasses.
z'from_openai method not implemented for .)r>   r"   clsrD   s     r)   from_openaiBaseMessage.from_openaiw   s     "$KCLL>YZ"[\\r+   r3   N)r"   r4   r5   r6   r7   r   r-   r/   r0   r1   r2   __annotations__dictstrlistr   rB   classmethodrI   r8   r3   r+   r)   r:   r:   g   s     %,,

EOOUZZG
HHa4S4S#S#X:N5N0O+P%P PQ a ]c3d3dSVX[S[nH\C\>]9^3^.^)_ ]dq ] ]r+   r:   c                       \ rS rSr% Sr\R                  r\\R                     \	S'   \
\\   -  \	S'   S\\
\
\\\
\
\\
\4   -  4      -  4   4S jr\S\\
\
\\\
\
\\
\4   -  4      -  4   SS 4S j5       rS	rg
)UserMessage   zUser message.

Attributes:
    content: The content of the message.

Examples:
    >>> message = UserMessage(content="Can you help me to write a poem?")
r<   contentr   c                     [        U R                  [        5      (       a  U R                  U R                  S.$ U R                  U R                   Vs/ s H  oR	                  5       PM     snS.$ s  snf )*Converts the message to the OpenAI format.r<   rS   )
isinstancerS   rM   r<   rB   )rA   chunks     r)   rB   UserMessage.to_openai   sP    dllC(( II$,,??		dll.[lU/@l.[\\.[s   A0rD   c           	          [        US   [        5      (       a  U R                  U5      $ U R                  US   US    Vs/ s H  n[        U5      PM     snS.5      $ s  snf )2Converts the OpenAI message to the Mistral format.rS   r<   rV   )rW   rM   model_validater   )rH   rD   rX   s      r)   rI   UserMessage.from_openai   sm     nY/55%%n55!!&v.O]^gOhiOhe:5AOhi
 	
 js    A
r3   N)r"   r4   r5   r6   r7   r-   r0   r<   r   rK   rM   rN   r   rL   r   rB   rO   rI   r8   r3   r+   r)   rQ   rQ      s     !&

D'%**
*4()))]4S4S#S#X:N5N0O+P%P PQ ] 	
c3d3dSVX[S[nH\C\>]9^3^.^)_ 	
dq 	
 	
r+   rQ   c                       \ rS rSr% Sr\R                  r\\R                     \	S'   \
\\\-     -  \	S'   S\\
\
\\\
\
\\
\4   -  4      -  4   4S jr\S\\
\
\\\
\
\\
\4   -  4      -  4   SS 4S j5       rS	rg
)SystemMessage   zSystem message.

Attributes:
    content: The content of the message.

Examples:
    >>> message = SystemMessage(content="You are a helpful assistant.")
r<   rS   r   c                 "    U R                  5       $ )rU   )
model_dumpr@   s    r)   rB   SystemMessage.to_openai   s      r+   rD   c                 $    U R                  U5      $ )r[   )r\   rG   s     r)   rI   SystemMessage.from_openai   s     !!.11r+   r3   N)r"   r4   r5   r6   r7   r-   r/   r<   r   rK   rM   rN   r   r   rL   r   rB   rO   rI   r8   r3   r+   r)   r_   r_      s     #(,,D'%,,
.4	J.///!4S4S#S#X:N5N0O+P%P PQ ! 2c3d3dSVX[S[nH\C\>]9^3^.^)_ 2ds 2 2r+   r_   c                   .   \ rS rSr% Sr\R                  r\\R                     \	S'   Sr
\\\\-     -  S-  \	S'   Sr\\   S-  \	S'   Sr\\	S'   S	\\\\\\\\\\4   -  4      -  4   4S
 jr\S\\\\\\\\\\4   -  4      -  4   S	S 4S j5       rSrg)AssistantMessage   a  Assistant message.

Attributes:
    role: The role of the message.
    content: The content of the message.
    tool_calls: The tool calls of the message.
    prefix: Whether the message is a prefix.

Examples:
    >>> message = AssistantMessage(content="Hello, how can I help you?")
r<   NrS   
tool_callsFprefixr   c                 ~   SU R                   0nU R                  c  O\[        U R                  [        5      (       a  U R                  US'   O-U R                   Vs/ s H  o"R	                  5       PM     snUS'   U R
                  b-  U R
                   Vs/ s H  o3R	                  5       PM     snUS'   U$ s  snf s  snf )rU   r<   rS   ri   )r<   rS   rW   rM   rB   ri   )rA   out_dictrX   	tool_calls       r)   rB   AssistantMessage.to_openai   s     DIIL
 <<c**"&,,HYBF,,"O,??#4,"OHY??&MQ__%]_	&9&9&;_%]H\"	 #P%]s   B5B:rD   c                 &   UR                  SS5      nUc  SnOf[        U[        5      (       a:  / nU=(       d    /  H(  nUR                  [        R
                  " U5      5        M*     O[        S[        U5       35      eUR                  SS5      nSnUb  [        U[        5      (       a  UnOH[        U[        5      (       a  U Vs/ s H  n[        U5      PM     nnO[        S[        U5       35      eU R                  US   UUS.5      $ s  snf )r[   ri   Nztool_calls must be a list, got rS   zUnknown content type: r<   )r<   rS   ri   )getrW   rN   appendr   rI   
ValueErrorr?   rM   r   r\   )rH   rD   openai_tool_callstools_callsopenai_tool_callopenai_contentrS   rX   s           r)   rI   AssistantMessage.from_openai   s    +..|TB$15K)400K$5$;$; ""8#7#78H#IJ %< >tDU?V>WXYY'++It<37!Z%D%D$G--JXY.5e<.GYG5d>6J5KLMM!!&v.")
 	
	 Zs   Dr3   )r"   r4   r5   r6   r7   r-   r1   r<   r   rK   rS   rM   rN   r   r   ri   r   rj   boolrL   r   rB   rO   rI   r8   r3   r+   r)   rg   rg      s    
 &+__D'%//
"49=GS4	J.//$6=(,JX%,FD4S4S#S#X:N5N0O+P%P PQ   
c3d3dSVX[S[nH\C\>]9^3^.^)_ 
dv 
 
r+   rg   c                   .    \ rS rSr% SrSr\S-  \S'   Srg)FinetuningAssistantMessage   zAssistant message for finetuning.

Attributes:
    weight: The weight of the message to train on.

Examples:
    >>> message = FinetuningAssistantMessage(content="Hello, how can I help you?", weight=0.5)
Nweightr3   )	r"   r4   r5   r6   r7   r|   floatrK   r8   r3   r+   r)   rz   rz      s      FEDLr+   rz   c                      \ rS rSr% Sr\\S'   \R                  r	\
\R                     \S'   Sr\S-  \S'   Sr\S-  \S'   S\\\\\\\\\\4   -  4      -  4   4S	 jr\S
\\\\\\\\\\4   -  4      -  4   SS 4S j5       rSrg)ToolMessagei  a  Tool message.

Attributes:
    content: The content of the message.
    tool_call_id: The tool call id of the message.
    name: The name of the tool. (Deprecated in V3 tokenization)

Examples:
   >>> message = ToolMessage(content="Hello, how can I help you?", tool_call_id="123")
rS   r<   Ntool_call_idr   r   c                 J    U R                   c   S5       eU R                  S1S9$ )rU   0tool_call_id must be provided for tool messages.r   )exclude)r   rb   r@   s    r)   rB   ToolMessage.to_openai  s-      ,`.``,x00r+   messagesc                 P    U R                  U5      nUR                  c   S5       eU$ )r[   r   )r\   r   )rH   r   tool_messages      r)   rI   ToolMessage.from_openai  s2     ))(3((4h6hh4r+   r3   )r"   r4   r5   r6   r7   rM   rK   r-   r2   r<   r   r   r   rL   rN   r   rB   rO   rI   r8   r3   r+   r)   r   r     s    	 L %

D'%**
*#L#*# D#*14S4S#S#X:N5N0O+P%P PQ 1
 4S4S#SRUXBV=V8W3X-X(X#Y ^k  r+   r   r<   )discriminatorChatMessageType)boundUserMessageTypeAssistantMessageTypeToolMessageTypeSystemMessageTypeUATS)*r$   enumr   typingr   r   r   pydanticr   typing_extensionsr   r	   mistral_common.baser
   r#   r   r   r   r   r   +mistral_common.protocol.instruct.tool_callsr   filterwarningsr&   rM   r*   r-   r:   rQ   r_   rg   rz   r   ChatMessageFinetuningMessager   r   r   r   r   r   rK   r3   r+   r)   <module>r      sj     ( (  2 +  A   ]6Gc 6Gc 6GrC &]+ ]2
+ 
@2K 2.=
{ =
@
 !1 
 + @ 36FFTV[jpVqqrK"<<{J	! 
 +;? +;?5=MN +;?/}E !$88?JM^^i ^r+   