§
    ™ŠtjÍ  ã                   ó’   — d dl mZmZmZmZ d dlmZmZ d dlm	Z	  ed¦  «        Z
 ed¦  «        Z G d„ de	e
ef         ¦  «        ZdS )	é    )ÚAsyncIteratorÚCallableÚIteratorÚSequence)ÚAnyÚTypeVar)Ú	BaseStoreÚKÚVc            
       óÔ  — e Zd ZdZdeeef         deegef         dee	ge
f         deege	f         ddf
d„Zd	ee         dee	dz           fd
„Zd	ee         dee	dz           fd„Zdeeee	f                  ddfd„Zdeeee	f                  ddfd„Zd	ee         ddfd„Zd	ee         ddfd„Zddœdedz  dee         ee         z  fd„Zddœdedz  dee         ee         z  fd„ZdS )ÚEncoderBackedStorea¦  Wraps a store with key and value encoders/decoders.

    Examples that uses JSON for encoding/decoding:

    ```python
    import json


    def key_encoder(key: int) -> str:
        return json.dumps(key)


    def value_serializer(value: float) -> str:
        return json.dumps(value)


    def value_deserializer(serialized_value: str) -> float:
        return json.loads(serialized_value)


    # Create an instance of the abstract store
    abstract_store = MyCustomStore()

    # Create an instance of the encoder-backed store
    store = EncoderBackedStore(
        store=abstract_store,
        key_encoder=key_encoder,
        value_serializer=value_serializer,
        value_deserializer=value_deserializer,
    )

    # Use the encoder-backed store methods
    store.mset([(1, 3.14), (2, 2.718)])
    values = store.mget([1, 2])  # Retrieves [3.14, 2.718]
    store.mdelete([1, 2])  # Deletes the keys 1 and 2
    ```
    ÚstoreÚkey_encoderÚvalue_serializerÚvalue_deserializerÚreturnNc                 ó>   — || _         || _        || _        || _        dS )aW  Initialize an `EncodedStore`.

        Args:
            store: The underlying byte store to wrap.
            key_encoder: Function to encode keys from type `K` to strings.
            value_serializer: Function to serialize values from type `V` to bytes.
            value_deserializer: Function to deserialize bytes back to type V.
        N)r   r   r   r   )Úselfr   r   r   r   s        úf/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_classic/storage/encoder_backed.pyÚ__init__zEncoderBackedStore.__init__4   s)   € ð ˆŒ
Ø&ˆÔØ 0ˆÔØ"4ˆÔÐÐó    Úkeysc                 óp   ‡ — ˆ fd„|D ¦   «         }‰ j                              |¦  «        }ˆ fd„|D ¦   «         S )a  Get the values associated with the given keys.

        Args:
            keys: A sequence of keys.

        Returns:
            A sequence of optional values associated with the keys.
            If a key is not found, the corresponding value will be `None`.
        c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS © ©r   ©Ú.0Úkeyr   s     €r   ú
<listcomp>z+EncoderBackedStore.mget.<locals>.<listcomp>R   ó'   ø€ Ð"IÐ"IÐ"I¸S 4×#3Ò#3°CÑ#8Ô#8Ð"IÐ"IÐ"Ir   c                 óB   •— g | ]}|�‰                      |¦  «        n|‘ŒS ©N©r   ©r   Úvaluer   s     €r   r    z+EncoderBackedStore.mget.<locals>.<listcomp>T   óA   ø€ ð 
ð 
ð 
àð /4Ð.?ˆD×#Ò# EÑ*Ô*Ð*ÀUð
ð 
ð 
r   )r   Úmget©r   r   Úencoded_keysÚvaluess   `   r   r(   zEncoderBackedStore.mgetH   s]   ø€ ð #JÐ"IÐ"IÐ"IÀDÐ"IÑ"IÔ"IˆØ”—’ Ñ.Ô.ˆð
ð 
ð 
ð 
àð
ñ 
ô 
ð 	
r   c              ƒ   ó€   ‡ K  — ˆ fd„|D ¦   «         }‰ j                              |¦  «        ƒ d{V —†}ˆ fd„|D ¦   «         S )a  Async get the values associated with the given keys.

        Args:
            keys: A sequence of keys.

        Returns:
            A sequence of optional values associated with the keys.
            If a key is not found, the corresponding value will be `None`.
        c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS r   r   r   s     €r   r    z,EncoderBackedStore.amget.<locals>.<listcomp>c   r!   r   Nc                 óB   •— g | ]}|�‰                      |¦  «        n|‘ŒS r#   r$   r%   s     €r   r    z,EncoderBackedStore.amget.<locals>.<listcomp>e   r'   r   )r   Úamgetr)   s   `   r   r/   zEncoderBackedStore.amgetY   su   øè è € ð #JÐ"IÐ"IÐ"IÀDÐ"IÑ"IÔ"IˆØ”z×'Ò'¨Ñ5Ô5Ð5Ð5Ð5Ð5Ð5Ð5ˆð
ð 
ð 
ð 
àð
ñ 
ô 
ð 	
r   Úkey_value_pairsc                 óX   ‡ — ˆ fd„|D ¦   «         }‰ j                              |¦  «         dS )zvSet the values for the given keys.

        Args:
            key_value_pairs: A sequence of key-value pairs.
        c                 ój   •— g | ]/\  }}‰                      |¦  «        ‰                     |¦  «        f‘Œ0S r   ©r   r   ©r   r   r&   r   s      €r   r    z+EncoderBackedStore.mset.<locals>.<listcomp>p   óN   ø€ ð 
ð 
ð 
á��Uð ×Ò˜cÑ"Ô" D×$9Ò$9¸%Ñ$@Ô$@ÐAð
ð 
ð 
r   N)r   Úmset©r   r0   Úencoded_pairss   `  r   r6   zEncoderBackedStore.msetj   sG   ø€ ð
ð 
ð 
ð 
à-ð
ñ 
ô 
ˆð 	Œ
�Š˜Ñ&Ô&Ð&Ð&Ð&r   c              ƒ   óh   ‡ K  — ˆ fd„|D ¦   «         }‰ j                              |¦  «        ƒ d{V —† dS )z|Async set the values for the given keys.

        Args:
            key_value_pairs: A sequence of key-value pairs.
        c                 ój   •— g | ]/\  }}‰                      |¦  «        ‰                     |¦  «        f‘Œ0S r   r3   r4   s      €r   r    z,EncoderBackedStore.amset.<locals>.<listcomp>|   r5   r   N)r   Úamsetr7   s   `  r   r;   zEncoderBackedStore.amsetv   s_   øè è € ð
ð 
ð 
ð 
à-ð
ñ 
ô 
ˆð Œj×Ò˜}Ñ-Ô-Ð-Ð-Ð-Ð-Ð-Ð-Ð-Ð-Ð-r   c                 óX   ‡ — ˆ fd„|D ¦   «         }‰ j                              |¦  «         dS )zzDelete the given keys and their associated values.

        Args:
            keys: A sequence of keys to delete.
        c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS r   r   r   s     €r   r    z.EncoderBackedStore.mdelete.<locals>.<listcomp>ˆ   ó'   ø€ Ð>Ð>Ð>°#˜×(Ò(¨Ñ-Ô-Ð>Ð>Ð>r   N)r   Úmdelete©r   r   r*   s   `  r   r?   zEncoderBackedStore.mdelete‚   s:   ø€ ð ?Ð>Ð>Ð>¸Ð>Ñ>Ô>ˆØŒ
×Ò˜<Ñ(Ô(Ð(Ð(Ð(r   c              ƒ   óh   ‡ K  — ˆ fd„|D ¦   «         }‰ j                              |¦  «        ƒ d{V —† dS )z€Async delete the given keys and their associated values.

        Args:
            keys: A sequence of keys to delete.
        c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS r   r   r   s     €r   r    z/EncoderBackedStore.amdelete.<locals>.<listcomp>‘   r>   r   N)r   Úamdeleter@   s   `  r   rC   zEncoderBackedStore.amdelete‹   sP   øè è € ð ?Ð>Ð>Ð>¸Ð>Ñ>Ô>ˆØŒj×!Ò! ,Ñ/Ô/Ð/Ð/Ð/Ð/Ð/Ð/Ð/Ð/Ð/r   ©ÚprefixrE   c             #   óL   K  — | j                              |¬¦  «        E d{V —† dS )z¶Get an iterator over keys that match the given prefix.

        Args:
            prefix: The prefix to match.

        Yields:
            Keys that match the given prefix.
        rD   N)r   Ú
yield_keys)r   rE   s     r   rG   zEncoderBackedStore.yield_keys”   s9   è è € ð ”:×(Ò(°Ð(Ñ7Ô7Ð7Ð7Ð7Ð7Ð7Ð7Ð7Ð7Ð7r   c               ó\   K  — | j                              |¬¦  «        2 3 d{V —†}|W V — Œ6 dS )z¼Async get an iterator over keys that match the given prefix.

        Args:
            prefix: The prefix to match.

        Yields:
            Keys that match the given prefix.
        rD   N)r   Úayield_keys)r   rE   r   s      r   rI   zEncoderBackedStore.ayield_keys¥   s[   è è € ð œ×/Ò/°vÐ/Ñ>Ô>ð 	ð 	ð 	ð 	ð 	ð 	ð 	�#ØˆIˆIˆIˆIˆIð ?Ð>Ð>s   ž+)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   Ústrr   r   r
   r   Úbytesr   r   Úlistr(   r/   Útupler6   r;   r?   rC   r   rG   r   rI   r   r   r   r   r      s%  € € € € € ð$ð $ðL5à˜˜c˜Ô"ð5ð ˜q˜c 3˜hÔ'ð5ð # A 3¨ :Ô.ð	5ð
 % c U¨A XÔ.ð5ð 
ð5ð 5ð 5ð 5ð(
˜ !œð 
¨¨a°$©h¬ð 
ð 
ð 
ð 
ð"
 ¨¤ð 
°°Q¸±X´ð 
ð 
ð 
ð 
ð"
' H¨U°1°a°4¬[Ô$9ð 
'¸dð 
'ð 
'ð 
'ð 
'ð
.¨8°E¸!¸Q¸$´KÔ+@ð 
.ÀTð 
.ð 
.ð 
.ð 
.ð)˜H QœKð )¨Dð )ð )ð )ð )ð0 8¨A¤;ð 0°4ð 0ð 0ð 0ð 0ð "ð8ð 8ð 8ð �d‘
ð8ð 
�!Œ�x ”}Ñ	$ð	8ð 8ð 8ð 8ð( "ðð ð ð �d‘
ðð 
�qÔ	˜M¨#Ô.Ñ	.ð	ð ð ð ð ð r   r   N)Úcollections.abcr   r   r   r   Útypingr   r   Úlangchain_core.storesr	   r
   r   r   r   r   r   ú<module>rU      sÅ   ðØ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ Gðð ð ð ð ð ð ð ð
 ,Ð +Ð +Ð +Ð +Ð +à€GˆC�L„L€Ø€GˆC�L„L€ðhð hð hð hð h˜ 1 a 4œñ hô hð hð hð hr   