Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��j�����SSKJr SSKJrJrJr SSKJr SSKJ	r	 SSK3Jr SSKJ
r
Jr SSKJr Sr"S	S4\5r"SS\5r\\-rS
S
S
SSS.SSjjrSS.SSjjrSSjrg
)�)�annotations)�Any�Literal�cast)�uuid4)�5AnyMessage)�	TypedDict)�6get_config�get_stream_writer)�CONF)�	UIMessage�RemoveUIMessage�AnyUIMessage�push_ui_message�delete_ui_message�ui_message_reducerc�L�\rSrSr%SrS\S'S\S'S\S'S\S	'S\S7'Srg)
r
�a�A message type for UI updates in LangGraph.8 9This TypedDict represents a UI message that can be sent to update the UI state.10It contains information about the UI component to render and its properties.11 12Attributes:13    type: Literal type indicating this is a UI message.14    id: Unique identifier for the UI message.15    name: Name of the UI component to render.16    props: Properties to pass to the UI component.17    metadata: Additional metadata about the UI message.18z
Literal['ui']�type�str�id�name�dict[str, Any]�props�metadata�N��__name__�19__module__�__qualname__�__firstlineno__�__doc__�__annotations__�__static_attributes__r��XD:\code\apps\devtools\python\user_packages\Python313\site-packages\langgraph/graph/ui.pyr
r
s%������G�20
�I����r%r
c�.�\rSrSr%SrS\S'S\S'Srg)	r�+a"A message type for removing UI components in LangGraph.21 22This TypedDict represents a message that can be sent to remove a UI component23from the current state.24 25Attributes:26    type: Literal type indicating this is a remove-ui message.27    id: Unique identifier of the UI message to remove.28zLiteral['remove-ui']rrrrNrrr%r&rr+s������Gr%rN�uiF)rr�message�	state_key�mergec��SSKJn [5n[5n	Sn29U(aJ[	U[305(aSU;aUR
S5n31O[US5(aURn32SU=(d [[55UUUU	R
SS5U	R
SS5U	R
SS5S	.U=(d 0EU33(aS34U350O0ES.nU"U5 U(aU	[U"X[4/5 U$)amPush a new UI message to update the UI state.36 37This function creates and sends a UI message that will be rendered in the UI.38It also updates the graph state with the new UI message.39 40Args:41    name: Name of the UI component to render.42    props: Properties to pass to the UI component.43    id: Optional unique identifier for the UI message.44        If not provided, a random UUID will be generated.45    metadata: Optional additional metadata about the UI message.46    message: Optional message object to associate with the UI message.47    state_key: Key in the graph state where the UI messages are stored.48    merge: Whether to merge props with existing UI message (True) or replace49        them (False).50 51Returns:52    The created UI message.53 54Example:55    ```python56    push_ui_message(57        name="component-name",58        props={"content": "Hello world"},59    )60    ```61 62r��CONFIG_KEY_SENDNrr)�run_id�tags�run_name)r,r0r1r�63message_id)rrrrr)�langgraph._internal._constantsr/rr64�65isinstance�dict�get�hasattrrrrr)rrrrr*r+r,r/�writer�configr3�evts            r&rr=s���L?�
�
 �F�
�\�F��J���g�t�$�$���� ���T�*�J�
�W�d�
#�
#� ���J��� �C���L�����j�j��4�0��J�J�v�t�,��J�J�z�4�0�	66�67�~�2�68�.8��j�)�R�
69�
�C��3�K���t��_�%�	�'7�&8�9��Jr%)r+c�|�SSKJn [5n[5nSUS.nU"U5 U[U"X4/5 U$)a�Delete a UI message by ID from the UI state.70 71This function creates and sends a message to remove a UI component from the current state.72It also updates the graph state to remove the UI message.73 74Args:75    id: Unique identifier of the UI component to remove.76    state_key: Key in the graph state where the UI messages are stored. Defaults to "ui".77 78Returns:79    The remove UI message.80 81Example:82    ```python83    delete_ui_message("message-123")84    ```85 86rr.�	remove-ui)rr)r4r/rr87r)rr+r/r9r:r;s      r&rr�sC��&?�
�
 �F�
�\�F�$/�r�:�C�88�3�K�89�4�L��!�I�#3�"4�5��Jr%c�p�[U[5(dU/n[U[5(dU/nUR5n[U5VVs0sHup4UR	S5U_M nnn[5nUGHnUR	S5nUR	U5=n	b�UR	S5S:XaUR
U5 MQURU5 [[U5R	S05R	SS5(a#X)n90UR5n0U91SEUSEUS'XrU	'M�UR	S5S:Xa[SUS	35e[U5XX'URU5 GM UVs/sHoDR	S5U;dMUPM nnU$s snnfs snf)92a�Merge two lists of UI messages, supporting removing UI messages.93 94This function combines two lists of UI messages, handling both regular UI messages95and `remove-ui` messages. When a `remove-ui` message is encountered, it removes any96UI message with the matching ID from the current state.97 98Args:99    left: First list of UI messages or single UI message.100    right: Second list of UI messages or single UI message.101 102Returns:103    Combined list of UI messages with removals applied.104 105Example:106    ```python107    messages = ui_message_reducer(108        [{"type": "ui", "id": "1", "name": "Chat", "props": {}}],109        {"type": "remove-ui", "id": "1"},110    )111    ```112 113rrr=rr,FrzCAttempting to delete an UI message with an ID that doesn't exist ('z'))
r5�list�copy�	enumerater7�set�add�discardrr
�114ValueError�len�append)�left�right�merged�i�m�merged_by_id�
ids_to_remove�msg�msg_id�existing_idx�prev_msgs           r&rr�s���4�d�D�!�!��v���e�T�"�"�����Y�Y�[�F�/8��/@�A�/@�t�q�A�E�E�$�K��N�/@�L�A��E�M���������(�,�,�V�4�4�L�A��w�w�v��+�-��!�!�&�)��%�%�f�-��	�3�'�+�+�J��;�?�?���O�O�%�3�H��(�(�*�C�#H�h�w�&7�#H�3�w�<�#H�C��L�'*�|�$��w�w�v��+�-� �Y�Z`�Ya�ac�d���$'�v�;�L� ��M�M�#��-�0 �
D��A�5�5��;�m�#C�a��F�
D��M��9B��6Es�F-�F3�#F3)rrrrr�115str | Nonerzdict[str, Any] | Noner*zAnyMessage | Noner+rSr,�bool�returnr
)rrr+rrUr)rH�!list[AnyUIMessage] | AnyUIMessagerIrVrUzlist[AnyUIMessage])�116__future__r�typingrrr�uuidr�langchain_core.messagesr�typing_extensionsr	�langgraph.configr117r�langgraph.constantsr�__all__r
rrrrrrr%r&�<module>r_s���"�%�%��.�'�:�$����	��*�i���?�*���&*�!%� ��E�118
�E��E�	�	E�119$�E��
E��E��E��E�P48��@>�120+�>�,�>��>r%
codekingpro/portable-devtools · Team Ai