
    <i                       S SK Jr  S SKJrJrJr  S SKJrJrJ	r	  S SK
Jr  S SKJrJr  S SKJrJr  S SKJr  S SKJrJr  S S	KJr  S
rSS jr " S S\\\   SS9r\" S0 \D6 " S S\\   5      5       r\" SS\SS9rSSS jjrg)    )annotations)	dataclassfieldreplace)AnyGenericcast)	BaseStore)	TypedDictUnpack)CONFCONFIG_KEY_RUNTIME)
get_config)
_DC_KWARGSStreamWriter)ContextT)Runtimeget_runtimec                    g N )_s    a/home/dmtnaga/Documents/work/airagagent/rag_env/lib/python3.13/site-packages/langgraph/runtime.py_no_op_stream_writerr      s    #    c                  >    \ rS rSr% S\S'   S\S'   S\S'   S\S	'   S
rg)_RuntimeOverrides   r   contextBaseStore | Nonestorer   stream_writerr   previousr   N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r   r   r   r   r      s    Mr   r   F)totalc                      \ rS rSr% Sr\" SS9rS\S'    \" SS9rS\S'    \" \	S9r
S	\S
'    \" SS9rS\S'    SS jr    SS jrSrg)r      a  Convenience class that bundles run-scoped context and other runtime utilities.

!!! 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                   [        UR                  =(       d    U R                  UR                  =(       d    U R                  UR                  [        La  UR                  OU R                  UR
                  =(       d    U R
                  S9$ )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   mergeRuntime.mergeg   sd    
 MM1T\\+++""*>>  --##^^4t}}
 	
r   c                    [        U 40 UD6$ )z@Replace the runtime with a new runtime with the given overrides.)r   )r0   	overridess     r   overrideRuntime.overrideu   s     t)y))r   r   )r1   Runtime[ContextT]returnr8   )r5   z#Unpack[_RuntimeOverrides[ContextT]]r9   r8   )r$   r%   r&   r'   __doc__r   r   r(   r!   r   r"   r#   r2   r6   r)   r   r   r   r   r      st    7r d+GX+5 $D1E1C"'0D"EM<E4$'Hc'

*>*	*r   r   Nr/   c                x    [        [        [           [        5       [           R                  [        5      5      nU$ )zGet 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-     78$jl4&8&<&<=O&PQGNr   )r   r   r9   Noner   r   )r=   ztype[ContextT] | Noner9   r8   )
__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>rK      s    " 1 1 % % * / C ' 4 %
$ .	78#4E  Z]*gh ]* ]*@ 
&	r   