
    <i              	           S SK rS SK JrJr  S SKJrJr  S SKJrJ	r	J
r
  S SKJr  S SKJr  S SKJrJr  S SKJrJrJrJr  S S	KJr  S
rS rS\S\\\4   4S jr " S S\\   \\\\4   5      rg)    N)CallableSequence)AnyGeneric)NotRequiredRequiredSelf)	OVERWRITE)MISSING)BaseChannelValue)EmptyChannelError	ErrorCodeInvalidUpdateErrorcreate_error_message)	Overwrite)BinaryOperatorAggregatec                     [        U S5      (       a  [        U R                  5      $ [        U S5      (       a2  U R                  [        [        4;   a  [        U R
                  S   5      $ U $ )z=Strips Annotated, Required and NotRequired from a given type.
__origin__r   )hasattr_strip_extrasr   r   r   __args__)ts    h/home/dmtnaga/Documents/work/airagagent/rag_env/lib/python3.13/site-packages/langgraph/channels/binop.pyr   r      sS    q,Q\\**q,ALLX{4K$KQZZ]++H    valuereturnc                     [        U [        5      (       a  SU R                  4$ [        U [        5      (       a-  [	        U R                  5       5      [        1:X  a  SU [           4$ g)zEInspects the given value and returns (is_overwrite, overwrite_value).T)FN)
isinstancer   r   dictsetkeysr
   r   s    r   _get_overwriter$       sR    %##U[[  %3uzz|#4#CU9%%%r   c                      ^  \ rS rSrSrSrS\\   S\\\/\4   4U 4S jjr	S\
S\4S	 jr\S\\   4S
 j5       r\S\\   4S j5       rS\4S jrS\S\4S jrS\\   S\4S jrS\4S jrS\4S jrS\4S jrSrU =r$ )r   )   zStores the result of applying a binary operator to the current value and each new value.

```python
import operator

total = Channels.BinaryOperatorAggregate(int, operator.add)
```
)r   operatortypr'   c                 
  > [         TU ]  U5        X l        [        U5      nU[        R
                  R                  [        R
                  R                  4;   a  [        nU[        R
                  R                  [        R
                  R                  4;   a  [        nU[        R
                  R                  [        R
                  R                  4;   a  [        n U" 5       U l        g ! [          a    ["        U l         g f = fN)super__init__r'   r   collectionsabcr   MutableSequencelistSet
MutableSetr!   MappingMutableMappingr    r   	Exceptionr   )selfr(   r'   	__class__s      r   r,    BinaryOperatorAggregate.__init__5   s      C ;??++[__-L-LMMC;??&&(B(BCCC;??**KOO,J,JKKC	!DJ 	! DJ	!s   C* *DDr   r   c                     [        U[        5      =(       aN    UR                  R                  S:w  a2  U R                  R                  S:w  a  UR                  U R                  L $ S$ )Nz<lambda>T)r   r   r'   __name__)r6   r   s     r   __eq__BinaryOperatorAggregate.__eq__F   sW    %!89 
~~&&*4&&*4 NNdmm+	
 		
r   c                     U R                   $ )z,The type of the value stored in the channel.r(   r6   s    r   	ValueType!BinaryOperatorAggregate.ValueTypeN        xxr   c                     U R                   $ )z/The type of the update received by the channel.r>   r?   s    r   
UpdateType"BinaryOperatorAggregate.UpdateTypeS   rB   r   c                     U R                  U R                  U R                  5      nU R                  Ul        U R                  Ul        U$ )zReturn a copy of the channel.)r7   r(   r'   keyr   )r6   emptys     r   copyBinaryOperatorAggregate.copyX   s5    txx7HH	jjr   
checkpointc                     U R                  U R                  U R                  5      nU R                  Ul        U[        La  Xl        U$ r*   )r7   r(   r'   rG   r   r   )r6   rK   rH   s      r   from_checkpoint'BinaryOperatorAggregate.from_checkpoint_   s7    txx7HH	W$$Kr   valuesc                 R   U(       d  gU R                   [        L a  US   U l         USS  nSnU Hu  n[        U5      u  pEU(       a4  U(       a#  [        S[        R
                  S9n[        U5      eXPl         SnMK  U(       a  MT  U R                  U R                   U5      U l         Mw     g)NFr      z4Can receive only one Overwrite value per super-step.)message
error_codeT)r   r   r$   r   r   INVALID_CONCURRENT_GRAPH_UPDATEr   r'   )r6   rO   seen_overwriter   is_overwriteoverwrite_valuemsgs          r   updateBinaryOperatorAggregate.updatef   s    :: DJABZF$E,:5,A)L!. V#,#L#LC -S11,
!%!>!]]4::u=
  r   c                 T    U R                   [        L a
  [        5       eU R                   $ r*   )r   r   r   r?   s    r   getBinaryOperatorAggregate.get}   s!    :: #%%zzr   c                 &    U R                   [        L$ r*   )r   r   r?   s    r   is_available$BinaryOperatorAggregate.is_available   s    zz((r   c                     U R                   $ r*   r#   r?   s    r   rK   "BinaryOperatorAggregate.checkpoint   s    zzr   )r'   r   )r:   
__module____qualname____firstlineno____doc__	__slots__typer   r   r,   objectboolr;   propertyr@   rD   r	   rI   rM   r   rY   r\   r_   rK   __static_attributes____classcell__)r7   s   @r   r   r   )   s     &I!DK !8UENE<Q3R !"
F 
t 
 4;   DK  d % D Xe_  .U 
)d )E  r   r   )collections.abcr-   r   r   typingr   r   typing_extensionsr   r   r	   langgraph._internal._constantsr
   langgraph._internal._typingr   langgraph.channels.baser   r   langgraph.errorsr   r   r   r   langgraph.typesr   __all__r   tuplerj   r$   r    r   r   <module>ry      sr     .  9 9 4 / 6  &
&# %c	"2 ]genk%:M.N ]r   