o
    ॵi                     @   s   d dl Z d dlmZ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mZ d dlmZ d dlmZmZ d d	lmZ d
gZejejejdG dd
 d
eZdS )    N)AnyDictOptionalUnion)	Pipelines)Model)MGLMForTextSummarization)PipelineTensor)	PIPELINES)MGLMSummarizationPreprocessorPreprocessor)TasksMGLMTextSummarizationPipeline)	group_keymodule_namec                       sn   e Zd Z	ddeeef dee f fddZdee	ef de	ee
f fdd	Zde	ee
f fd
dZ  ZS )r   Nmodelpreprocessorc                    sl   t |tr	t|n|}|| _| j  |d u rt }ddlm} t| tj	d< t
 jd||d| d S )Nr   )_find_free_portMASTER_PORT)r   r    )
isinstancestrr   r   evalr   modelscope.utils.torch_utilsr   osenvironsuper__init__)selfr   r   argskwargsr   	__class__r   m/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/pipelines/nlp/mglm_text_summarization_pipeline.pyr      s   
z&MGLMTextSummarizationPipeline.__init__inputsreturnc                 K   s"   t |tr	d|in|}| j|S )Ntext)r   r   r   generate)r   r%   forward_paramsr   r   r$   forward'   s   z%MGLMTextSummarizationPipeline.forwardc                 K   s   |S Nr   )r   inputr!   r   r   r$   postprocess-   s   z)MGLMTextSummarizationPipeline.postprocessr+   )__name__
__module____qualname__r   r   r   r   r   r   r   r   r*   r-   __classcell__r   r   r"   r$   r      s    


)r   typingr   r   r   r   modelscope.metainfor   modelscope.models.baser   modelscope.models.nlpr   modelscope.pipelines.baser	   r
   modelscope.pipelines.builderr   modelscope.preprocessorsr   r   modelscope.utils.constantr   __all__register_moduletext_summarizationmglm_text_summarizationr   r   r   r   r$   <module>   s   