o
    i
                     @   s   d dl mZmZ d dlmZmZ d dlmZmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ e	d
Ze	dZG dd deeeef ZdS )    )ABCabstractmethod)AsyncGeneratorSequence)AnyGenericTypeVar)
VllmConfig)IOProcessorResponse)
PromptType)PoolingRequestOutputPoolingParams)SamplingParamsIOProcessorInputIOProcessorOutputc                
   @   s  e Zd ZdefddZe	ddededB dee	e B fdd	Z
	ddededB dee	e B fd
dZe	dde	e dedB defddZ	ddeeeef  dedB defddZededefddZ	ddeeB dB deeB fddZededefddZdS )IOProcessorvllm_configc                 C   s
   || _ d S N)r   )selfr    r   Z/home/ubuntu/vllm_env/lib/python3.10/site-packages/vllm/plugins/io_processors/interface.py__init__   s   
zIOProcessor.__init__Nprompt
request_idreturnc                 K      t r   NotImplementedErrorr   r   r   kwargsr   r   r   pre_process      zIOProcessor.pre_processc                    s   | j ||fi |S r   )r!   r   r   r   r   pre_process_async    s   zIOProcessor.pre_process_asyncmodel_outputc                 K   r   r   r   )r   r$   r   r    r   r   r   post_process(   r"   zIOProcessor.post_processc                    sD   t dd |2 I d H dd d}dd |D }| j||fi |S )Nc                    s$   g | z3 d H W \}}||fq6 S r   r   ).0iitemr   r   r   
<listcomp>;   s   " z2IOProcessor.post_process_async.<locals>.<listcomp>c                 S   s   | d S )Nr   r   )outputr   r   r   <lambda>;   s    z0IOProcessor.post_process_async.<locals>.<lambda>)keyc                 S   s   g | ]}|d  qS )   r   )r&   r*   r   r   r   r)   =   s    )sortedr%   )r   r$   r   r    sorted_outputcollected_outputr   r   r   post_process_async1   s   	zIOProcessor.post_process_asyncrequestc                 C   r   r   r   )r   r2   r   r   r   parse_request@   s   zIOProcessor.parse_requestparamsc                 C   s
   |pt  S r   r   )r   r4   r   r   r   validate_or_generate_paramsD   s   
z'IOProcessor.validate_or_generate_paramsplugin_outputc                 C   r   r   r   )r   r6   r   r   r   output_to_responseI   s   zIOProcessor.output_to_responser   )__name__
__module____qualname__r	   r   r   r   strr   r   r!   r#   r   r   r%   r   tupleintr1   r   r3   r   r   r5   r
   r7   r   r   r   r   r      sd    





r   N)abcr   r   collections.abcr   r   typingr   r   r   vllm.configr	   )vllm.entrypoints.pooling.pooling.protocolr
   vllm.inputs.datar   vllm.outputsr   vllm.pooling_paramsr   vllm.sampling_paramsr   r   r   r   r   r   r   r   <module>   s   