Ë
    fœiÓ  ã                  ó  — d dl mZ d dlmZmZmZ d dlmZmZm	Z	 d dl
mZ d dlmZmZ d dlmZmZ d dlmZ d dlmZmZ d d	lmZ d
Zdd„Z G d„ deee   d¬«      Z edi e¤Ž G d„ dee   «      «       Z edded¬«      Zddd„Zy)é    )Úannotations)Ú	dataclassÚfieldÚreplace)ÚAnyÚGenericÚcast)Ú	BaseStore)Ú	TypedDictÚUnpack)ÚCONFÚCONFIG_KEY_RUNTIME)Ú
get_config)Ú
_DC_KWARGSÚStreamWriter)ÚContextT)ÚRuntimeÚget_runtimec                 ó   — y ©N© )Ú_s    úf/var/www/html/Whatsapp_Customer_Support_Chatbot/venv/lib/python3.12/site-packages/langgraph/runtime.pyÚ_no_op_stream_writerr      s   � ó    c                  ó6   — e Zd ZU ded<   ded<   ded<   ded<   y	)
Ú_RuntimeOverridesr   ÚcontextúBaseStore | NoneÚstorer   Ústream_writerr   ÚpreviousN)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__r   r   r   r   r      s   … ØÓØÓØÓØ„Mr   r   F)Útotalc                  ó¢   — e Zd ZU dZ ed¬«      Zded<   	  ed¬«      Zded<   	  ee¬«      Z	ded	<   	  ed¬«      Z
d
ed<   	 dd„Z	 	 	 	 dd„Zy)r   at	  Convenience class that bundles run-scoped context and other runtime utilities.

    This class is injected into graph nodes and middleware. It provides access to
    `context`, `store`, `stream_writer`, and `previous`.

    !!! note "Accessing `config`"

        `Runtime` does not include `config`. To access `RunnableConfig`, you can inject
        it directly by adding a `config: RunnableConfig` parameter to your node function
        (recommended), or use `get_config()` from `langgraph.config`.

    !!! note
        `ToolRuntime` (from `langgraph.prebuilt`) is a subclass that provides similar
        functionality but is designed specifically for tools. It shares `context`, `store`,
        and `stream_writer` with `Runtime`, and adds tool-specific attributes like `config`,
        `state`, and `tool_call_id`.

    !!! version-added "Added in version v0.6.0"

    Example:

    ```python
    from typing import TypedDict
    from langgraph.graph import StateGraph
    from dataclasses import dataclass
    from langgraph.runtime import Runtime
    from langgraph.store.memory import InMemoryStore


    @dataclass
    class Context:  # (1)!
        user_id: str


    class State(TypedDict, total=False):
        response: str


    store = InMemoryStore()  # (2)!
    store.put(("users",), "user_123", {"name": "Alice"})


    def personalized_greeting(state: State, runtime: Runtime[Context]) -> State:
        '''Generate personalized greeting using runtime context and store.'''
        user_id = runtime.context.user_id  # (3)!
        name = "unknown_user"
        if runtime.store:
            if memory := runtime.store.get(("users",), user_id):
                name = memory.value["name"]

        response = f"Hello {name}! Nice to see you again."
        return {"response": response}


    graph = (
        StateGraph(state_schema=State, context_schema=Context)
        .add_node("personalized_greeting", personalized_greeting)
        .set_entry_point("personalized_greeting")
        .set_finish_point("personalized_greeting")
        .compile(store=store)
    )

    result = graph.invoke({}, context=Context(user_id="user_123"))
    print(result)
    # > {'response': 'Hello Alice! Nice to see you again.'}
    ```

    1. Define a schema for the runtime context.
    2. Create a store to persist memories and other information.
    3. Use the runtime context to access the `user_id`.
    N)Údefaultr   r   r   r    r   r!   r   r"   c                ó  — t        |j                  xs | j                  |j                  xs | j                  |j                  t        ur|j                  n| j                  |j
                  €| j
                  ¬«      S |j
                  ¬«      S )z‹Merge two runtimes together.

        If a value is not provided in the other runtime, the value from the current runtime is used.
        ©r   r    r!   r"   )r   r   r    r!   r   r"   )ÚselfÚothers     r   ÚmergezRuntime.mergev   sy   € ô
 Ø—M‘MÒ1 T§\¡\Ø—+‘+Ò+ §¡à×"Ñ"Ô*>Ñ>ð  ×-Ò-à×#Ñ#Ø&+§n¡nÐ&<�T—]‘]ô
ð 	
ð CHÇ.Á.ô
ð 	
r   c                ó   — t        | fi |¤ŽS )z@Replace the runtime with a new runtime with the given overrides.)r   )r,   Ú	overridess     r   ÚoverridezRuntime.override„   s   € ô �tÑ)˜yÑ)Ð)r   )r-   úRuntime[ContextT]Úreturnr2   )r0   z#Unpack[_RuntimeOverrides[ContextT]]r3   r2   )r#   r$   r%   Ú__doc__r   r   r&   r    r   r!   r"   r.   r1   r   r   r   r   r      su   … ñFñP  dÔ+€GˆXÓ+ð5ñ $¨DÔ1€EÐÓ1ØCá"'Ð0DÔ"E€M�<ÓEØ4á $Ô'€HˆcÓ'ðó

ð*Ø>ð*à	ô*r   r   Nr+   c                óx   — t        t        t           t        «       t           j                  t        «      «      }|S )zÕGet the runtime for the current graph run.

    Args:
        context_schema: Optional schema used for type hinting the return type of the runtime.

    Returns:
        The runtime for the current graph run.
    )r	   r   r   r   r   Úgetr   )Úcontext_schemaÚruntimes     r   r   r   “   s-   € ô ”7œ8Ñ$¤j£l´4Ñ&8×&<Ñ&<Ô=OÓ&PÓQ€GØ€Nr   )r   r   r3   ÚNoner   r   )r7   ztype[ContextT] | Noner3   r2   )Ú
__future__r   Údataclassesr   r   r   Útypingr   r   r	   Úlanggraph.store.baser
   Útyping_extensionsr   r   Úlanggraph._internal._constantsr   r   Úlanggraph.configr   Úlanggraph.typesr   r   Úlanggraph.typingr   Ú__all__r   r   r   ÚDEFAULT_RUNTIMEr   r   r   r   ú<module>rE      sŽ   ðÝ "ç 1Ñ 1ß %Ñ %å *ß /ç CÝ 'ß 4Ý %à
$€ó .ô˜	 7¨8Ñ#4¸Eõ ñ ÑˆZÑôl*ˆg�hÑó l*ó ðl*ñ^ ØØ
Ø&Øô	€õr   