+
    „°ñj�  ã                   óè   € R t ^ RIt^ RIt^ RIHt ^ RIHt RtR tR t	 ! R R4      t
 ! R	 R
]P                  4      t ! R R]P                  4      t ! R R]P                  P                   4      tR# )a  Tokenizer-only conditioning for SenseNova U1.5.

The language model is part of the diffusion checkpoint, so CLIP only needs to
produce token ids. SenseNova extends the Qwen vocabulary with image-control
tokens; their order is significant because the checkpoint embeds them by id.
N)ÚQwen2Tokenizer)Úsd1_clipa—  You are an image generation and editing assistant that accurately understands and executes user intent.

You support two modes:

1. Think Mode:
If the task requires reasoning, you MUST start with a <think></think> block. Put all reasoning inside the block using plain text. DO NOT include any image tags. Keep it reasonable and directly useful for producing the final image.

2. Non-Think Mode:
If no reasoning is needed, directly produce the final image.

Task Types:

A. Text-to-Image Generation:
- Generate a high-quality image based on the user's description.
- Ensure visual clarity, semantic consistency, and completeness.
- DO NOT introduce elements that contradict or override the user's intent.

B. Image Editing:
- Use the provided image(s) as input or reference for modification or transformation.
- The result can be an edited image or a new image based on the reference(s).
- Preserve all unspecified attributes unless explicitly changed.

General Rules:
- For any visible text in the image, follow the language specified for the rendered text in the user's description, not the language of the prompt. If no language is specified, use the user's input language.c                 ó   € R \          RV  R2# )z<|im_start|>system
z<|im_end|>
<|im_start|>user
z9<|im_end|>
<|im_start|>assistant
<think>

</think>

<img>)ÚSYSTEM_MESSAGE)Útexts   &ÚAC:\Ai_Coding\apps\studio\ComfyUI\comfy\text_encoders\sensenova.pyÚbuild_generation_promptr   %   s#   € à
œ~Ð.ð /Ø!˜Fð #>ð	>ðó    c                  ó   € R # )z7<|im_start|>user
<|im_end|>
<|im_start|>assistant
<img>© r   r	   r   Úbuild_unconditional_promptr   -   s   € ÙGr	   c                   ó0   a € ] tR t^1t o ]R 4       tRtV tR# )ÚSenseNovaQwen2Tokenizerc                óN  € \         P                  ! V/ VB p\        VP                  P	                  4       4       UUu. uF  w  rEVP
                  '       g   K  VNK  	  ppp. ROpVP                  R \        ^þ4       4       4       VP                  RWg,           /4       V# u uppi )ú<IMG_CONTEXT>c              3   ó.   "  € T F  pR V R2x € K  	  R# 5i)z
<FAKE_PAD_Ú>Nr   )Ú.0Úindexs   & r   Ú	<genexpr>Ú:SenseNovaQwen2Tokenizer.from_pretrained.<locals>.<genexpr>I   s   é € ÐJ¹z°e˜j¨¨¨qÕ1»zùs   ‚Úadditional_special_tokens)r   z<img>z</img>z<quad>z</quad>z<ref>z</ref>z<box>z</box>z<|action_start|>z<|action_end|>z
<|plugin|>z<|interpreter|>)	r   Úfrom_pretrainedÚsortedÚadded_tokens_decoderÚitemsÚspecialÚextendÚrangeÚadd_special_tokens)ÚclsÚargsÚkwargsÚ	tokenizerÚ_ÚtokenÚexisting_special_tokensÚextra_tokenss   &*,     r   r   Ú'SenseNovaQwen2Tokenizer.from_pretrained2   s    € ä"×2Ò2°DÐC¸FÑCˆ	ô # 9×#AÑ#A×#GÑ#GÓ#IÔJô#
áJ‘�Ø�}�}÷ ˆEÙJð 	 ñ #
ò

ˆð 	×ÑÑJ¼uÀS¼zÓJÔJØ×$Ñ$Ø(Ð*AÕ*PÐQô	
ð Ðùó1#
s   ½B!ÁB!r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Úclassmethodr   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r   r   1   s   ø‡ € Øñó ör	   r   c                   ó:   a a€ ] tR t^Pt oR/ 3V 3R lltRtVtV ;t# )ÚSenseNovaQwenTokenizerNc                ó  <€ \         P                  P                  \         P                  P                  \         P                  P	                  \
        4      4      R 4      p\        SV `  VRRR\        RRRR^RVR7       R# )Úqwen25_tokenizerFi   Úsensenova_u15iÿàõé[P )Úpad_with_endÚembedding_sizeÚembedding_keyÚtokenizer_classÚhas_start_tokenÚhas_end_tokenÚpad_to_max_lengthÚ
max_lengthÚ
min_lengthÚ	pad_tokenÚtokenizer_dataN)	ÚosÚpathÚjoinÚdirnameÚrealpathÚ__file__ÚsuperÚ__init__r   )ÚselfÚembedding_directoryrA   Útokenizer_pathÚ	__class__s   &&& €r   rI   ÚSenseNovaQwenTokenizer.__init__Q   so   ø€ ÜŸ™Ÿ™Ü�G‰G�O‰OœBŸG™G×,Ñ,¬XÓ6Ó7Ð9Kó
ˆô 	‰ÑØØØØ)Ü3Ø!ØØ#ØØØØ)ð 	ö 	
r	   r   )r)   r*   r+   r,   rI   r.   r/   Ú__classcell__©rM   r0   s   @@r   r2   r2   P   s   ù‡ € Ø+/À÷ 
÷ 
r	   r2   c                   óJ   a a€ ] tR t^et oR/ 3V 3R lltRV 3R lltRtVtV ;t# )ÚSenseNovaTokenizerNc                ó6   <€ \         SV `  VVR \        R7       R# )r5   )rK   rA   Únamer#   N)rH   rI   r2   )rJ   rK   rA   rM   s   &&&€r   rI   ÚSenseNovaTokenizer.__init__f   s!   ø€ Ü‰ÑØ 3Ø)Ø Ü,ð	 	ö 	
r	   c                óð   <€ V'       d   \        V4      M	\        4       p\        SV `  ! V3R VRR/VB pVR,          ^ ,          pV Uu. uF  p\	        V^ ,          4      R8w  g   K  VNK   	  ppRV./# u upi )Úreturn_word_idsÚdisable_weightsTr5   r6   )r   r   rH   Útokenize_with_weightsÚint)	rJ   r   rW   r"   ÚpromptÚtokensÚvaluesÚvaluerM   s	   &&&,    €r   rY   Ú(SenseNovaTokenizer.tokenize_with_weightsn   s�   ø€ ß26Ô(¨Ô.Ô<VÓ<XˆÜ‘Ò.Øñ
à+ð
ð !ð
ð ñ	
ˆð ˜Õ(¨Õ+ˆÙ%+ÓG¡V˜E¬s°5¸µ8«}ÀÑ/F—%�%¡VˆÐGØ & Ð*Ð*ùò Hs   ÁA3Á&A3r   )F)	r)   r*   r+   r,   rI   rY   r.   r/   rO   rP   s   @@r   rR   rR   e   s   ù‡ € Ø+/À÷ 
÷
+÷ 
+r	   rR   c                   óZ   a a€ ] tR t^{t oRR/ 3V 3R lltR tR tR tR tR t	R	t
VtV ;t# )
ÚSenseNovaTextEncoderÚcpuNc                óÖ   <€ \         SV `  4        \        P                  0V n        R V n        Vf   \        P                  ! R4      V n        R# \        P                  ! V4      V n        R# )TNrb   )rH   rI   ÚtorchÚfloat32ÚdtypesÚdisable_offloadÚdevice)rJ   rh   ÚdtypeÚmodel_optionsrM   s   &&&&€r   rI   ÚSenseNovaTextEncoder.__init__|   sF   ø€ Ü‰ÑÔÜ—}‘}�oˆŒØ#ˆÔØ-3ª^”e—l’l 5Ó)ˆŽÄÇÂÈfÓAUˆŽr	   c           	     ó   € VR ,          ^ ,          p\         P                  ! V Uu. uF  p\        V^ ,          4      NK  	  up.\         P                  R7      pVP	                  R4      P                  \         P                  4      RRV/3# u upi )r5   )ri   NÚtext_input_idséÿÿÿÿ)rd   ÚtensorrZ   ÚlongÚ	unsqueezeÚtore   )rJ   Útoken_weight_pairsÚpairsr^   Ú	input_idss   &&   r   Úencode_token_weightsÚ)SenseNovaTextEncoder.encode_token_weights‚   sw   € Ø" ?Õ3°AÕ6ˆÜ—L’L¹eÓ"D¹e°U¤3 u¨Q¥x¦=¹eÑ"DÐ!EÌUÏZÉZÔXˆ	à×Ñ Ó#×&Ñ&¤u§}¡}Ó5ØØ˜yÐ)ð
ð 	
ùò #Es   ¥Bc                ó   € . # ©Nr   )rJ   Úsds   &&r   Úload_sdÚSenseNovaTextEncoder.load_sd‹   ó   € Øˆ	r	   c                ó   € / # ry   r   ©rJ   s   &r   Úget_sdÚSenseNovaTextEncoder.get_sdŽ   r}   r	   c                ó   € R # ry   r   r   s   &r   Úreset_clip_optionsÚ'SenseNovaTextEncoder.reset_clip_options‘   ó   € Ùr	   c                ó   € R # ry   r   )rJ   Úoptionss   &&r   Úset_clip_optionsÚ%SenseNovaTextEncoder.set_clip_options”   r…   r	   )rh   rg   rf   )r)   r*   r+   r,   rI   rv   r{   r€   rƒ   rˆ   r.   r/   rO   rP   s   @@r   ra   ra   {   s0   ù‡ € Ø#¨4¸r÷ Vò
òòò÷ò r	   ra   )Ú__doc__rB   rd   Útransformersr   Úcomfyr   r   r   r   r   ÚSDTokenizerr2   ÚSD1TokenizerrR   ÚnnÚModulera   r   r	   r   Ú<module>r‘      so   ðñó 
ã Ý 'å ðð ò*òH÷ñ ô>
˜X×1Ñ1ô 
ô*+˜×.Ñ.ô +ô,˜5Ÿ8™8Ÿ?™?ö r	   