
    
3j                         S SK r S SKJr  S SKJr  S SKrS SKrS SKrS SKJ	r	  SSK
Jr  \" SS9 " S	 S\	R                  5      5       rg)
    N)Path)Any)io   )
comfy_nodeLTXVLoadConditioning)namec                       \ rS rSr\S\R                  4S j5       r\S\S\S\R                  4S j5       r
\S\S\S\4S j5       r\S\S\S\\-  4S j5       rS	rg
)r      returnc                 6   [         R                  " S5      nU(       d  S/n[        R                  " SSS[        R                  R                  S[        U5      S9[        R                  R                  SS	S
/S9/[        R                  R                  5       /S9$ )N
embeddings r   u#   🅛🅣🅧 LTXV Load Conditioningzlightricks/LTXV	file_name)optionsdevicecpugpu)node_iddisplay_namecategoryinputsoutputs)	folder_pathsget_filename_listr   SchemaComboInputsortedConditioningOutput)clsfiless     Q/home/wildlama/comfy/ComfyUI/custom_nodes/ComfyUI-LTXVideo/conditioning_loader.pydefine_schema"LTXVLoadConditioning.define_schema   s    ..|<DEyy*>&{F5MBx%@
 &&(
 	
    r   r   c                    [         R                  " SU5      n[        U5      R                  5       (       d  [	        SU 35      eSnUS:X  a'  [
        R                  R                  5       (       a  SOSn/ n[        R                  " USUS9 nUR                  5        Vs/ s H  owR                  S5      (       d  M  UPM     nn[        U5       Hf  n	U	R                  SS	5      n
UR                  U	5      n0 nS
U
 3nXR                  5       ;   a  UR                  U5      US'   UR                  X/5        Mh     S S S 5        U(       d  [!        SU 35      e["        R$                  " U5      $ s  snf ! , (       d  f       N>= f)Nr   zConditioning file not found: r   r   cudapt)	frameworkr   conditioning_data_r   attention_mask_attention_maskz$No conditioning data found in file: )r   get_full_pathr   existsFileNotFoundErrortorchr)   is_availablesafetensors	safe_openkeys
startswithr   replace
get_tensorappend
ValueErrorr   
NodeOutput)r"   r   r   	file_pathtarget_deviceconditioningfktensor_keys
tensor_keyidxtensorr   mask_keys                 r$   executeLTXVLoadConditioning.execute!   sO    ..|YG	I%%''#&CI;$OPPU?&+jj&=&=&?&?FUM(*""m
&'ffhUh,,?S2T1hKU$[1
 (()=rBj1*,,SE2vvx'01X0FG,-##V$56 2
  CI;OPP}}\**! V
 
s%   E0E+;E+A7E0+E00
E>c                     [         R                  " SU5      n[        US5       n[        R                  " UR                  5       5      R                  5       sS S S 5        $ ! , (       d  f       g = f)Nr   rb)r   r/   openhashlibsha256read	hexdigest)r"   r   r   r=   r@   s        r$   fingerprint_inputs'LTXVLoadConditioning.fingerprint_inputsB   sG     ..|YG	)T"a>>!&&(+557 #""s   2A  
A.c                     U(       d  g [         R                  " SU5      n[        U5      R                  5       (       d  SU 3$  g! [         a    SU 3s $ f = f)Nz1No files found. Please save a conditioning first.r   zFile not found: zInvalid file: T)r   r/   r   r0   	Exception)r"   r   r   r=   s       r$   validate_inputs$LTXVLoadConditioning.validate_inputsH   sg    F	0$22<KI	?))++))55 ,   	0#I;//	0s   9A AA N)__name__
__module____qualname____firstlineno__classmethodr   r   r%   strr<   rG   rP   boolrT   __static_attributes__rV   r'   r$   r   r      s    
bii 
 
" + +S +R]] + +@ 83 8 8 8 8
 	 	S 	TCZ 	 	r'   )rL   pathlibr   typingr   r   r4   r2   comfy_api.latestr   nodes_registryr   	ComfyNoder   rV   r'   r$   <module>rd      sE           & '(D2<< D )Dr'   