o
    -i,                     @   s  U d dl mZ d dlmZmZmZmZmZmZ d dl	Z	d dl
mZmZmZmZ er4d dlmZmZmZ neZeZeZG dd deZG dd	 d	eZG d
d deZG dd deZeeB eB eB Zeed< 	 dedee fddZdedee fddZedeeddZedeeddZG dd deeeef ZeeB Z eed< 	 G dd deZ!	d;de"e# dedB de!fd d!Z$G d"d# d#eZ%	d;d$e	j&dedB de%fd%d&Z'e!e%B eB Z(eed'< 	 G d(d) d)eZ)e!e%B eB Z*eed*< 	 e(e)B Z+eed+< 	 ed,eed-Z,ed.eed-Z-	d;d/e,d0e-dB d1e.eef dB dee,e-f fd2d3Z/	d;d4ee, d5ee-dB  d1ee.eef  e.eef B dB de"ee,e-f  fd6d7Z0d8eee,e-f  de"e1e,e-dB f  fd9d:Z2dS )<    )Iterable)TYPE_CHECKINGAnyGenericLiteral	TypeAliascastN)NotRequired	TypedDictTypeIsTypeVar)MultiModalDataDictMultiModalInputsMultiModalUUIDDictc                   @   sb   e Zd ZU dZeed< 	 eedB  ed< 	 eeee	f dB  ed< 	 ee
 ed< 	 ee ed< dS )
TextPromptzSchema for a text prompt.promptNmulti_modal_datamm_processor_kwargsmulti_modal_uuids
cache_salt)__name__
__module____qualname____doc__str__annotations__r	   r   dictr   r    r   r   M/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/vllm/inputs/data.pyr      s   
 r   c                   @   s   e Zd ZU dZee ed< 	 ee ed< 	 eee  ed< 	 ee	dB  ed< 	 ee
eef dB  ed< 	 ee ed< 	 ee ed	< dS )
TokensPromptzSchema for a tokenized prompt.prompt_token_idsr   token_type_idsNr   r   r   r   )r   r   r   r   listintr   r	   r   r   r   r   r   r   r   r   r   r   8   s    
 r   c                   @   s*   e Zd ZU dZejed< 	 ee ed< dS )EmbedsPromptz2Schema for a prompt provided via token embeddings.prompt_embedsr   N)	r   r   r   r   torchTensorr   r	   r   r   r   r   r   r$   `   s   
 
r$   c                   @   s$   e Zd ZU dZeed< 	 eed< dS )
DataPromptz:Represents generic inputs handled by IO processor plugins.datadata_formatN)r   r   r   r   r   r   r   r   r   r   r   r(   l   s   
 r(   SingletonPromptr   returnc                 C   s   t | tod| v od| vS Nr    r%   
isinstancer   r   r   r   r   is_tokens_prompt   
   
r1   c                 C   s   t | tod| vod| v S r-   r.   r0   r   r   r   is_embeds_prompt   r2   r3   _T1_coT)bounddefault	covariant_T2_coc                   @   s:   e Zd ZU dZeed< edB ed< eee	e
f  ed< dS )ExplicitEncoderDecoderPromptaw  
    Represents an encoder/decoder model input prompt,
    comprising an explicit encoder prompt and a decoder prompt.

    The encoder and decoder prompts, respectively, may be formatted
    according to any of the
    [`SingletonPrompt`][vllm.inputs.data.SingletonPrompt] schemas,
    and are not required to have the same schema.

    Only the encoder prompt may have multi-modal data. mm_processor_kwargs
    should be at the top-level, and should not be set in the encoder/decoder
    prompts, since they are agnostic to the encoder/decoder.

    Note that an
    [`ExplicitEncoderDecoderPrompt`][vllm.inputs.data.ExplicitEncoderDecoderPrompt]
    may not be used as an input to a decoder-only model,
    and that the `encoder_prompt` and `decoder_prompt`
    fields of this data structure themselves must be
    [`SingletonPrompt`][vllm.inputs.data.SingletonPrompt] instances.
    encoder_promptNdecoder_promptr   )r   r   r   r   r4   r   r8   r	   r   r   r   r   r   r   r   r9      s
   
 r9   
PromptTypec                   @   s:   e Zd ZU dZed ed< 	 ee ed< 	 ee	 ed< dS )TokenInputszRepresents token-based inputs.tokentyper    r   N)
r   r   r   r   r   r   r"   r#   r	   r   r   r   r   r   r=      s   
 r=   r    r   c                 C       t d| d}|dur||d< |S )zQConstruct [`TokenInputs`][vllm.inputs.data.TokenInputs] from optional
    values.r>   )r?   r    Nr   )r=   )r    r   inputsr   r   r   token_inputs      rB   c                   @   s8   e Zd ZU dZed ed< 	 ejed< 	 ee	 ed< dS )EmbedsInputsz#Represents embeddings-based inputs.embedsr?   r%   r   N)
r   r   r   r   r   r   r&   r'   r	   r   r   r   r   r   rD      s   
 
rD   r%   c                 C   r@   )zSConstruct [`EmbedsInputs`][vllm.inputs.data.EmbedsInputs] from optional
    values.rE   )r?   r%   Nr   )rD   )r%   r   rA   r   r   r   embeds_inputs   rC   rF   DecoderOnlyInputsc                   @   s,   e Zd ZU dZeeB ed< 	 eeB ed< dS )EncoderDecoderInputsz
    The inputs in [`LLMEngine`][vllm.engine.llm_engine.LLMEngine] before they
    are passed to the model executor.

    This specifies the required data for encoder-decoder models.
    encoderdecoderN)r   r   r   r   r=   r   r   r   r   r   r   rH     s   
 rH   SingletonInputsProcessorInputs_T1)r5   r6   _T2r:   r;   r   c                 C   s   |d u ri }t | ||dS )Nr:   r;   r   )r9   rO   r   r   r   build_explicit_enc_dec_prompt2  s   rP   enc_promptsdec_promptsc                    sR    du rt tttf i  t tr fddt| |D S dd t| | D S )a  
    Zip encoder and decoder prompts together into a list of
    [`ExplicitEncoderDecoderPrompt`][vllm.inputs.data.ExplicitEncoderDecoderPrompt]
    instances.

    `mm_processor_kwargs` may also be provided; if a dict is passed, the same
    dictionary will be used for every encoder/decoder prompt. If an iterable is
    provided, it will be zipped with the encoder/decoder prompts.
    Nc              	      s*   g | ]\}}t ||ttttf  qS r   )rP   r   r   r   r   ).0r:   r;   r   r   r   
<listcomp>Q  s    z'zip_enc_dec_prompts.<locals>.<listcomp>c                 S   s   g | ]\}}}t |||qS r   )rP   )rS   r:   r;   mm_proc_kwargsr   r   r   rU   Y  s    
)r   r   r   r   r/   zip)rQ   rR   r   r   rT   r   zip_enc_dec_prompts@  s   

rX   enc_dec_promptsc                 C   s   dd | D S )Nc                 S   s   g | ]
}|d  |d fqS )r:   r;   r   )rS   enc_dec_promptr   r   r   rU   d  s    z)to_enc_dec_tuple_list.<locals>.<listcomp>r   )rY   r   r   r   to_enc_dec_tuple_lista  s   r[   )N)3collections.abcr   typingr   r   r   r   r   r   r&   typing_extensionsr	   r
   r   r   vllm.multimodal.inputsr   r   r   objectr   r   r$   r(   r   r+   r   r1   r3   r4   r8   r9   r<   r=   r"   r#   rB   rD   r'   rF   rG   rH   rK   rL   rM   rN   r   rP   rX   tupler[   r   r   r   r   <module>   s    #(






!