o
    ॵi
                     @   s   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 d dl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 )    )AnyDictUnion)	Pipelines)Model)SpaceForDialogIntent)
OutputKeys)Pipeline)	PIPELINES)"DialogIntentPredictionPreprocessor)TasksDialogIntentPredictionPipeline)module_namec                	       sb   e Zd Z				ddeeef dededef fdd	Zd
eee	f deeef fddZ
  ZS )r   NgpuTmodelpreprocessorconfig_filedevicec                    sV   t  j||||||dd|di d |du r$t| jjfi || _| jj| _dS )a  Use `model` and `preprocessor` to create a dialog intent prediction pipeline

        Args:
            model (str or SpaceForDialogIntent): Supply either a local model dir or a model id from the model hub,
            or a SpaceForDialogIntent instance.
            preprocessor (DialogIntentPredictionPreprocessor): An optional preprocessor instance.
            kwargs (dict, `optional`):
                Extra kwargs passed into the preprocessor's constructor.
        compileFcompile_options)r   r   r   r   auto_collater   r   N)super__init__popr   r   	model_dirr   
categories)selfr   r   r   r   r   kwargs	__class__ n/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/pipelines/nlp/dialog_intent_prediction_pipeline.pyr      s    

z'DialogIntentPredictionPipeline.__init__inputsreturnc              	   C   sR   ddl }|d }||||k}tjtj|tj|d tj| j|d d  iiS )zprocess the prediction results

        Args:
            inputs (Dict[str, Any]): _description_

        Returns:
            Dict[str, str]: the prediction results
        r   Npred)	numpywheremaxr   OUTPUT
PREDICTION	LABEL_POSLABELr   )r   r"   npr$   posr    r    r!   postprocess3   s   	
z*DialogIntentPredictionPipeline.postprocess)NNr   T)__name__
__module____qualname__r   r   strr   r   r   r   r.   __classcell__r    r    r   r!   r      s    
*N)typingr   r   r   modelscope.metainfor   modelscope.modelsr   modelscope.models.nlpr   modelscope.outputsr   modelscope.pipelines.baser	   modelscope.pipelines.builderr
   modelscope.preprocessorsr   modelscope.utils.constantr   __all__register_moduletask_oriented_conversationdialog_intent_predictionr   r    r    r    r!   <module>   s   