
    ci	              	       D    d Z ddlZddlmZ dZ	 	 d
dededz  dedefd	Zy)z
Video generation service using Replicate.

- Text-to-video: lightricks/ltx-2-distilled
- Image-to-video: lightricks/ltx-2-distilled (with image input)
    N)loggerzlightricks/ltx-2-distilledprompt	image_url
num_framesreturnc                   K   	 t        j                  d|        | |dddd}|r||d<   t        j                  t        |       d{   }|rIt        |d	      rt        |j                        n
t        |      }t        j                  d
|        |ddS t        j                  d       dddS 7 i# t        $ r0}t        j                  d|        t        |      ddcY d}~S d}~ww xY ww)aX  Generate a video using Replicate's lightricks/ltx-2-distilled model.

    Args:
        prompt: Text description of the video to generate.
        image_url: Optional reference image URL for image-to-video.
        num_frames: Number of frames (default 121).

    Returns:
        dict with "url" key on success, or "error" key on failure.
    z3[VideoService] Generating video (ltx-2-distilled): z16:9F   )r   r   aspect_ratioenhance_promptimage_strengthimage)inputNurlz [VideoService] Video generated: T)r   successz/[VideoService] No video returned from Replicatez)No video was generated. Please try again.)errorr   z'[VideoService] Error generating video: )r   info	replicate	async_run	LTX_MODELhasattrstrr   warning	Exceptionr   )r   r   r   input_paramsoutputr   es          L/Users/thippareddysaicharanreddy/Desktop/agent_all/services/video_service.pygenerate_videor      s     +3I&TU $"#
 $-L! **9LII& %,VU%;#fjj/VCKK:3%@A400HIDQVWW3 J6  3>qcBCQE223sT   C1AB5 	B3
AB5 C1B5 2C13B5 5	C.>%C)#C.$C1)C..C1)Ny   )	__doc__r   logurur   r   r   intdictr        r   <module>r&      sN      )	 !:3:3Tz:3 :3 
	:3r%   