U
    DAfT                     @   sx   d dl mZmZ d dlmZ d dlmZmZ eddddZeegdf e	dd	d
Z
e	eeegdf  dddZdS )    )CallableOptional)StreamingChunk)deserialize_callableserialize_callableN)chunkreturnc                 C   s   t | jddd dS )z
    Default callback function for streaming responses.

    Prints the tokens of the first completion to stdout as soon as they are received
    T )flushendN)printcontent)r    r   H/tmp/pip-unpacked-wheel-z752163x/haystack/components/generators/utils.pyprint_streaming_chunk   s    r   )streaming_callbackr   c                 C   s   t | S )z
    Serializes the streaming callback handler.

    :param streaming_callback:
        The streaming callback handler function
    :returns:
        The full path of the streaming callback handler function
    )r   )r   r   r   r   serialize_callback_handler   s    	r   )callback_namer   c                 C   s   t | S )a5  
    Deserializes the streaming callback handler.

    :param callback_name:
        The full path of the streaming callback handler function
    :returns:
        The streaming callback handler function
    :raises DeserializationError:
        If the streaming callback handler function cannot be found
    )r   )r   r   r   r   deserialize_callback_handler    s    r   )typingr   r   Zhaystack.dataclassesr   Zhaystack.utilsr   r   r   strr   r   r   r   r   r   <module>   s
   	