
    vj                          d dl mZmZ d dl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        
           G d d	e                      ZdS )    )AnyDictN)	Pipelines)Model)
OutputKeys)Pipeline)	PIPELINES)TasksPipelineTemplate)module_namec            	            e Zd ZdZdef fdZ	 	 ddededed	efd
Z		 	 ddededed	efdZ
	 ddeded	eeef         fdZ xZS )r   a:  A pipeline template explain how to define parameters and input and
       output information. As a rule, the first parameter is the input,
       followed by the request parameters. The parameter must add type
       hint information, and set the default value if necessary,
       for the convenience of use.
    modelc                 >     t                      j        dd|i| dS )zA pipeline template to describe input and
        output and parameter processing

        Args:
            model: A Model instance.
        r   N )super__init__)selfr   kwargs	__class__s      v/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/modelscope/pipelines/pipeline_template.pyr   zPipelineTemplate.__init__   s-     	//u//////       皙?input
max_lengthtop_preturnc                     dS )al  Pipeline preprocess interface.

        Args:
            input (Any): The pipeline input, ref Tasks.task_template TASK_INPUTS.
            max_length (int, optional): The max_length parameter. Defaults to 1024.
            top_p (float, optional): The top_p parameter. Defaults to 0.8.

        Returns:
            Any: Return result process by forward.
        Nr   r   r   r   r   s       r   
preprocesszPipelineTemplate.preprocess%   	     	r   c                     dS )a1  The forward interface.

        Args:
            input (Any): The output of the preprocess.
            max_length (int, optional): max_length. Defaults to 1024.
            top_p (float, optional): top_p. Defaults to 0.8.

        Returns:
            Any: Return result process by postprocess.
        Nr   r   s       r   forwardzPipelineTemplate.forward5   r!   r   Ninputspostprocess_param1c           	          t           j        t          j        d          t           j        t          j        dd          t           j        t          j        dd          i}|S )a2  The postprocess interface.

        Args:
            input (Any): The output of the forward.
            max_length (int, optional): max_length. Defaults to 1024.
            top_p (float, optional): top_p. Defaults to 0.8.

        Returns:
            Any: Return result process by postprocess.
           
      i  )r   BOXESnpzeros
OUTPUT_IMGTEXT_EMBEDDING)r   r$   r%   results       r   postprocesszPipelineTemplate.postprocessE   sH     bhqkk!28B??%rx4'8'8

 r   )r   r   )N)__name__
__module____qualname____doc__r   r   r   intfloatr    r#   strr   r0   __classcell__)r   s   @r   r   r      s        0e 0 0 0 0 0 0 &*"% "   +.   $ #'"   (+   $ /3 (+7;CH~       r   )typingr   r   numpyr+   modelscope.metainfor   !modelscope.models.base.base_modelr   modelscope.outputs.outputsr   modelscope.pipelines.baser   modelscope.pipelines.builderr	   modelscope.utils.constantr
   __all__register_moduletask_templatepipeline_templater   r   r   r   <module>rE      s               ) ) ) ) ) ) 3 3 3 3 3 3 1 1 1 1 1 1 . . . . . . 2 2 2 2 2 2 + + + + + +
 	Y%@B B BD D D D Dx D DB BD D Dr   