
    qi                     R    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e
      Zy)z4Stateless text transformation processor for Pipecat.    )Callable	CoroutineUnion)Frame	TextFrame)FrameDirectionFrameProcessorc            	       j     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Zde	de
f fdZ x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                 0    t         |           || _        y)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__s     U/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/processors/text_transformer.pyr   z!StatelessTextTransformer.__init__   s     	)    frame	directionc                 T  K   t         |   ||       d{    t        |t              rY| j	                  |j
                        }t        |t              r
| d{   }| j                  t        |             d{    y| j                  ||       d{    y7 7 E7 $7 w)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   s       r   r   z&StatelessTextTransformer.process_frame#   s      g#E9555eY'''

3F&),%//)"8999//%333 	6
 &93sF   B(B AB(B""B(?B$ B(B&B("B($B(&B()__name__
__module____qualname____doc__r   r   strr   r   r   r   r   __classcell__)r   s   @r   r   r      s]    
*!(C5#:"6#	RVX\^aRaHbAb8c"cd
*4 4> 4 4r   r   N)r    typingr   r   r   pipecat.frames.framesr   r   "pipecat.processors.frame_processorr   r	   r    r   r   <module>r'      s"    ; - - 2 M#4~ #4r   