Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
runtime.cpython-313.pyc127 linesDownload Raw Back to __pycache__
1�

2��jO(�3��SSKJr SSKJr SSKJrJrJr SSKJ	r	J4r5Jr SSKJ
r
 SSKJr SSKJrJr SSKJrJr SS	KJr SS6KJrJr SSKJr Sr\"S
S
S9"SS55r\"S
S
S9"SS55r"SS5r S Sjr!S!Sjr""SS\\7\SS9r#\"S"0\D6"SS\8\55r$\$"SS\!\"SSSS9r%S#S$Sjjr&g)%�)�annotations)�Callable)�	dataclass�field�replace)�Any�Generic�cast)�	BaseStore)�BaseUser)�	TypedDict�Unpack)�CONF�CONFIG_KEY_RUNTIME)�9get_config)�10_DC_KWARGS�StreamWriter)�ContextT)r�
ExecutionInfo�11RunControl�Runtime�12ServerInfo�get_runtimeT)�frozen�slotsc��\rSrSr%SrS\S'S\S'S\S'SrS\S	'SrS\S13'SrS\S
'Sr	S\S'SSjr14Srg)r�zORead-only execution info/metadata for the execution of current thread/run/node.�str�
checkpoint_id�
checkpoint_ns�task_idN�15str | None�	thread_id�run_id��int�node_attemptzfloat | None�node_first_attempt_timec��[U40UD6$)zAReturn a new execution info object with selected fields replaced.�r��self�	overridess  �WD:\code\apps\devtools\python\user_packages\Python313\site-packages\langgraph/runtime.py�patch�ExecutionInfo.patch7s���t�)�y�)�)��)r-r�returnr)�__name__�16__module__�__qualname__�__firstlineno__�__doc__�__annotations__r#r$r'r(r/�__static_attributes__r2r1r.rrsc��Y���6���=�
�L�0� �I�z� �H��F�J��A��L�#��<�,0��\�0�F�*r1rc�@�\rSrSr%SrS\S'S\S'SrS\S'S	rg)17r�<zmMetadata injected by LangGraph Server. None when running open-source LangGraph without LangSmith deployments.r�assistant_id�graph_idNzBaseUser | None�userr2)r4r5r6r7r8r9r?r:r2r1r.rr<s%��w���5��M�1� �D�/� �r1rc�\�\rSrSrSrSrS	SjrS18SSjjr\SSj5r	\S
Sj5r19Srg)r�OavRun-scoped control surface for cooperative draining.20 21Intended for a single graph run. Create a fresh `RunControl` per run;22reusing a control after `request_drain()` leaves it drained.23 24Safe to call from any thread: the drain request is represented by a25single attribute write, so no lock is needed for this signal.26If more mutable state is added here, add synchronization.27��
_drain_reasonc��SUlg�NrB�r,s r.�__init__�RunControl.__init__\s28��)-��r1c��XlgrErB)r,�reasons  r.�
request_drain�RunControl.request_drain_s��#�r1c��URSL$rErBrFs r.�drain_requested�RunControl.drain_requestedbs���!�!��-�-r1c��UR$rErBrFs r.�drain_reason�RunControl.drain_reasonfs���!�!�!r1N�r3�None)�shutdown)rJrr3rT�r3�bool�r3r")r4r5r6r7r8�	__slots__rGrK�propertyrNrQr:r2r1r.rrOs@���#�I�.�$��.��.��"��"r1rc��grEr2)�_s r.�_no_op_stream_writerr]ks��#r1c��grEr2r2r1r.�_no_op_heartbeatr_ns��r1c�f�\rSrSr%S\S'S\S'S\S'S\S	'S29\S'S\S
'S\S'S\S'Srg)�_RuntimeOverrides�qr�context�BaseStore | None�storer�
stream_writer�Callable[[], None]�	heartbeatr�previousr�execution_info�ServerInfo | None�server_info�RunControl | None�controlr2N)r4r5r6r7r9r:r2r1r.raraqs1��
������!�!��M�!�!�"�"�
�r1raF)�totalc�(�\rSrSr%Sr\"SS9rS\S'\"SS9rS\S'\"\	S9r30S	\S31'\"\S9rS\S'\"SS9r
S
\S'\"SS9rS\S'\"SS9rS\S'\"SS9rS\S'SSjrSSjrSSjr\SSj5r\SSj5rSrg) r�|a�Convenience class that bundles run-scoped context and other runtime utilities.32 33This class is injected into graph nodes and middleware. It provides access to34`context`, `store`, `stream_writer`, `previous`, and `execution_info`.35 36!!! note "Accessing `config`"37 38    `Runtime` does not include `config`. To access `RunnableConfig`, you can inject39    it directly by adding a `config: RunnableConfig` parameter to your node function40    (recommended), or use `get_config()` from `langgraph.config`.41 42!!! note43    `ToolRuntime` (from `langgraph.prebuilt`) is a subclass that provides similar44    functionality but is designed specifically for tools. It shares `context`, `store`,45    and `stream_writer` with `Runtime`, and adds tool-specific attributes like `config`,46    `state`, and `tool_call_id`.47 48!!! version-added "Added in version v0.6.0"49 50Example:51 52```python53from typing import TypedDict54from langgraph.graph import StateGraph55from dataclasses import dataclass56from langgraph.runtime import Runtime57from langgraph.store.memory import InMemoryStore58 59 60@dataclass61class Context:  # (1)!62    user_id: str63 64 65class State(TypedDict, total=False):66    response: str67 68 69store = InMemoryStore()  # (2)!70store.put(("users",), "user_123", {"name": "Alice"})71 72 73def personalized_greeting(state: State, runtime: Runtime[Context]) -> State:74    '''Generate personalized greeting using runtime context and store.'''75    user_id = runtime.context.user_id  # (3)!76    name = "unknown_user"77    if runtime.store:78        if memory := runtime.store.get(("users",), user_id):79            name = memory.value["name"]80 81    response = f"Hello {name}! Nice to see you again."82    return {"response": response}83 84 85graph = (86    StateGraph(state_schema=State, context_schema=Context)87    .add_node("personalized_greeting", personalized_greeting)88    .set_entry_point("personalized_greeting")89    .set_finish_point("personalized_greeting")90    .compile(store=store)91)92 93result = graph.invoke({}, context=Context(user_id="user_123"))94print(result)95# > {'response': 'Hello Alice! Nice to see you again.'}96```97 981. Define a schema for the runtime context.992. Create a store to persist memories and other information.1003. Use the runtime context to access the `user_id`.101N)�defaultrrcrdrerrfrgrhrrizExecutionInfo | Nonerjrkrlrmrnc�.�[UR=(d URUR=(d URUR[LaUROURUR102[LaUR103OUR104URcUROURUR=(d URUR=(d URUR=(d URS9$)z{Merge two runtimes together.105 106If a value is not provided in the other runtime, the value from the current runtime is used.107)rcrerfrhrirjrlrn)rrcrerfr]rhr_rirjrlrn)r,�others  r.�merge�
Runtime.merge�s���108��M�M�1�T�\�\��+�+�+�����"�"�*>�>� �-�-��#�#����&6�6��o�o����&+�n�n�&<�T�]�]�%�.�.� �/�/�F�4�3F�3F��)�)�=�T�-=�-=��M�M�1�T�\�\�
109�
	110r1c��[U40UD6$)z@Replace the runtime with a new runtime with the given overrides.r*r+s  r.�override�Runtime.overrides���t�)�y�)�)r1c�~�URc
Sn[U5e[UURR"S0UD6S9$)zBReturn a new runtime with selected execution_info fields replaced.z2Cannot patch execution_info before it has been set)rjr2)rj�RuntimeErrorrr/)r,r-�msgs   r.�patch_execution_info�Runtime.patch_execution_info111sE�����&�F�C��s�#�#����.�.�4�4�A�y�A�112�	113r1c�L�URbURR$S$)NF)rnrNrFs r.rN�Runtime.drain_requesteds ��/3�|�|�/G�t�|�|�+�+�R�U�Rr1c�L�URbURR$S$rE)rnrQrFs r.rQ�Runtime.drain_reasons ��,0�L�L�,D�t�|�|�(�(�N�$�Nr1r2)rt�Runtime[ContextT]r3r�)r-z#Unpack[_RuntimeOverrides[ContextT]]r3r�)r-rr3r�rVrX)r4r5r6r7r8rrcr9rer]rfr_rhrirjrlrnrurxr}rZrNrQr:r2r1r.rr|s���F�P�d�+�G�X�+�5�$�D�1�E��1�C�"'�0D�"E�M�<�E�4�$)�2B�$C�I�!�C���$�'�H�c�'��114,1��+>�N�(�>�2�&+�4�%8�K�"�8�w�!&�t�!4�G�
�4��115�(*�>�*�	�*�116��S��S��O��Or1rN)rcrerfrhrirjrnc�x�[[[[5[R[55nU$)z�Get the runtime for the current graph run.117 118Args:119    context_schema: Optional schema used for type hinting the return type of the runtime.120 121Returns:122    The runtime for the current graph run.123)r124rrrr�getr)�context_schema�runtimes  r.rr(s-���7�8�$�j�l�4�&8�&<�&<�=O�&P�Q�G��Nr1)r\rr3rTrSr2rE)r�ztype[ContextT] | Noner3r�)'�125__future__r�collections.abcr�dataclassesrrr�typingrr	r126�langgraph.store.baser�langgraph_sdk.auth.typesr�typing_extensionsr
r�langgraph._internal._constantsrr�langgraph.configr�langgraph.typesrr�langgraph.typingr�__all__rrrr]r_rar�DEFAULT_RUNTIMErr2r1r.�<module>r�s���"�$�1�1�%�%�*�-�/�C�'�4�%����$�d�#�*�*�$�*�B�$�d�#���$��$"�"�8.�$��	�7�8�#4�E����Z��]O�g�h��]O��]O�@��127�&��
�����r1
codekingpro/portable-devtools · Team Ai