
    &`i                         d Z ddlZddlZddlmZ ddlmZmZmZ  ed          Z	 G d d          Z
 e
            Zded	e	f         d
ed	ee	         f         fdZdS )z
Generic model definitions for common utilities.

These models represent generic concepts that can be used by both
serve and batch components.
    N)partial)	AwaitableCallableTypeVarTc                   $    e Zd ZdZd ZdefdZdS )GlobalIdManagerz7Thread-safe global ID manager for assigning unique IDs.c                 D    d| _         t          j                    | _        d S )Nr   )_counter	threadingLock_lockselfs    s/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/llm/_internal/common/models.py__init__zGlobalIdManager.__init__   s    ^%%


    returnc                 r    | j         5  | xj        dz  c_        | j        cddd           S # 1 swxY w Y   dS )zGet the next unique ID.   N)r   r   r   s    r   nextzGlobalIdManager.next   s    Z 	! 	!MMQMM=	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s   ,00N)__name__
__module____qualname____doc__r   intr    r   r   r	   r	      sD        AA& & &!c ! ! ! ! ! !r   r	   _func.r   c                 ,     dt           j        f fd}|S )zTake a blocking function, and run it on in an executor thread.

    This function prevents the blocking function from blocking the asyncio event loop.
    The code in this function needs to be thread safe.
    r   c                  x    t          j                    }t          g| R i |}|                    d |          S )N)executorfunc)asyncioget_event_loopr   run_in_executor)argskwargsloopr"   r   s       r   _async_wrapperz"make_async.<locals>._async_wrapper,   sG    %''u.t...v..##T#===r   )r#   Future)r   r)   s   ` r   
make_asyncr+   %   s2    >7> > > > > > >
 r   )r   r#   r   	functoolsr   typingr   r   r   r   r	   global_id_managerr+   r   r   r   <module>r/      s                / / / / / / / / / /GCLL! ! ! ! ! ! ! ! $O%% hsAv& 8C14E+F      r   