§
    ÙŽ’j@R  ã                   óÜ   — d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 d	d
lmZ d	dlmZmZmZmZmZmZmZmZmZ  G d„ de
e¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )z:The DashScope formatter module (OpenAI-compatible format).é    N)ÚAny)Úfnmatch)ÚABC)ÚFieldé   )ÚFormatterBaseé   )Úlogger)	ÚMsgÚ	TextBlockÚThinkingBlockÚToolResultBlockÚ	URLSourceÚ	DataBlockÚToolCallBlockÚBase64SourceÚ	HintBlockc                   óR  — e Zd ZU dZ ed„ d¬¦  «        Zee         ed<   e	dee         fd„¦   «         Z
e	defd„¦   «         Zd	edeeef         d
z  fd„Zedeez  deeef         fd„¦   «         Zedeez  deeef         fd„¦   «         Zedeez  deeef         fd„¦   «         Zd
S )Ú_DashScopeFormatterBasezqBase class for DashScope formatters (OpenAI-compatible format),
    providing shared data block formatting logic.c                  ó
   — g d¢S )N)ú
text/plainzimage/*zaudio/*zvideo/*© r   ó    úWC:\Projects\DSCons\.venv\Lib\site-packages\agentscope\formatter\_dashscope_formatter.pyú<lambda>z _DashScopeFormatterBase.<lambda>   s   € ð !
ð !
ð !
€ r   a  The supported input types, aligned with the model card's ``input_types`` field. Media types (non ``text/plain`` / ``application/x-thinking`` entries) are used to filter ``DataBlock``\s; ``application/x-thinking`` enables passing ``reasoning_content`` back to the API.)Údefault_factoryÚdescriptionÚinput_typesÚreturnc                 ó$   — d„ | j         D ¦   «         S )zwDerive supported media types from :attr:`input_types`, excluding
        ``text/plain`` and ``application/x-thinking``.c                 ó   — g | ]}|d v¯|‘Œ	S ))r   úapplication/x-thinkingr   )Ú.0Úts     r   ú
<listcomp>zG_DashScopeFormatterBase.supported_input_media_types.<locals>.<listcomp>2   s.   € ð 
ð 
ð 
àØÐ@Ð@Ð@ð à@Ð@Ð@r   ©r   ©Úselfs    r   Úsupported_input_media_typesz3_DashScopeFormatterBase.supported_input_media_types.   s&   € ð
ð 
àÔ%ð
ñ 
ô 
ð 	
r   c                 ó   — d| j         v S )z¬Return ``True`` if ``application/x-thinking`` is listed in
        :attr:`input_types`, meaning the model accepts ``reasoning_content``
        in the conversation history.r"   r&   r'   s    r   Úsupports_thinking_inputz/_DashScopeFormatterBase.supports_thinking_input8   s   € ð
 (¨4Ô+;Ð;Ð;r   ÚblockNc                 óð  ‡— t          ˆfd„| j        D ¦   «         ¦  «        s:t          j        d‰j        j        d                     | j        ¦  «        ¦  «         dS ‰j        j                             d¦  «        d         }|dk    r|                      ‰j        ¦  «        S |dk    r|  	                    ‰j        ¦  «        S |d	k    r|  
                    ‰j        ¦  «        S t          j        d
|¦  «         dS )aM  Format a DataBlock into the OpenAI-compatible format for
        DashScope API.

        Supports:
        - Images: ``{"type": "image_url", "image_url": {"url": ...}}``
        - Videos: ``{"type": "video_url", "video_url": {"url": ...}}``
        - Audio: ``{"type": "input_audio", "input_audio": {...}}``

        Args:
            block (`DataBlock`):
                The DataBlock to format.

        Returns:
            `dict[str, Any] | None`:
                A dictionary representing the formatted DataBlock, or ``None``
                if the media type is unsupported.
        c              3   óL   •K  — | ]}t          ‰j        j        |¦  «        V — Œd S )N)r   ÚsourceÚ
media_type)r#   Úpatternr,   s     €r   ú	<genexpr>zG_DashScopeFormatterBase._format_dashscope_data_block.<locals>.<genexpr>T   sF   øè è € ð 
ð 
àõ �E”LÔ+¨WÑ5Ô5ð
ð 
ð 
ð 
ð 
ð 
r   z]Unsupported media type %s for DashScope API. Supported types: %s. This block will be skipped.z, Nú/r   ÚimageÚvideoÚaudiozMUnsupported main media type %s for DashScope API. This block will be skipped.)Úanyr)   r
   Úwarningr/   r0   ÚjoinÚsplitÚ_format_image_sourceÚ_format_video_sourceÚ_format_audio_source)r(   r,   Ú	main_types    ` r   Ú_format_dashscope_data_blockz4_DashScopeFormatterBase._format_dashscope_data_block?   s  ø€ õ* ð 
ð 
ð 
ð 
àÔ;ð
ñ 
ô 
ñ 
ô 
ð 
	õ ŒNð9à”Ô'Ø—	’	˜$Ô:Ñ;Ô;ñ	ô ð ð �4à”LÔ+×1Ò1°#Ñ6Ô6°qÔ9ˆ	à˜ÒÐØ×,Ò,¨U¬\Ñ:Ô:Ð:à˜ÒÐØ×,Ò,¨U¬\Ñ:Ô:Ð:à˜ÒÐØ×,Ò,¨U¬\Ñ:Ô:Ð:åŒð*àñ	
ô 	
ð 	
ð
 ˆtr   r/   c                 ó(  — t          | t          ¦  «        rd| j        › d| j        › �}nät          | t          ¦  «        r°t          | j        ¦  «        }|                     d¦  «        r„|                     d¦  «        }t          |d¦  «        5 }t          j        |                     ¦   «         ¦  «                             d¦  «        }ddd¦  «         n# 1 swxY w Y   d| j        › d|› �}n"|}nt          dt          | ¦  «        › �¦  «        ‚dd	|id
œS )zÓConvert an image source to OpenAI-compatible ``image_url`` format.

        Local ``file://`` URLs are read from disk and converted to base64
        data URIs. Remote URLs are passed through unchanged.
        údata:ú;base64,úfile://Úrbúutf-8NzUnsupported image source type: Ú	image_urlÚurl)ÚtyperF   ©Ú
isinstancer   r0   Údatar   ÚstrrG   Ú
startswithÚremoveprefixÚopenÚbase64Ú	b64encodeÚreadÚdecodeÚ
ValueErrorrH   ©r/   rG   Úurl_strÚ
local_pathÚfÚencodeds         r   r;   z,_DashScopeFormatterBase._format_image_sourcer   sm  € õ �f�lÑ+Ô+ð 	OØB˜&Ô+ÐBÐB°V´[ÐBÐBˆCˆCÝ˜¥	Ñ*Ô*ð 
	OÝ˜&œ*‘o”oˆGØ×!Ò! )Ñ,Ô,ð Ø$×1Ò1°)Ñ<Ô<�
Ý˜* dÑ+Ô+ð I¨qÝ$Ô.¨q¯vªv©x¬xÑ8Ô8×?Ò?ÀÑHÔH�GðIð Ið Iñ Iô Ið Ið Ið Ið Ið Ið Iøøøð Ið Ið Ið IàB˜fÔ/ÐBÐB¸ÐBÐB��à��åÐM½tÀF¹|¼|ÐMÐMÑNÔNÐNð  Ø ˜ð
ð 
ð 	
ó   Â:CÃCÃCc                 ó(  — t          | t          ¦  «        rd| j        › d| j        › �}nät          | t          ¦  «        r°t          | j        ¦  «        }|                     d¦  «        r„|                     d¦  «        }t          |d¦  «        5 }t          j        |                     ¦   «         ¦  «                             d¦  «        }ddd¦  «         n# 1 swxY w Y   d| j        › d|› �}n"|}nt          dt          | ¦  «        › �¦  «        ‚dd	|id
œS )zòConvert a video source to DashScope's ``video_url`` format
        (OpenAI-compatible extension).

        Local ``file://`` URLs are read from disk and converted to base64
        data URIs. Remote URLs are passed through unchanged.
        rA   rB   rC   rD   rE   NzUnsupported video source type: Ú	video_urlrG   )rH   r\   rI   rU   s         r   r<   z,_DashScopeFormatterBase._format_video_sourceŽ   sm  € õ �f�lÑ+Ô+ð 	OØB˜&Ô+ÐBÐB°V´[ÐBÐBˆCˆCÝ˜¥	Ñ*Ô*ð 
	OÝ˜&œ*‘o”oˆGØ×!Ò! )Ñ,Ô,ð Ø$×1Ò1°)Ñ<Ô<�
Ý˜* dÑ+Ô+ð I¨qÝ$Ô.¨q¯vªv©x¬xÑ8Ô8×?Ò?ÀÑHÔH�GðIð Ið Iñ Iô Ið Ið Ið Ið Ið Ið Iøøøð Ið Ið Ið IàB˜fÔ/ÐBÐB¸ÐBÐB��à��åÐM½tÀF¹|¼|ÐMÐMÑNÔNÐNð  Ø ˜ð
ð 
ð 	
rZ   c                 óŒ  — t          | t          ¦  «        r-| j                             d¦  «        d         }d| j        |dœdœS t          | t
          ¦  «        rÏt          | j        ¦  «        }| j                             d¦  «        d         }|                     d¦  «        r~| 	                    d¦  «        }t          |d¦  «        5 }t          j        |                     ¦   «         ¦  «                             d¦  «        }d	d	d	¦  «         n# 1 swxY w Y   d||dœdœS d||dœdœS t          d
t!          | ¦  «        › �¦  «        ‚)a  Convert an audio source to DashScope ``input_audio`` format.

        DashScope's compatible API accepts URLs directly in the ``data``
        field (unlike standard OpenAI which requires base64). Local files
        are still read and base64-encoded.
        r3   éÿÿÿÿÚinput_audio)rK   Úformat)rH   r_   rC   rD   rE   NzUnsupported audio source type: )rJ   r   r0   r:   rK   r   rL   rG   rM   rN   rO   rP   rQ   rR   rS   rT   rH   )r/   ÚfmtrV   rW   rX   rK   s         r   r=   z,_DashScopeFormatterBase._format_audio_source«   s¹  € õ �f�lÑ+Ô+ð 	ØÔ#×)Ò)¨#Ñ.Ô.¨rÔ2ˆCà%à"œKØ!ð ð  ðð ð õ �f�iÑ(Ô(ð 	Ý˜&œ*‘o”oˆGØÔ#×)Ò)¨#Ñ.Ô.¨rÔ2ˆCØ×!Ò! )Ñ,Ô,ð Ø$×1Ò1°)Ñ<Ô<�
Ý˜* dÑ+Ô+ð F¨qÝ!Ô+¨A¯FªF©H¬HÑ5Ô5×<Ò<¸WÑEÔE�DðFð Fð Fñ Fô Fð Fð Fð Fð Fð Fð Føøøð Fð Fð Fð Fð *à $Ø"%ð$ð $ðð ð ð *à 'Ø"%ð$ð $ðð ð õ ÐI½4À¹<¼<ÐIÐIÑJÔJÐJs   Ã:DÄDÄD)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   ÚlistrL   Ú__annotations__Úpropertyr)   Úboolr+   r   Údictr   r?   Ústaticmethodr   r   r;   r<   r=   r   r   r   r   r      s¡  € € € € € € ð5ð 5ð #˜Uð
ð 
ð5ðñ ô €K��c”ð ð ñ ð  ð
¨T°#¬Yð 
ð 
ð 
ñ „Xð
ð ð<¨ð <ð <ð <ñ „Xð<ð1àð1ð 
ˆc�3ˆhŒ˜$Ñ	ð1ð 1ð 1ð 1ðf ð
Ø˜LÑ(ð
à	ˆc�3ˆhŒð
ð 
ð 
ñ „\ð
ð6 ð
Ø˜LÑ(ð
à	ˆc�3ˆhŒð
ð 
ð 
ñ „\ð
ð8 ð*KØ˜LÑ(ð*Kà	ˆc�3ˆhŒð*Kð *Kð *Kñ „\ð*Kð *Kð *Kr   r   c                   óJ   — e Zd ZdZdee         deeeef                  fd„Z	dS )ÚDashScopeChatFormattera�  The DashScope formatter class for chatbot scenario (OpenAI-compatible
    format), where only a user and an agent are involved. We use the ``role``
    field to identify different entities in the conversation.

    This formatter outputs messages in the OpenAI Chat Completions format,
    with DashScope-specific extensions for video (``video_url``) and
    thinking (``reasoning_content``).
    Úmsgsr   c              ƒ   óä  K  — |                       |¦  «         g }d}|t          |¦  «        k     �r@||         }g }g }g }|                     ¦   «         D �]�}t          |t          ¦  «        r|                     d|j        dœ¦  «         Œ6t          |t          ¦  «        r-|                      |¦  «        }	|	r|                     |	¦  «         Œxt          |t          ¦  «        �r'|s|s|rH|j
        |pddœ}
|r||
d<   |rd                     |¦  «        |
d<   |                     |
¦  «         g }g }g }t          |j        t          ¦  «        r#|                     d	d|j        dœgdœ¦  «         �Œg }|j        D ]v}t          |t          ¦  «        r|                     d|j        dœ¦  «         Œ5t          |t          ¦  «        r,|                      |¦  «        }|r|                     |¦  «         Œw|r|                     d	|dœ¦  «         �Œµt          |t          ¦  «        r-|                     |j        d
|j        |j        dœdœ¦  «         �Œ÷t          |t$          ¦  «        r#| j        r|                     |j        ¦  «         �Œ/t          |t*          ¦  «        �r(|s|s|rH|j
        |pddœ}|r||d<   |rd                     |¦  «        |d<   |                     |¦  «         g }g }g }|                      |j        ¦  «        \  }}|                     d|j        ||j        dœ¦  «         |r•g }|D ]v}t          |t          ¦  «        r|                     d|j        dœ¦  «         Œ5t          |t          ¦  «        r,|                      |¦  «        }|�|                     |¦  «         Œw|r|                     d	|dœ¦  «         �Œmt1          j        dt5          |¦  «        ¦  «         �Œ‘|j
        |pddœ}|r||d<   |rd                     |¦  «        |d<   |d         s*|                     d¦  «        s|                     d¦  «        r|                     |¦  «         |dz  }|t          |¦  «        k     �°@|S )a&  Format message objects into DashScope OpenAI-compatible format.

        Args:
            msgs (`list[Msg]`):
                The list of message objects to format.

        Returns:
            `list[dict[str, Any]]`:
                The formatted messages as a list of dictionaries.
        r   Útext©rH   rp   N©ÚroleÚcontentÚ
tool_callsú
Úreasoning_contentÚuserÚfunction)ÚnameÚ	arguments)ÚidrH   ry   Útool)rs   Útool_call_idrt   rz   z2Unsupported block type %s in the message, skipped.rt   r   )Úassert_list_of_msgsÚlenÚget_content_blocksrJ   r   Úappendrp   r   r?   r   rs   r9   ÚhintrL   r   r|   rz   Úinputr   r+   Úthinkingr   Úconvert_tool_result_to_stringÚoutputr
   r8   rH   Úget)r(   rn   Úformatted_msgsÚiÚmsgÚcontent_blocksru   Úthinking_partsr,   Úformatted_blockÚ
msg_openaiÚ
hint_partsÚsubÚformatted_subÚ	msg_flushÚtextual_outputÚmultimodal_dataÚpromo_contentÚitemÚfmt_itemÚmsg_dashscopes                        r   r`   zDashScopeChatFormatter.formatä   sò  è è € ð 	× Ò  Ñ&Ô&Ð&à%'ˆØˆØ•#�d‘)”)Šm‰mØ�q”'ˆCØ)+ˆNØˆJØ(*ˆNà×/Ò/Ñ1Ô1ð Añ A�Ý˜e¥YÑ/Ô/ð @Ø"×)Ò)°6À5Ä:Ð*NÐ*NÑOÔOÐOÐOå ¥yÑ1Ô1ð }Ø&*×&GÒ&GØñ'ô '�Oð 'ð ?Ø&×-Ò-¨oÑ>Ô>Ð>øå ¥yÑ1Ô1ñ vØ%ð ,¨ð ,°~ð ,à$'¤HØ'5Ð'=¸ð6ð 6˜
ð &ð BØ7A˜J |Ñ4Ø)ð Ø>B¿iºiØ .ñ?ô ?˜JÐ':Ñ;ð '×-Ò-¨jÑ9Ô9Ð9Ø)+˜Ø%'˜
Ø)+˜å! %¤*­cÑ2Ô2ð Ø&×-Ò-à(.à-3¸U¼ZÐ$HÐ$Hð,"ðð ñô ð ñ ð 24˜
Ø#(¤:ð Eð E˜CÝ)¨#­yÑ9Ô9ð EØ *× 1Ò 1Ø-3¸S¼XÐ$FÐ$Fñ!"ô !"ð !"ð !"õ ",¨CµÑ!;Ô!;ð Eà$(×$EÒ$EØ(+ñ%&ô %&ð !.ð
 $1ð !EØ$.×$5Ò$5°mÑ$DÔ$DÐ$DøØ%ð Ø*×1Ò1Ø)/¸JÐ GÐ Gñô ð ùõ   ¥}Ñ5Ô5ð HØ×%Ò%à"'¤(Ø$.à(-¬
Ø-2¬[ð)ð )ðð ñ	ô 	ð 	ñ 	õ   ¥}Ñ5Ô5ð <ØÔ3ð >Ø&×-Ò-¨e¬nÑ=Ô=Ð=ùå ¥Ñ7Ô7ñ 8Ø%ð ,¨ð ,°~ð ,à$'¤HØ'5Ð'=¸ð5ð 5˜	ð &ð AØ6@˜I lÑ3Ø)ð Ø=A¿YºYØ .ñ>ô >˜IÐ&9Ñ:ð '×-Ò-¨iÑ8Ô8Ð8Ø)+˜Ø%'˜
Ø)+˜ð
 ×:Ò:¸5¼<ÑHÔHñØ&Ø'ð #×)Ò)à$*Ø,1¬HØ'5Ø$)¤Jð	ð ñô ð ð 'ð Ø(*˜Ø$3ð 
Cð 
C˜DÝ)¨$µ	Ñ:Ô:ð 	CØ -× 4Ò 4Ø-3¸T¼YÐ$GÐ$Gñ!"ô !"ð !"ð !"õ ",¨Dµ)Ñ!<Ô!<ð CØ+/×+LÒ+LØ$(ñ,"ô ," ð $,Ð#7Ø$1×$8Ò$8¸Ñ$BÔ$BÐ$BøØ(ð Ø*×1Ò1à,2Ø/<ð!"ð !"ñô ð ùõ ”NØLÝ˜U™œñô ð ñ ð œØ)Ð1¨Tð-ð -ˆMð
 ð 9Ø.8�˜lÑ+àð OØ59·Y²Y¸~Ñ5NÔ5N�Ð1Ñ2ð ˜iÔ(ð5à ×$Ò$ \Ñ2Ô2ð5ð !×$Ò$Ð%8Ñ9Ô9ð5ð
 ×%Ò% mÑ4Ô4Ð4à�‰FˆAðw •#�d‘)”)Šm‰mðz Ðr   N)
rb   rc   rd   re   rf   r   rj   rL   r   r`   r   r   r   rm   rm   Ù   s]   € € € € € ðð ðoà�3Œiðoð 
ˆd�3˜�8ŒnÔ	ðoð oð oð oð oð or   rm   c            
       ó  — e Zd ZU dZ edd¬¦  «        Zeed<   dee	         dee
         fd„Zdee	         dee
eef                  fd	„Z	 ddee	         dedee
eef                  fd„Zede	de
eef         fd„¦   «         ZdS )ÚDashScopeMultiAgentFormatteraÅ  DashScope formatter for multi-agent conversations (OpenAI-compatible
    format), where more than a user and an agent are involved.

    .. note:: This formatter will combine previous messages (except tool
     calls/results) into a history section in the first system message with
     the conversation history prompt.

    .. note:: For tool calls/results, they will be presented as separate
     messages as required by the API. Therefore, the tool calls/results
     messages are expected to be placed at the end of the input messages.

    .. tip:: Telling the assistant's name in the system prompt is very
     important in multi-agent conversations. So that LLM can know who it
     is playing as.
    z The conversation history prompt.zg# Conversation History
The content between <history></history> tags contains your conversation history
)r   ÚdefaultÚconversation_history_promptrn   r   c              ƒ   óø  K  — g }d}t          |¦  «        dk    rG|d         j        dk    r6|                     |                      |d         ¦  «        ƒ d{V —†¦  «         d}d}|                      ||d…         ¦  «        2 3 d{V —†\  }}|xdk    r0 |                     |                      |¦  «        ƒ d{V —†¦  «         ŒAdk    r2|                     |                      ||¦  «        ƒ d{V —†¦  «         d}ŒxŒy6 |S )	a…  Format input messages into the structure required by the DashScope
        OpenAI-compatible API.

        To support multi-agent conversations, this formatter processes messages
        as follows:

        - Prepends an instruction before the first conversation history
         section.
        - Combines conversation turns into a history section, where each entry
         is formatted as ``{name}: {content}``.
        - Wraps the conversation history with ``<history>`` and ``</history>``
         tags.

        Returns:
            `list[dict[str, Any]]`:
                A list of dictionaries formatted for the DashScope API.
        r   ÚsystemNr   TÚtool_sequenceÚagent_messageF)r€   rs   r‚   Ú_format_system_messageÚ_group_messagesÚextendÚ_format_tool_sequenceÚ_format_agent_message)r(   rn   r‰   Ústart_indexÚis_first_agent_messageÚtypÚgroups          r   r`   z#DashScopeMultiAgentFormatter.format°  s„  è è € ð& ˆØˆÝˆt‰9Œ9�qŠ=ˆ=˜T !œWœ\¨XÒ5Ð5Ø×!Ò!Ø×1Ò1°$°q´'Ñ:Ô:Ð:Ð:Ð:Ð:Ð:Ð:ñô ð ð ˆKà!%ÐØ $× 4Ò 4°T¸+¸,¸,Ô5GÑ HÔ Hð 	3ð 	3ð 	3ð 	3ð 	3ð 	3ð 	3‘*�#�uØØ$�_’_�_�_Ø"×)Ò)Ø"×8Ò8¸Ñ?Ô?Ð?Ð?Ð?Ð?Ð?Ð?ñô ð ð ð %’_�_Ø"×)Ò)Ø"×8Ò8Ø!Ø2ñô ð ð ð ð ð ð ñô ð ð .3Ð*Ð*ð %ð !Ið Ðs   Â C9c              ƒ   ób   K  — t          | j        ¬¦  «                             |¦  «        ƒ d{V —†S )zrGiven a sequence of tool call/result messages, format them into
        the required format for the DashScope API.r&   N)rm   r   r`   )r(   rn   s     r   r¥   z2DashScopeMultiAgentFormatter._format_tool_sequenceÝ  sN   è è € õ ,ØÔ(ð
ñ 
ô 
ç
Š&�‰,Œ,ðð ð ð ð ð ð 	r   TÚis_firstc              ƒ   óÊ  K  — |r| j         }nd}g }g }g }g }|D ]”}|                     ¦   «         D ]}}	t          |	t          ¦  «        r%|                     |j        › d|	j        › �¦  «         Œ<t          |	t          ¦  «        r,|                      |	¦  «        }
|
�|                     |
¦  «         Œ~Œ•|r*|                     dd 	                    |¦  «        i¦  «         |r�|d          
                    d¦  «        r|dz   |d         d         z   |d         d<   n|                     dd|dz   i¦  «         |d          
                    d¦  «        r|d         dxx         d	z  cc<   n|                     dd
i¦  «         d 	                    d„ |D ¦   «         ¦  «        }g }|r|                     d|dœ¦  «         |                     |¦  «         |r|                     d|dœ¦  «         |S )z€Given a sequence of messages without tool calls/results, format
        them into a user message with conversation history tags.Ú z: Nrp   rv   r   z
<history>
r^   z
</history>z
</history>c              3   óB   K  — | ]}|                      d d¦  «        V — ŒdS )rp   r®   N)rˆ   )r#   Úbs     r   r2   zEDashScopeMultiAgentFormatter._format_agent_message.<locals>.<genexpr>  sA   è è € ð -
ð -
Ø"#ˆA�EŠE�&˜"ÑÔð-
ð -
ð -
ð -
ð -
ð -
r   rq   rx   rr   )r�   r�   rJ   r   r‚   rz   rp   r   r?   r9   rˆ   Úinsertr¤   )r(   rn   r¬   r�   r‰   Úconversation_blocksÚaccumulated_textÚmedia_blocksr‹   r,   rŽ   Úconversation_blocks_textÚcontent_lists                r   r¦   z2DashScopeMultiAgentFormatter._format_agent_messageç  sŸ  è è € ð ð 	-Ø*.Ô*JÐ'Ð'à*,Ð'à%'ˆØ$&ÐØÐØ#%ˆàð 
	=ð 
	=ˆCØ×/Ò/Ñ1Ô1ð 	=ð 	=�Ý˜e¥YÑ/Ô/ð =Ø$×+Ò+¨s¬xÐ,GÐ,G¸5¼:Ð,GÐ,GÑHÔHÐHÐHå ¥yÑ1Ô1ð =Ø&*×&GÒ&GØñ'ô '�Oð 'Ð2Ø$×+Ò+¨OÑ<Ô<Ð<øð	=ð ð 	Ø×&Ò&Ø˜ŸšÐ#3Ñ4Ô4Ð5ñô ð ð ð 	CØ" 1Ô%×)Ò)¨&Ñ1Ô1ð 
à/Ø#ñ$à)¨!Ô,¨VÔ4ñ5ð $ AÔ& vÑ.Ð.ð $×*Ò*ØØÐ8¸=ÑHÐIñô ð ð
 # 2Ô&×*Ò*¨6Ñ2Ô2ð CØ# BÔ'¨Ð/Ð/Ô/°>ÑAÐ/Ð/Ñ/Ð/à#×*Ò*¨F°LÐ+AÑBÔBÐBà#'§9¢9ð -
ð -
Ø':ð-
ñ -
ô -
ñ $
ô $
Ð ð .0ˆØ#ð 	Ø×ÒØÐ)AÐBÐBñô ð ð 	×Ò˜LÑ)Ô)Ð)àð 	MØ×!Ò!¨6¸lÐ"KÐ"KÑLÔLÐLàÐr   r‹   c              ƒ   ó4   K  — d|                       ¦   «         dœS )z(Format system message for DashScope API.rŸ   rr   )Úget_text_content)r‹   s    r   r¢   z3DashScopeMultiAgentFormatter._format_system_message+  s)   è è € ð Ø×+Ò+Ñ-Ô-ð
ð 
ð 	
r   N)T)rb   rc   rd   re   r   r�   rL   rg   rf   r   rj   r`   r   r¥   ri   r¦   rk   r¢   r   r   r   r›   r›   –  s@  € € € € € € ðð ð  (- uØ6ð*ð(ñ (ô (Ð ð ð ñ ð+  c¤ð +¨t°D¬zð +ð +ð +ð +ðZà�3Œiðð 
ˆd�3˜�8ŒnÔ	ðð ð ð ð ðBð Bà�3ŒiðBð ðBð 
ˆd�3˜�8ŒnÔ	ð	Bð Bð Bð BðH ð
Øð
à	ˆc�3ˆhŒð
ð 
ð 
ñ „\ð
ð 
ð 
r   r›   )re   rP   Útypingr   r   Úabcr   Úpydanticr   Ú_formatter_baser   Ú_loggingr
   Úmessager   r   r   r   r   r   r   r   r   r   rm   r›   r   r   r   ú<module>r¿      sž  ðà @Ð @à €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð à *Ð *Ð *Ð *Ð *Ð *Ø Ð Ð Ð Ð Ð ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð|Kð |Kð |Kð |Kð |K˜m¨Sñ |Kô |Kð |Kð~zð zð zð zð zÐ4ñ zô zð zðz]
ð ]
ð ]
ð ]
ð ]
Ð#:ñ ]
ô ]
ð ]
ð ]
ð ]
r   