§
    ™Štjx  ã                  ó8  — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	m
Z
mZmZ  ed¦  «        Zed         Z	 ddlmZ dd	lmZ n# e$ r d
Zd
ZY nw xY w	 ddlmZ ddlmZ n!# e$ r d
Z G d„ de
e         ¦  «        ZY nw xY wg d¢Zd%d„Zd
dœd&d„Zd
d
d
dœd'd$„Zd
S )(z»Key/value cache for use inside LangGraph deployments.

Thin wrapper around ``langgraph_api.cache``.
Values must be JSON-serializable (dicts, lists, strings, numbers, booleans,
``None``).
é    )Úannotations)Ú	AwaitableÚCallable)Ú	timedelta)ÚAnyÚGenericÚLiteralÚTypeVarÚT)ÚmissÚfreshÚstaleÚexpired)Ú	cache_get)Ú	cache_setN)Ú	SWRResult)Úswrc                  ó4   — e Zd ZU dZded<   ded<   	 d
dd„Zd	S )r   z'Result wrapper returned by :func:`swr`.r   ÚvalueÚCacheStatusÚstatus.Úreturnc              ƒ  ó
   K  — dS )z&Update or revalidate the cached value.N© )Úselfr   s     úQ/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langgraph_sdk/cache.pyÚmutatezSWRResult.mutate+   s   è è € ð
 ˆCó    N).)r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   r   r   r   r   %   sO   € € € € € € Ø5Ð5àˆˆ‰ØÐÐÑð ð	ð 	ð 	ð 	ð 	ð 	ð 	r   r   )r   r   r   r   ÚkeyÚstrr   ú
Any | Nonec              ƒ  ó\   K  — t           €t          d¦  «        ‚t          | ¦  «        ƒ d{V —†S )z¯Get a value from the cache.

    Returns the deserialized value, or ``None`` if the key is missing or expired.

    Requires Agent Server runtime version 0.7.29 or later.
    NúyCache is only available server-side within the LangGraph Agent Server (https://docs.langchain.com/langsmith/deployments).)Ú
_cache_getÚRuntimeError)r$   s    r   r   r   ;   sF   è è € õ ÐÝðBñ
ô 
ð 	
õ ˜C‘”Ð Ð Ð Ð Ð Ð Ð r   )Úttlr   r   r+   útimedelta | NoneÚNonec             ƒ  ód   K  — t           €t          d¦  «        ‚t          | ||¦  «        ƒ d{V —† dS )a%  Set a value in the cache.

    Args:
        key: The cache key.
        value: The value to cache (must be JSON-serializable).
        ttl: Optional time-to-live. Capped at 1 day; ``None`` or zero
            defaults to 1 day.

    Requires Agent Server runtime version 0.7.29 or later.
    Nr(   )Ú
_cache_setr*   )r$   r   r+   s      r   r   r   J   sR   è è € õ ÐÝðBñ
ô 
ð 	
õ �S˜% Ñ
%Ô
%Ð%Ð%Ð%Ð%Ð%Ð%Ð%Ð%Ð%r   ©Ú	fresh_forÚmax_ageÚmodelÚloaderúCallable[[], Awaitable[T]]r1   r2   r3   útype[T] | NoneúSWRResult[T]c             ƒ  ó¬   K  — t           €t          d¦  «        ‚|€t          d¦  «        }|€t          d¬¦  «        }t          | ||||¬¦  «        ƒ d{V —†S )a  Load a cached value using stale-while-revalidate semantics.

    This helper is server-side only and is intended for caching internal async
    dependencies such as auth or metadata lookups.

    Args:
        key: Cache key.
        loader: Async callable that fetches the value on miss/revalidation.
        fresh_for: How long a cached value is considered fresh (no revalidation).
            Defaults to ``timedelta(0)`` so every access triggers a background
            revalidate while still returning the cached value instantly. Values
            above :data:`MAX_CACHE_TTL` are clamped to the backend maximum.
        max_age: Total lifetime of a cached entry. After this, the next access
            blocks on the loader. Defaults to :data:`MAX_CACHE_TTL` (24 h by
            default). Values above :data:`MAX_CACHE_TTL` are clamped to the
            backend maximum.
        model: Optional Pydantic model class. When provided, values are
            serialized via ``model_dump(mode="json")`` before storage and
            deserialized via ``model.model_validate()`` on read.

    Returns:
        An :class:`SWRResult` with ``.value``, ``.status``, and an async
        ``.mutate()`` method.

    Semantics:
    - cache miss: await ``loader()``, store the value, return it
    - fresh hit (age < fresh_for): return the cached value
    - stale hit (fresh_for <= age < max_age): return the cached value
      immediately and trigger a best-effort background refresh
    - expired (age >= max_age): await ``loader()``, store the value, return it
    Nr(   r   é   )Údaysr0   )Ú_api_swrr*   r   )r$   r4   r1   r2   r3   s        r   r   r   ]   s�   è è € õN ÐÝðBñ
ô 
ð 	
ð ÐÝ˜a‘L”Lˆ	Ø€Ý Ð#Ñ#Ô#ˆÝØˆV˜y°'Àðñ ô ð ð ð ð ð ð ð r   )r$   r%   r   r&   )r$   r%   r   r   r+   r,   r   r-   )r$   r%   r4   r5   r1   r,   r2   r,   r3   r6   r   r7   )r"   Ú
__future__r   Úcollections.abcr   r   Údatetimer   Útypingr   r   r	   r
   r   r   Úlanggraph_api.cacher   r)   r   r/   ÚImportErrorr   r   r;   Ú__all__r   r   r   ú<module>rC      sû  ððð ð #Ð "Ð "Ð "Ð "Ð "à /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ø Ð Ð Ð Ð Ð Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1à€GˆC�L„L€àÐ9Ô:€ð	ðð ð ð ð ð ðð ð ð ð ð ð øð ð ð ð Ø€JØ€J€J€Jðøøøð
Ø-Ð-Ð-Ð-Ð-Ð-Ø3Ð3Ð3Ð3Ð3Ð3Ð3øàð ð ð Ø€Hðð ð ð ð �G˜A”Jñ ô ð ð ð ðøøøð"ð ð €ð!ð !ð !ð !ð FJð &ð &ð &ð &ð &ð &ð. #'Ø $Ø ð2ð 2ð 2ð 2ð 2ð 2ð 2ð 2s#   ·A Á	AÁAÁA! Á!A?Á>A?