
    .`i                     `    d dl mZ d dlmZ d dlmZmZmZmZ da	d Z
d Z G d d          Zd	S )
    )	Awaitable)JSONResponse)ASGIAppReceiveScopeSendFc                      t           S N_scaling_elastic_ep     /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/vllm/entrypoints/serve/elastic_ep/middleware.pyget_scaling_elastic_epr      s    r   c                 
    | a d S r
   r   )values    r   set_scaling_elastic_epr      s    r   c            	       F    e Zd ZdZdeddfdZdededede	d         fd	Z
dS )
ScalingMiddlewarez
    Middleware that checks if the model is currently scaling and
    returns a 503 Service Unavailable response if it is.

    This middleware applies to all HTTP requests and prevents
    processing when the model is in a scaling state.
    appreturnNc                     || _         d S r
   )r   )selfr   s     r   __init__zScalingMiddleware.__init__   s    r   scopereceivesendc                     |d         dk    r|                      |||          S t                      r t          ddid          } ||||          S |                      |||          S )Ntypehttperrorz7The model is currently scaling. Please try again later.i  )contentstatus_code)r   r   r   )r   r   r   r   responses        r   __call__zScalingMiddleware.__call__"   s    =F""88E7D111 "## 	2#V  	  H 8E7D111xxw---r   )__name__
__module____qualname____doc__r   r   r   r   r   r   r%   r   r   r   r   r      su         G     .e .g .T .iPTo . . . . . .r   r   N)collections.abcr   fastapi.responsesr   starlette.typesr   r   r   r   r   r   r   r   r   r   r   <module>r-      s    & % % % % % * * * * * * 9 9 9 9 9 9 9 9 9 9 9 9         
. . . . . . . . . .r   