o
    e8*                     @  s\  d Z ddlmZ ddlmZ ddlmZ ddlmZ dd Z	G dd	 d	ej
Z
G d
d dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dZG dd dejZG dd dejZG d d! d!ejZG d"d# d#ejZG d$d% d%ejZG d&d' d'ejZd(S ))aP  
This module defines various classes that can serve as the `output` to an interface. Each class must inherit from
`OutputComponent`, and each class must define a path to its template. All of the subclasses of `OutputComponent` are
automatically added to a registry, which allows them to be easily referenced in other parts of the code.
    )annotations)Optional)
componentswarn_deprecationc                   C  s   t d d S )NzUsage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.componentsr    r   r   >D:\Projects\ConvertPro\env\Lib\site-packages\gradio/outputs.pywarn_outputs_deprecation   s   r	   c                      s$   e Zd Z		d	d
 fddZ  ZS )TextboxtextNtypestrlabelOptional[str]c                   s   t   t j||d d S )N)r   r   r	   super__init__selfr   r   	__class__r   r   r      s   zTextbox.__init__)r   Nr   r   r   r   )__name__
__module____qualname__r   __classcell__r   r   r   r   r
      s    r
   c                      s&   e Zd ZdZ	dd fddZ  ZS )Imagez
    Component displays an output image.
    Output type: Union[numpy.array, PIL.Image, str, matplotlib.pyplot, Tuple[Union[numpy.array, PIL.Image, str], List[Tuple[str, float, float, float, float]]]]
    autoFNr   r   plotboolr   r   c                   s"   t   |rd}t j||d dS )a  
        Parameters:
        type (str): Type of value to be passed to component. "numpy" expects a numpy array with shape (height, width, 3), "pil" expects a PIL image object, "file" expects a file path to the saved image or a remote URL, "plot" expects a matplotlib.pyplot object, "auto" detects return type.
        plot (bool): DEPRECATED. Whether to expect a plot to be returned by the function.
        label (str): component name in interface.
        r   r   r   Nr   )r   r   r   r   r   r   r   r   '   s   	zImage.__init__)r   FN)r   r   r   r   r   r   r   r   r   __doc__r   r   r   r   r   r   r   !       r   c                      s$   e Zd ZdZdd	 fddZ  ZS )
Videoz:
    Used for video output.
    Output type: filepath
    Nr   r   r   c                      t   t j||d dS )a  
        Parameters:
        type (str): Type of video format to be passed to component, such as 'avi' or 'mp4'. Use 'mp4' to ensure browser playability. If set to None, video will keep returned format.
        label (str): component name in interface.
        )formatr   Nr   r   r   r   r   r   <      zVideo.__init__NN)r   r   r   r   r!   r   r   r   r   r$   6       r$   c                      s$   e Zd ZdZd
d fdd	Z  ZS )Audiozs
    Creates an audio player that plays the output audio.
    Output type: Union[Tuple[int, numpy.array], str]
    r   Nr   r   r   r   c                   r%   )ab  
        Parameters:
        type (str): Type of value to be passed to component. "numpy" returns a 2-set tuple with an integer sample_rate and the data as 16-bit int numpy.array of shape (samples, 2), "file" returns a temporary file path to the saved wav audio file, "auto" detects return type.
        label (str): component name in interface.
        r    Nr   r   r   r   r   r   L   r'   zAudio.__init__)r   Nr   r!   r   r   r   r   r*   F   r)   r*   c                      $   e Zd ZdZdd fddZ  ZS )	FilezF
    Used for file output.
    Output type: Union[file-like, str]
    Nr   r   c                      t   t j|d dS zO
        Parameters:
        label (str): component name in interface.
        r   Nr   r   r   r   r   r   r   \      zFile.__init__Nr   r   r!   r   r   r   r   r,   V   r)   r,   c                      s0   e Zd ZdZ						dd fddZ  ZS )	Dataframez
    Component displays 2D output through a spreadsheet interface.
    Output type: Union[pandas.DataFrame, numpy.array, List[Union[str, float]], List[List[Union[str, float]]]]
    N   paginater   headersOptional[list[str]]max_rowsOptional[int]max_colsoverflow_row_behaviourr   r   r   r   c                   s"   t   t j||||||d dS )a  
        Parameters:
        headers (List[str]): Header names to dataframe. Only applicable if type is "numpy" or "array".
        max_rows (int): Maximum number of rows to display at once. Set to None for infinite.
        max_cols (int): Maximum number of columns to display at once. Set to None for infinite.
        overflow_row_behaviour (str): If set to "paginate", will create pages for overflow rows. If set to "show_ends", will show initial and final rows and truncate middle rows.
        type (str): Type of value to be passed to component. "pandas" for pandas dataframe, "numpy" for numpy array, or "array" for Python array, "auto" detects return type.
        label (str): component name in interface.
        )r7   r   r   r9   r;   r<   Nr   )r   r7   r9   r;   r<   r   r   r   r   r   r   k   s   
zDataframe.__init__)Nr5   Nr6   r   N)r7   r8   r9   r:   r;   r:   r<   r   r   r   r   r   r!   r   r   r   r   r4   e   s    r4   c                      s&   e Zd ZdZ	dd fd	d
Z  ZS )
TimeserieszO
    Component accepts pandas.DataFrame.
    Output type: pandas.DataFrame
    Nxr   ystr | list[str]r   r   c                      t   t j|||d dS )a~  
        Parameters:
        x (str): Column name of x (time) series. None if csv has no headers, in which case first column is x series.
        y (Union[str, List[str]]): Column name of y series, or list of column names if multiple series. None if csv has no headers, in which case every column after first is a y series.
        label (str): component name in interface.
        )r>   r?   r   Nr   )r   r>   r?   r   r   r   r   r      s   	zTimeseries.__init__)NNN)r>   r   r?   r@   r   r   r!   r   r   r   r   r=      r#   r=   c                      r+   )	Statezg
    Special hidden component that stores state across runs of the interface.
    Output type: Any
    Nr   r   c                   r-   zZ
        Parameters:
        label (str): component name in interface (not used).
        r/   Nr   r0   r   r   r   r      r1   zState.__init__r2   r3   r!   r   r   r   r   rB      r)   rB   c                      s*   e Zd ZdZ			dd fd
dZ  ZS )Labela  
    Component outputs a classification label, along with confidence scores of top categories if provided. Confidence scores are represented as a dictionary mapping labels to scores between 0 and 1.
    Output type: Union[Dict[str, float], str, int, float]
    Nr   num_top_classesr:   r   r   r   r   c                   rA   )a]  
        Parameters:
        num_top_classes (int): number of most confident classes to show.
        type (str): Type of value to be passed to component. "value" expects a single out label, "confidences" expects a dictionary mapping labels to confidence scores, "auto" detects return type.
        label (str): component name in interface.
        )rE   r   r   Nr   )r   rE   r   r   r   r   r   r         zLabel.__init__)Nr   N)rE   r:   r   r   r   r   r!   r   r   r   r   rD      s    rD   c                   @  s"   e Zd ZdZddddd	d
ZdS )	KeyValuesz
    Component displays a table representing values for multiple fields.
    Output type: Union[Dict, List[Tuple[str, Union[str, int, float]]]]
     Nr/   valuer   r   r   c                K  s   t d)zl
        Parameters:
        value (str): IGNORED
        label (str): component name in interface.
        z[The KeyValues component is deprecated. Please use the DataFrame or JSON components instead.)DeprecationWarning)r   rI   r   kwargsr   r   r   r      s   zKeyValues.__init__)rH   )rI   r   r   r   )r   r   r   r"   r   r   r   r   r   rG      s    rG   c                      s*   e Zd ZdZ			dd fd
dZ  ZS )HighlightedTextac  
    Component creates text that contains spans that are highlighted by category or numerical value.
    Output is represent as a list of Tuple pairs, where the first element represents the span of text represented by the tuple, and the second element represents the category or value of the text.
    Output type: List[Tuple[str, Union[float, str]]]
    NF	color_mapdict[str, str]r   r   show_legendr   c                   rA   )z
        Parameters:
        color_map (Dict[str, str]): Map between category and respective colors
        label (str): component name in interface.
        show_legend (bool): whether to show span categories in a separate legend or inline.
        )rM   r   rO   Nr   )r   rM   r   rO   r   r   r   r      rF   zHighlightedText.__init__)NNF)rM   rN   r   r   rO   r   r!   r   r   r   r   rL      s    rL   c                      r+   )	JSONz
    Used for JSON output. Expects a JSON string or a Python object that is JSON serializable.
    Output type: Union[str, Any]
    Nr   r   c                   r-   r.   r   r0   r   r   r   r      r1   zJSON.__init__r2   r3   r!   r   r   r   r   rP      r)   rP   c                      r+   )	HTMLzR
    Used for HTML output. Expects an HTML valid string.
    Output type: str
    Nr   r   c                   s   t  j|d dS r.   )r   r   r0   r   r   r   r      s   zHTML.__init__r2   r3   r!   r   r   r   r   rQ      r)   rQ   c                      s&   e Zd ZdZ	d	d
 fddZ  ZS )CarouselzU
    Component displays a set of output components that can be scrolled through.
    Nr   1components.Component | list[components.Component]r   r   c                   r%   )z
        Parameters:
        components (Union[List[Component], Component]): Classes of component(s) that will be scrolled through.
        label (str): component name in interface.
        )r   r   Nr   )r   r   r   r   r   r   r        
zCarousel.__init__r2   )r   rS   r   r   r!   r   r   r   r   rR     s    rR   c                      r+   )	Chatbotz
    Component displays a chatbot output showing both user submitted messages and responses
    Output type: List[Tuple[str, str]]
    Nr   r   c                   r-   rC   r   r0   r   r   r   r     r1   zChatbot.__init__r2   r3   r!   r   r   r   r   rU     r)   rU   c                      s(   e Zd ZdZ		dd fddZ  ZS )	Image3Dzc
    Used for 3D image model output.
    Input type: File object of type (.obj, glb, or .gltf)
    Nr   r   c                   r%   )z
        Parameters:
        label (str): component name in interface.
        optional (bool): If True, the interface can be submitted with no uploaded image, in which case the input value is None.
        )clear_colorr   Nr   )r   rW   r   r   r   r   r   .  rT   zImage3D.__init__r(   r3   r!   r   r   r   r   rV   (  s
    rV   N)r"   
__future__r   typingr   Zgradior   Zgradio.deprecationr   r	   r
   r   r$   r*   r,   r4   r=   rB   rD   rG   rL   rP   rQ   rR   rU   ZModel3DrV   r   r   r   r   <module>   s,   
#