
    A'h                         d dl mZmZ d dlmZ d dlmZmZmZ d dl	m
Z
 d dlmZ d dlmZmZ  ed      Z ed      Z ed	      Z G d
 deeeef   e      Zg dZy)    )ABCabstractmethod)Sequence)AnyGenericTypeVar)Self)MISSING)EmptyChannelErrorInvalidUpdateErrorValueUpdateCc                       e Zd ZdZdZddededdfdZee	defd              Z
ee	defd	              Zdefd
ZdefdZe	dedefd       Ze	defd       ZdefdZe	dee   defd       ZdefdZdefdZy)BaseChannelzBase class for all channels.)keytypr   r   returnNc                      || _         || _        y )N)r   r   )selfr   r   s      ^/home/kushmeetdev/Regenta/Chatbot/venv/lib/python3.12/site-packages/langgraph/channels/base.py__init__zBaseChannel.__init__   s        c                      y)z,The type of the value stored in the channel.N r   s    r   	ValueTypezBaseChannel.ValueType       r   c                      y)z/The type of the update received by the channel.Nr   r   s    r   
UpdateTypezBaseChannel.UpdateType   r   r   c                 @    | j                  | j                               S )zReturn a copy of the channel.
        By default, delegates to checkpoint() and from_checkpoint().
        Subclasses can override this method with a more efficient implementation.)from_checkpoint
checkpointr   s    r   copyzBaseChannel.copy$   s     ##DOO$566r   c                 N    	 | j                         S # t        $ r	 t        cY S w xY w)zReturn a serializable representation of the channel's current state.
        Raises EmptyChannelError if the channel is empty (never updated yet),
        or doesn't support checkpoints.)getr   r
   r   s    r   r#   zBaseChannel.checkpoint*   s'    	88:  	N	s    $$r#   c                      y)zReturn a new identical channel, optionally initialized from a checkpoint.
        If the checkpoint contains complex data structures, they should be copied.Nr   )r   r#   s     r   r"   zBaseChannel.from_checkpoint3   r   r   c                      y)zwReturn the current value of the channel.

        Raises EmptyChannelError if the channel is empty (never updated yet).Nr   r   s    r   r&   zBaseChannel.get:   r   r   c                 D    	 | j                          y# t        $ r Y yw xY w)zReturn True if the channel is available (not empty), False otherwise.
        Subclasses should override this method to provide a more efficient
        implementation than calling get() and catching EmptyChannelError.
        TF)r&   r   r   s    r   is_availablezBaseChannel.is_available@   s%    
	HHJ  		s    	valuesc                      y)a  Update the channel's value with the given sequence of updates.
        The order of the updates in the sequence is arbitrary.
        This method is called by Pregel for all channels at the end of each step.
        If there are no updates, it is called with an empty sequence.
        Raises InvalidUpdateError if the sequence of updates is invalid.
        Returns True if the channel was updated, False otherwise.Nr   )r   r+   s     r   updatezBaseChannel.updateM   r   r   c                      y)a   Notify the channel that a subscribed task ran. By default, no-op.
        A channel can use this method to modify its state, preventing the value
        from being consumed again.

        Returns True if the channel was updated, False otherwise.
        Fr   r   s    r   consumezBaseChannel.consumeV   s     r   c                      y)zNotify the channel that the Pregel run is finishing. By default, no-op.
        A channel can use this method to modify its state, preventing finish.

        Returns True if the channel was updated, False otherwise.
        Fr   r   s    r   finishzBaseChannel.finish_   s     r   ) )__name__
__module____qualname____doc__	__slots__r   strr   propertyr   r   r    r	   r$   r   r#   r"   r   r&   boolr*   r   r   r-   r/   r1   r   r   r   r   r      s   &IC c 4  ;3 ;  ; >C >  >
7d 7A  V! V V V QU Q Q
	d 	 EXf- E$ E E  r   r   )r   r   r   N)abcr   r   collections.abcr   typingr   r   r   typing_extensionsr	   langgraph.constantsr
   langgraph.errorsr   r   r   r   r   r   __all__r   r   r   <module>rB      s[    # $ ( ( " ' B		CLV'%*+S Vrr   