o
    i                     @   sL   d Z ddlmZmZmZ ddlmZmZ ddlm	Z	m
Z
 G dd de
ZdS )z4Stateless text transformation processor for Pipecat.    )Callable	CoroutineUnion)Frame	TextFrame)FrameDirectionFrameProcessorc                	       sb   e Zd ZdZdeeegef eegeddef f f f fddZde	de
f fdd	Z  ZS )
StatelessTextTransformera
  Processor that applies transformation functions to text frames.

    This processor intercepts TextFrame objects and applies a user-provided
    transformation function to the text content. The function can be either
    synchronous or asynchronous (coroutine).
    transform_fnNc                    s   t    || _dS )zInitialize the text transformer.

        Args:
            transform_fn: Function to apply to text content. Can be synchronous
                (str -> str) or asynchronous (str -> Coroutine[None, None, str]).
        N)super__init___transform_fn)selfr
   	__class__ W/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/processors/text_transformer.pyr      s   
	
z!StatelessTextTransformer.__init__frame	directionc                    sp   t  ||I dH  t|tr-| |j}t|tr |I dH }| t|dI dH  dS | ||I dH  dS )zProcess frames, applying transformation to text frames.

        Args:
            frame: The frame to process.
            direction: The direction of frame flow in the pipeline.
        N)text)r   process_frame
isinstancer   r   r   r   
push_frame)r   r   r   resultr   r   r   r   #   s   


z&StatelessTextTransformer.process_frame)__name__
__module____qualname____doc__r   r   strr   r   r   r   r   __classcell__r   r   r   r   r	      s    (r	   N)r   typingr   r   r   pipecat.frames.framesr   r   "pipecat.processors.frame_processorr   r   r	   r   r   r   r   <module>   s
   