o
    i
                     @   sh   d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZ G dd	 d	eZd
S )zImage generation service implementation.

Provides base functionality for AI-powered image generation services that convert
text prompts into images.
    )abstractmethod)AsyncGeneratorOptional)Frame	TextFrame)FrameDirection)	AIService)ImageGenSettingsc                       sd   e Zd ZdZdddee f fddZedede	e
df fd	d
Zde
def fddZ  ZS )ImageGenServicea  Base class for image generation services.

    Processes TextFrames by using their content as prompts for image generation.
    Subclasses must implement the run_image_gen method to provide actual image
    generation functionality using their specific AI service.
    N)settingsr   c                   s    t  jdd|p	t i| dS )zInitialize the image generation service.

        Args:
            settings: The runtime-updatable settings for the image generation service.
            **kwargs: Additional arguments passed to the parent AIService.
        r   N )super__init__r	   )selfr   kwargs	__class__r   R/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/services/image_service.pyr      s   

zImageGenService.__init__promptreturnc                    s   dS )a  Generate an image from a text prompt.

        This method must be implemented by subclasses to provide actual image
        generation functionality using their specific AI service.

        Args:
            prompt: The text prompt to generate an image from.

        Yields:
            Frame: Frames containing the generated image (typically ImageRawFrame
                or URLImageRawFrame).
        Nr   )r   r   r   r   r   run_image_gen.   s   zImageGenService.run_image_genframe	directionc                    s   t  ||I dH  t|tr5| ||I dH  |  I dH  | | |jI dH  | 	 I dH  dS | ||I dH  dS )a  Process frames for image generation.

        TextFrames are used as prompts for image generation, while other frames
        are passed through unchanged.

        Args:
            frame: The frame to process.
            direction: The direction of frame processing.
        N)
r   process_frame
isinstancer   
push_framestart_processing_metricsprocess_generatorr   textstop_processing_metrics)r   r   r   r   r   r   r   >   s   

zImageGenService.process_frame)__name__
__module____qualname____doc__r   r	   r   r   strr   r   r   r   r   __classcell__r   r   r   r   r
      s    r
   N)r#   abcr   typingr   r   pipecat.frames.framesr   r   "pipecat.processors.frame_processorr   pipecat.services.ai_servicer   pipecat.services.settingsr	   r
   r   r   r   r   <module>   s   