
    +j:#                    J   d dl mZ d dlmZ d dlmZmZ d dlZd dlm	Z	m
Z
mZ  G d d          Z G d d	          Z G d
 d          Z G d d          Z G d d          Zd>dZ G d dee          Z G d dee          Z G d dee          Z G d dee          Z G d dee          Z G d dee          Z G d dee          Z G d  d!e	          Z G d" d#e	          Z G d$ d%e	          Z G d& d'e	          Z G d( d)e	          Z G d* d+e	          Z G d, d-e	          Z  G d. d/e	          Z! G d0 d1e	          Z" G d2 d3e	          Z# G d4 d5e	          Z$ G d6 d7e	          Z% G d8 d9e	          Z& G d: d;e	          Z' G d< d=e	          Z(dS )?    )annotations)Enum)OptionalUnionN)	BaseModelFieldconfloatc                      e Zd ZdZdZdS )LumaIOLUMA_REFLUMA_CONCEPTSN)__name__
__module____qualname__r   r        9/home/wildlama/comfy/ComfyUI/comfy_api_nodes/apis/luma.pyr   r   
   s        H#MMMr   r   c                      e Zd Zd
dZddZd	S )LumaReferenceimagetorch.Tensorweightfloatc                "    || _         || _        d S N)r   r   )selfr   r   s      r   __init__zLumaReference.__init__   s    
r   download_urlstrc                .    t          || j                  S )Nurlr   )LumaImageRefr   )r   r   s     r   create_api_modelzLumaReference.create_api_model   s    T[AAAAr   N)r   r   r   r   )r   r   )r   r   r   r   r$   r   r   r   r   r      sB           B B B B B Br   r   c                  2    e Zd ZdddZdddZddd
Zd ZdS )LumaReferenceChainN	first_refr   c                P    g | _         |r| j                             |           d S d S r   refsappend)r   r'   s     r   r   zLumaReferenceChain.__init__   s7    )+	 	(IY'''''	( 	(r   luma_refc                :    | j                             |           d S r   r)   )r   r,   s     r   addzLumaReferenceChain.add   s    	"""""r      download_urls	list[str]c                    t          | j                  dk    rd S g }t          | j        |          D ]0\  }}t          ||j                  }|                    |           1|S )Nr   r!   )lenr*   zipr#   r   r+   )r   r0   max_refsapi_refsrefr"   api_refs          r   r$   z#LumaReferenceChain.create_api_model    sl    ty>>Q4')DI}55 	% 	%HC"s3:>>>GOOG$$$$r   c                `    t                      }| j        D ]}|                    |           |S r   )r&   r*   r.   )r   cr7   s      r   clonezLumaReferenceChain.clone)   s4      9 	 	CEE#JJJJr   r   )r'   r   )r,   r   )r/   )r0   r1   )r   r   r   r   r.   r$   r;   r   r   r   r&   r&      sn        ( ( ( ( (
# # # # #        r   r&   c                      e Zd ZddZdS )LumaConceptkeyr   c                    || _         d S r   r>   )r   r>   s     r   r   zLumaConcept.__init__1   s    r   N)r>   r   )r   r   r   r   r   r   r   r=   r=   0   s(             r   r=   c                  4    e Zd ZdddZddZd Zd	 ZddZdS )LumaConceptChainNstr_listr1   c                x    g | _         |.|D ]-}|dk    r#|                     t          |                     ,d S d S )NNoner@   )conceptsr.   r=   )r   rC   r:   s      r   r   zLumaConceptChain.__init__6   sW    +- 1 1;;HH[Q///000  1 1r   conceptr=   c                :    | j                             |           d S r   )rF   r+   )r   rG   s     r   r.   zLumaConceptChain.add=   s    W%%%%%r   c                    t          | j                  dk    rd S g }| j        D ]6}|j        dk    r|                    t	          |j                             7t          |          dk    rd S |S )Nr   rE   r@   )r3   rF   r>   r+   LumaConceptObject)r   api_conceptsrG   s      r   r$   z!LumaConceptChain.create_api_model@   s    t}""402} 	D 	DG{f$$ 1gk B B BCCCC|!!4r   c                `    t                      }| j        D ]}|                    |           |S r   )rB   rF   r.   )r   r:   rG   s      r   r;   zLumaConceptChain.cloneL   s4    } 	 	GEE'NNNNr   otherc                l    |                                  }|j        D ]}|                    |           |S r   )r;   rF   r.   )r   rM   r:   rG   s       r   clone_and_mergez LumaConceptChain.clone_and_mergeR   s6    JJLL~ 	 	GEE'NNNNr   r   )rC   r1   )rG   r=   )rM   rB   )r   r   r   r   r.   r$   r;   rO   r   r   r   rB   rB   5   ss        1 1 1 1 1& & & &
 
 
       r   rB   Fc                B    g }| r|                     d           |g dz   S )NrE   )"
truck_left	pan_rightpedestal_down	low_anglepedestal_upselfiepan_left
roll_rightzoom_inover_the_shoulderorbit_right
orbit_leftstatictiny_planet
high_anglebolt_cam
dolly_zoomoverheadzoom_outhandheld	roll_leftpovaerial_dronepush_in
crane_downtruck_right	tilt_downelevator_doorstilt_upground_levelpull_outaerialcrane_up	eye_level)r+   )include_nonerF   s     r   get_luma_conceptsrt   Y   s=    H   # # # # #r   c                      e Zd ZdZdZdS )LumaImageModelzphoton-1zphoton-flash-1N)r   r   r   photon_1photon_flash_1r   r   r   rv   rv      s        H%NNNr   rv   c                      e Zd ZdZdZdZdS )LumaVideoModelzray-2zray-flash-2zray-1-6N)r   r   r   ray_2ray_flash_2ray_1_6r   r   r   rz   rz      s        EKGGGr   rz   c                  *    e Zd ZdZdZdZdZdZdZdZ	dS )	LumaAspectRatioz1:1z16:9z9:16z4:3z3:4z21:9z9:21N)
r   r   r   	ratio_1_1
ratio_16_9
ratio_9_16	ratio_4_3	ratio_3_4
ratio_21_9
ratio_9_21r   r   r   r   r      s1        IJJIIJJJJr   r   c                      e Zd ZdZdZdZdZdS )LumaVideoOutputResolution540p720p1080p4kN)r   r   r   res_540pres_720p	res_1080pres_4kr   r   r   r   r      s"        HHIFFFr   r   c                      e Zd ZdZdZdS )LumaVideoModelOutputDuration5s9sN)r   r   r   dur_5sdur_9sr   r   r   r   r      s        FFFFr   r   c                      e Zd ZdZdZdS )LumaGenerationTypevideor   N)r   r   r   r   r   r   r   r   r   r      s        EEEEr   r   c                      e Zd ZdZdZdZdZdS )	LumaStatequeueddreaming	completedfailedN)r   r   r   r   r   r   r   r   r   r   r   r      s"        FHIFFFr   r   c                  |    e Zd ZU  edd          Zded<    edd          Zded<    edd          Zded	<   dS )

LumaAssetsNzThe URL of the videodescriptionOptional[str]r   The URL of the imager   zThe URL of the progress videoprogress_video)r   r   r   r   r   __annotations__r   r   r   r   r   r   r      su          53IJJJEJJJJ 53IJJJEJJJJ$)E$<[$\$\$\N\\\\\\r   r   c                  \    e Zd ZU dZ edd          Zded<    edd          Zded	<   d
S )r#   zUsed for image gen.The URL of the image referencer   r   r"   !The weight of the image referenceconfloat(ge=0.0, le=1.0)r   N)r   r   r   __doc__r   r"   r   r   r   r   r   r#   r#      sZ         uS&FGGGCGGGG',uS>a'b'b'bFbbbbbbr   r#   c                  \    e Zd ZU dZ edd          Zded<    edd          Zd	ed
<   dS )LumaImageReferencezUsed for video genr   zInput type, defaults to imager   r   type.r   r   r"   N)r   r   r   r   r   r   r   r"   r   r   r   r   r      sZ         %5TUUUDUUUUuS&<===C======r   r   c                  X    e Zd ZU  edd          Zded<    edd          Zded<   d	S )
LumaModifyImageRef.r   r   r   r"   r   r   r   N)r   r   r   r   r"   r   r   r   r   r   r   r      sT         uS&FGGGCGGGG',uS>a'b'b'bFbbbbbbr   r   c                  4    e Zd ZU  edd          Zded<   dS )LumaCharacterRef.The image identity objectr   LumaImageIdentity	identity0N)r   r   r   r   r   r   r   r   r   r   r      s3         #(5:U#V#V#VIVVVVVVr   r   c                  4    e Zd ZU  edd          Zded<   dS )r   .zThe URLs of the image identityr   r1   imagesN)r   r   r   r   r   r   r   r   r   r   r      s3         c/OPPPFPPPPPPr   r   c                  X    e Zd ZU  edd          Zded<    edd          Zded<   d	S )
LumaGenerationReference
generationz"Input type, defaults to generationr   r   r   .The ID of the generationidN)r   r   r   r   r   r   r   r   r   r   r   r      sT         l0TUUUDUUUUeC%?@@@B@@@@@@r   r   c                  X    e Zd ZU  edd          Zded<    edd          Zded<   dS )LumaKeyframesN r   z<Optional[Union[LumaImageReference, LumaGenerationReference]]frame0frame1)r   r   r   r   r   r   r   r   r   r   r   r      sV         KP5QUceKfKfKfFffffKP5QUceKfKfKfFffffffr   r   c                  4    e Zd ZU  edd          Zded<   dS )rJ   .zCamera Concept namer   r   r>   N)r   r   r   r   r>   r   r   r   r   rJ   rJ      s3         uS&;<<<C<<<<<<r   rJ   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    ee	j
        d	          Zd
ed<    edd          Zded<    edd          Zded<    edd          Zded<    edd          Zded<   dS )LumaImageGenerationRequest.The prompt of the generationr   r   promptz'The image model used for the generationrv   model"The aspect ratio of the generationOptional[LumaAspectRatio]aspect_ratioNzList of image reference objectszOptional[list[LumaImageRef]]	image_refzList of style reference objects	style_refr   zOptional[LumaCharacterRef]character_refz!The modify image reference objectzOptional[LumaModifyImageRef]modify_image_ref)r   r   r   r   r   r   rv   rw   r   r   r   r   r   r   r   r   r   r   r   r   r      s        %)GHHHFHHHH!E."9GpqqqEqqqq.3eO4N  ]A  /B  /B  /BL  B  B  B  B.3eDFg.h.h.hIhhhh.3eDFg.h.h.hIhhhh05dHc0d0d0dMdddd5:U4Mp5q5q5qqqqqqqr   r   c                  :   e Zd ZU  edd          Zded<    eej        d          Zded<    ed	d
          Z	ded<    ed	d          Z
ded<    ed	d          Zded<    ed	d          Zded<    ed	d          Zded<    ed	d          Zded<   d	S )LumaGenerationRequest.r   r   r   r   z'The video model used for the generationrz   r   NzThe duration of the generationz&Optional[LumaVideoModelOutputDuration]durationr   r   r   z The resolution of the generationz#Optional[LumaVideoOutputResolution]
resolutionzWhether to loop the videozOptional[bool]loopzThe keyframes of the generationzOptional[LumaKeyframes]	keyframesz&Camera Concepts to apply to generationz!Optional[list[LumaConceptObject]]rF   )r   r   r   r   r   r   rz   r{   r   r   r   r   r   r   rF   r   r   r   r   r      s        %)GHHHFHHHH!E."6DmnnnEnnnn7<uTOo7p7p7pHpppp.3eDFj.k.k.kLkkkk6;eDNp6q6q6qJqqqq 53NOOODOOOO).tAb)c)c)cIcccc27%Jr2s2s2sHssssssr   r   c                  0   e Zd ZU  edd          Zded<    edd          Zded<    edd	          Zd
ed<    edd          Zded<    edd          Z	ded<    edd          Z
ded<    edd          Zded<    edd          Zded<   dS )LumaGeneration.r   r   r   r   zGeneration type, image or videor   generation_typezThe state of the generationr   stateNz*The reason for the state of the generationr   failure_reasonz1The date and time when the generation was created
created_atzThe assets of the generationzOptional[LumaAssets]assetsz!The model used for the generationr   z#The request used for the generationz8Union[LumaGenerationRequest, LumaImageGenerationRequest]request)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s<        eC%?@@@B@@@@*/%Ab*c*c*cOccccuS.KLLLELLLL$)E$<h$i$i$iNiiiieC-`aaaJaaaa#(5;Y#Z#Z#ZFZZZZs(KLLLELLLLHMc  `E  IF  IF  IFG  F  F  F  F  F  Fr   r   c                  :    e Zd ZU dZded<   dZded<   dZded<   dS )Luma2ImageRefN
str | Noner"   data
media_type)r   r   r   r"   r   r   r   r   r   r   r   r      sE         CD!J!!!!!!r   r   c                      e Zd ZU  eddd          Zded<   dZded	<   dZded
<   dZded<   dZ	ded<   dZ
ded<   dZded<   dZded<   dZded<   dS )Luma2GenerationRequest.   ip  )
min_length
max_lengthr   r   Nr   r   r   r   styleoutput_formatzbool | None
web_searchzlist[Luma2ImageRef] | Noner   zLuma2ImageRef | Nonesource)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s         %d;;;F;;;;ED#L####E $M$$$$"J"""",0I0000#'F''''''r   r   c                      e Zd ZU dZded<   dZded<   dZded<   dZded<   dZded<   dZ	ded	<   dZ
ded
<   dZded<   dS )Luma2GenerationNr   r   r   r   r   r   zlist[LumaImageReference] | Noneoutputr   failure_code)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s         BDEE!J!!!!.2F2222!%N%%%%#L######r   r   )F))
__future__r   enumr   typingr   r   torchpydanticr   r   r	   r   r   r&   r=   rB   rt   r   rv   rz   r   r   r   r   r   r   r#   r   r   r   r   r   r   rJ   r   r   r   r   r   r   r   r   r   <module>r      sR   " " " " " "       " " " " " " " "  / / / / / / / / / /$ $ $ $ $ $ $ $
B B B B B B B B       2       
! ! ! ! ! ! ! !H' ' ' 'T& & & & &S$ & & &
    S$       c4       T       3   
    d   
    T   ] ] ] ] ] ] ] ]c c c c c9 c c c> > > > > > > >c c c c c c c c
W W W W Wy W W WQ Q Q Q Q	 Q Q QA A A A Ai A A A
g g g g gI g g g
= = = = =	 = = =r r r r r r r rt t t t tI t t tF F F F FY F F F" " " " "I " " "	( 	( 	( 	( 	(Y 	( 	( 	($ $ $ $ $i $ $ $ $ $r   