📄 state.cpython-312.pyc
/home/palash/git/local-ai/server/features/__pycache__/state.cpython-312.pyc
Language: pyc • Lines: 131
�

�Y�j���j�dZddlZddlZddlZddlmZddlmZGd�d�Z	d�Z
Gd�d	�Ze�ZiZ
iZiZiZiZej$�Ze�Ze�ZiZej$�Zd
ZiZej$�Zej$�Zej$�ZdZdd
d�Zggd�Z ej$�ej$�d�Z!e!jE�D��cic]\}}|ejF|���c}}Z$ddd�Z%ejL�Z'ejL�Z(ed��ee��d�Z)ed��ed��d�Z*iZ+dZ,dZ-dZ.ej�Z/ej�Z0iZ1ddd�Z2dZ3dZ4dZ5dZ6dZ7dZ8dZ9e:e9dz�Z;dZ<dZ=dZ>dZ?ycc}}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��eZdZdZdZy)�	_Registryz-Holds the single entrypoint module reference.N)�__name__�
__module__�__qualname__�__doc__�
entrypoint���server/features/state.pyrrs
��7��Jr
rc��|t_y)z?Point the ``M`` proxy at the module that owns the shared state.N)rr)�modules r�register_entrypointrs
��!�I�r
c��eZdZdZd�Zd�Zy)�_Proxyz=Forward attribute access to the registered entrypoint module.c�Z�tj}|�td|����t||�S)Nz@no entrypoint registered yet; import chat-webui.py before using )rr�AttributeError�getattr)�self�name�eps   r�__getattr__z_Proxy.__getattr__$s:��
�
!�
!��
�:� �R�SW�RX�Y��
��r�4� � r
c�D�tjj||�y)N)rr�__setattr__)rr�values   rrz_Proxy.__setattr__,s�����(�(��u�5r
N)rrr	r
rrrr
rrr!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.configrrrr�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�locks00r�<module>rjs#��
����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�����������qXs�.F/