
    9i	                         S SK JrJr  S SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJrJr  S SKJr  S SKJr  S S	KJr  S
/r\R*                  " \R,                  \R.                  S9 " S S
\5      5       rg)    )DictUnion)	Pipelines)Model)SpaceForDialogModeling)
OutputKeys)PipelineTensor)	PIPELINES)DialogModelingPreprocessor)TasksDialogModelingPipeline)module_namec            	       x   ^  \ rS rSr    SS\\\4   S\S\S\4U 4S jjjrS\	\\
4   S\	\\4   4S	 jrS
rU =r$ )r      modelpreprocessorconfig_filedevicec                 z   > [         TU ]  UUUUUS9  Uc&  [        U R                  R                  40 UD6U l        gg)a  Use `model` and `preprocessor` to create a dialog modeling pipeline for dialog response generation

Args:
    model (str or SpaceForDialogModeling): Supply either a local model dir or a model id from the model hub,
    or a SpaceForDialogModeling instance.
    preprocessor (DialogModelingPreprocessor): An optional preprocessor instance.
    kwargs (dict, `optional`):
        Extra kwargs passed into the preprocessor's constructor.
)r   r   r   r   auto_collateN)super__init__r   r   	model_dirr   )selfr   r   r   r   r   kwargs	__class__s          q/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/pipelines/nlp/dialog_modeling_pipeline.pyr   DialogModelingPipeline.__init__   sU      	%#% 	 	'  :

$$!0(.!0D      inputsreturnc                     U R                   R                  R                  R                  US   5      n[	        U5      S:  d   eUS[	        U5      S-
   nX![
        R                  '   U$ )zprocess the prediction results

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

Returns:
    Dict[str, str]: the prediction results
resp      )r   
text_field	tokenizerconvert_ids_to_tokenslenr   OUTPUT)r   r!   sys_rsps      r   postprocess"DialogModelingPipeline.postprocess/   sg     ##..88NN6N7|a!CL1,-$+z  !r    )r   )NNgpuT)__name__
__module____qualname____firstlineno__r   r   strr   r   r   r
   r-   __static_attributes____classcell__)r   s   @r   r   r      st     =A$($"04c9:090 "0 	0 04$sF{"3 S#X  r    N)typingr   r   modelscope.metainfor   modelscope.modelsr   modelscope.models.nlpr   modelscope.outputsr   modelscope.pipelines.baser	   r
   modelscope.pipelines.builderr   modelscope.preprocessorsr   modelscope.utils.constantr   __all__register_moduletask_oriented_conversationdialog_modelingr    r    r   <module>rE      sc     ) # 8 ) 6 2 ? +#
$ 	$$)2K2KM+X +M+r    