pyc • Lines: 131�
�Y�j� � �j � d Z ddlZddlZddlZddlmZ ddlmZ G d� d� Z d� Z
G d� d � Z e� Zi Z
i Zi Zi Zi Z ej$ � Z e� Z e� Zi Z ej$ � Zd
Zi Z ej$ � Z ej$ � Z ej$ � ZdZdd
d�Zg g d�Z ej$ � ej$ � d�Z!e!jE � D � �ci c] \ } }| ejF |� �� c}} Z$ddd�Z% ejL � Z' ejL � Z( ed�� ee�� d�Z) ed�� ed�� d�Z*i Z+dZ,dZ-dZ. ej � Z/ ej � Z0i Z1ddd�Z2dZ3dZ4dZ5dZ6dZ7dZ8dZ9 e:e9dz � Z;dZ<dZ=dZ>dZ?yc c}} w )a� Shared application state and the entrypoint proxy.
The chat engine's implementation lives in the :mod:`server.features` package,
but the entrypoint module (``chat-webui.py``) remains the single owner of every
shared value: containers, scalar flags, constants, config values and the
cross-cutting helpers. Feature modules resolve those names at *call time*
through the ``M`` proxy registered here, which simply forwards attribute reads
and writes to the entrypoint module.
This indirection is what keeps per-test monkeypatching working. The test-suite
patches ``chat-webui.<name>`` (functions, containers, scalars, stdlib modules)
and expects every feature module to observe those patches, so no feature module
may bind a shared name at import time.
� N)�ThreadPoolExecutor)�CPU_PARALLEL_SLOTSc � � e Zd ZdZdZy)� _Registryz-Holds the single entrypoint module reference.N)�__name__�
__module__�__qualname__�__doc__�
entrypoint� � �server/features/state.pyr r s
� �7��Jr
r c � � | t _ y)z?Point the ``M`` proxy at the module that owns the shared state.N)r r )�modules r �register_entrypointr s
� �!�I�r
c � � e Zd ZdZd� Zd� Zy)�_Proxyz=Forward attribute access to the registered entrypoint module.c �Z � t j }|�t d|� �� �t ||� S )Nz@no entrypoint registered yet; import chat-webui.py before using )r r �AttributeError�getattr)�self�name�eps r �__getattr__z_Proxy.__getattr__$ s: � �
�
!�
!��
�:� �R�SW�RX�Y��
� �r�4� � r
c �D � t j j ||� y )N)r r �__setattr__)r r �values r r z_Proxy.__setattr__, s � ����(�(��u�5r
N)r r r r
r r r r
r r r ! s � �G�!�6r
r �x � �
�2 )�default�research)�gpu�cpu� )�max_workers� �unloadedFi ` gffffff�?�Z �K �_ �F )@r
�queue�_queue� threading�time�concurrent.futuresr �
server.configr r r r �M�sessions�
sessions_meta�tasks�shares�_active_tokens�Lock�_tokens_lock�set�
_agent_tokens�_agent_users�_user_last_seen�_user_last_seen_lock�ACTIVE_WINDOW_SECONDS�_effective_contexts�_effective_contexts_lock�_model_transition_lock�
_data_lock�MAX_QUEUE_SIZE�MAX_TOOL_ROUNDS�_task_queues�_queue_locks�items� Condition�_queue_conds�_current_task_ids�Queue�_event_queue�_image_queue�
_llm_pools�_tool_pools�_location_events�model_status�_cpu_model_status� _last_tps�
_last_llm_use�_cpu_last_llm_use�_slot_checkpoints�_slot_kv_dirty�_client_location�_overheated� _gpu_temp�_ram_evacuating�_users_cache�_users_cache_time�MAX_INPUT_TOKENS�int�AUTO_COMPACT_THRESHOLD�TEMP_THRESHOLD_ON�TEMP_THRESHOLD_OFF�RAM_EVAC_THRESHOLD�RAM_RESUME_THRESHOLD)�mode�locks 00r �<module>rj s# ��
� � � � 1� ,�� �"�
6� 6� �H�� ���
�
�� �����y�~�~�����
��u��
��%�y�~�~�'� �
� �� �)�9�>�>�+� �'����)� �
�Y�^�^�
�
��� !�b�1�� �"�%��%�y�~�~�'�� ���0@�A��BN�BT�BT�BV�W�J�D�$��)�i�)�)�$�/�/�W�� ��.� ��v�|�|�~�� �v�|�|�~�� (�A�6�?Q�^p�?q�
r�
�(�Q�7�@R�_`�@a�b��� � ��� �� ��� � ��
��D�I�I�K� � � � �u�-��� ���� ������ � � ��-��3�4� � � �� �� �� ��q Xs �.F/