
    +jg                     B   d dl mZ d dlmZmZ d dlmZ d dlmZm	Z	m
Z
mZ d dlmZmZmZmZmZ dddZ G d	 d
e          Z ej         ej        g d          d          Z G d dej                  Z G d dej                  Z G d de	          ZdefdZdS )    )BytesIO)	BaseModelField)override)IOComfyExtensionInput	InputImpl)ApiEndpointget_number_of_imagessync_op_rawupload_images_to_comfyapivalidate_stringz	ltx-2-proz
ltx-2-fast)zLTX-2 (Pro)LTX-2 (Fast)c                      e Zd ZU  ed          Zeed<    ed          Zeed<    ed          Ze	ed<    ed          Z
eed<    ed          Ze	dz  ed<    ed	          Zedz  ed
<    ed          Zedz  ed<   dS )ExecuteTaskRequest.promptmodelduration
resolution   NfpsTgenerate_audio	image_uri)__name__
__module____qualname__r   r   str__annotations__r   r   intr   r   r   boolr        :/home/wildlama/comfy/ComfyUI/comfy_api_nodes/nodes_ltxv.pyr   r      s         %**FCsE3E#JJHceCjjJ   eBiiCt"'%++ND4K---!E$KKIsTz'''''r#   r   )r   r   r   )widgetsaw  
    (
      $prices := {
        "ltx-2 (pro)": {"1920x1080":0.06,"2560x1440":0.12,"3840x2160":0.24},
        "ltx-2 (fast)": {"1920x1080":0.04,"2560x1440":0.08,"3840x2160":0.16}
      };
      $modelPrices := $lookup($prices, $lowercase(widgets.model));
      $pps := $lookup($modelPrices, widgets.resolution);
      {"type":"usd","usd": $pps * widgets.duration}
    )
    )
depends_onexprc                   h    e Zd Zed             Ze	 	 ddededededed	ed
ej	        fd            Z
dS )TextToVideoNodec                    t          j        ddddt           j                            dt	          t
                                                              t           j                            ddd	
          t           j                            dg dd          t           j                            dg d          t           j                            dddgd          t           j                            ddddd          gt           j	        
                                gt           j        j        t           j        j        t           j        j        gdt          	  	        S )NLtxvApiTextToVideozLTXV Text To Videopartner/video/LTXVzFProfessional-quality videos with customizable duration and resolution.r   optionsr   T 	multilinedefaultr         
                  r5   r.   r2   r   	1920x1080	2560x1440	3840x2160r   r   2   r   FRWhen true, the generated video will include AI-generated audio matching the scene.r2   optionaltooltipadvanced	node_iddisplay_namecategorydescriptioninputsoutputshiddenis_api_nodeprice_badge)r   SchemaCombor	   list
MODELS_MAPkeysStringBooleanVideoOutputHiddenauth_token_comfy_orgapi_key_comfy_org	unique_idPRICE_BADGEclss    r$   define_schemazTextToVideoNode.define_schema0   sC   y(-)`wZ__5F5F0G0GHH	"    
 z3Q3Q3Q[\]]       ur2hCC
  $!!p! !  #4 !! 	.	+	#
 #O(
 (
 (
 (	
r#   r   Fr   r   r   r   r   r   returnc                 j  K   t          |dd           |dk    r!|dk    s|dk    s|dk    rt          d          t          | t          d	d
          t	          |t
          |         ||||          dd           d {V }t          j        t          j	        t          |                              S )N   '  
min_length
max_lengthr6   r   r>   r   \Durations over 10s are only available for the Fast model at 1920x1080 resolution and 25 FPS.z/proxy/ltx/v1/text-to-videoPOST)r   r   r   r   r   r   Tdata	as_binarymax_retries)r   
ValueErrorr   r   r   rT   r   
NodeOutputr
   VideoFromFiler   )r`   r   r   r   r   r   r   responses           r$   executezTextToVideoNode.execute\   s       	1????b==e~55{9R9RVY]_V_V_n   %5v>># '!%-   
 
 
 
 
 
 
 
 
 }Y4WX5F5FGGHHHr#   Nr   F)r   r   r   classmethodra   r   r    r!   r   rp   rs   r"   r#   r$   r)   r)   /   s        )
 )
 [)
V  $I II I 	I
 I I I 
I I I [I I Ir#   r)   c                   v    e Zd Zed             Ze	 	 ddej        dedededed	ed
e	de
j        fd            ZdS )ImageToVideoNodec                     t          j        ddddt           j                            dd          t           j                            dt          t                                                    	          t           j                            d
dd          t           j                            dg dd          t           j                            dg d	          t           j                            dddgd          t           j	                            ddddd          gt           j
                                        gt           j        j        t           j        j        t           j        j        gdt           	  	        S )NLtxvApiImageToVideozLTXV Image To Videor,   z[Professional-quality videos with customizable duration and resolution based on start image.imagez%First frame to be used for the video.)rE   r   r-   r   Tr/   r0   r   r3   r5   r<   r   r=   r   r   rA   r   FrB   rC   rG   )r   rQ   Imager	   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   s    r$   ra   zImageToVideoNode.define_schema}   sY   y).)uw0WXXwZ__5F5F0G0GHH	"    
 z3Q3Q3Q[\]]       ur2hCC
  $!!p! !  %6 !! 	.	+	#
 #Q)
 )
 )
 )	
r#   r   Frz   r   r   r   r   r   r   rb   c                   K   t          |dd           |dk    r!|dk    s|dk    s|dk    rt          d          t          |          dk    rt          d	          t          | t	          d
d          t          t          | |dd           d {V d         |t          |         ||||          dd           d {V }t          j	        t          j        t          |                              S )Nrd   re   rf   r6   r   r>   r   ri   z,Currently only one input image is supported.z/proxy/ltx/v1/image-to-videorj   z	image/png)
max_images	mime_typer   )r   r   r   r   r   r   r   Trk   )r   ro   r   r   r   r   r   rT   r   rp   r
   rq   r   )	r`   rz   r   r   r   r   r   r   rr   s	            r$   rs   zImageToVideoNode.execute   sF      	1????b==e~55{9R9RVY]_V_V_n    &&!++KLLL$6??#!:3RS_j!k!k!kkkkkkkmno '!%-   
 
 
 
 
 
 
 
 
 }Y4WX5F5FGGHHHr#   Nrt   )r   r   r   ru   ra   r	   r{   r   r    r!   r   rp   rs   r"   r#   r$   rw   rw   |   s        *
 *
 [*
X  $ I  I{ I  I 	 I
  I  I  I  I 
 I  I  I [ I  I  Ir#   rw   c                   L    e Zd Zedeeej                          fd            ZdS )LtxvApiExtensionrb   c                 "   K   t           t          gS N)r)   rw   )selfs    r$   get_node_listzLtxvApiExtension.get_node_list   s       
 	
r#   N)	r   r   r   r   rS   typer   	ComfyNoder   r"   r#   r$   r   r      sE        
T$r|*<%= 
 
 
 X
 
 
r#   r   rb   c                  "   K   t                      S r   )r   r"   r#   r$   comfy_entrypointr      s      r#   N)ior   pydanticr   r   typing_extensionsr   comfy_api.latestr   r   r	   r
   comfy_api_nodes.utilr   r   r   r   r   rT   r   
PriceBadgePriceBadgeDependsr^   r   r)   rw   r   r   r"   r#   r$   <module>r      s         % % % % % % % % & & & & & & A A A A A A A A A A A A                
( ( ( ( ( ( ( ( bm#r#,O,O,OPPP

   JI JI JI JI JIbl JI JI JIZOI OI OI OI OIr| OI OI OId
 
 
 
 
~ 
 
 
 0      r#   