
    ;3h1                       d Z ddlmZ ddlZddlZddl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mZ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m Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z-m.Z. ddl/m0Z0 	 ddlm1Z1  ede3      Z4 ede3      Z5 G d de      Z6 G d de      Z7 G d d      Z8eee8f   Z9 G d de      Z: G d de:      Z; G d de      Z< G d  d!e      Z= G d" d#e      Z> G d$ d%e      Z? G d& d'e      Z@ G d( d)e      ZA G d* d+e$      ZB G d, d-eAe      ZC G d. d/eAe$      ZDeeCeDf   ZE G d0 d1e.      ZF G d2 d3e.      ZG e        G d4 d5eC             ZH G d6 d7eD      ZI G d8 d9      ZJ G d: d;e.      ZK G d< d=e.      ZL G d> d?e.      ZM G d@ dAe.      ZN G dB dCe.      ZO G dD dEeC      ZP G dF dGeC      ZQ G dH dIe.      ZR G dJ dKe.      ZS G dL dMe.      ZTy# e2$ r eZ1Y tw xY w)NzPydantic data models and other dataclasses. This is the only file that uses Optional[]
typing syntax instead of | None syntax to work with pydantic    )annotationsN)ABCabstractmethod)Iterator)Enumauto)	AnnotatedAnyLiteralNewTypeOptionalUnion)Request)ParameterInfo)document)is_file_obj_with_metatraverse)		BaseModel
ConfigDictFieldGetCoreSchemaHandlerGetJsonSchemaHandler	RootModelValidationErrorValidationInfomodel_validator)JsonSchemaValue)core_schema)NotRequired	TypedDict)I18nData)	JsonValueDeveloperPathUserProvidedPathc                  ,    e Zd ZU ded<   ded<   ded<   y)
CancelBodystrsession_hashintfn_indexevent_idN__name__
__module____qualname____annotations__     S/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/gradio/data_classes.pyr&   r&   3   s    MMr2   r&   c                  &    e Zd ZU ded<   dZded<   y)SimplePredictBody	list[Any]dataNOptional[str]r(   )r-   r.   r/   r0   r(   r1   r2   r3   r5   r5   9   s    
O"&L-&r2   r5   c                  H    e Zd Ze	 	 	 	 	 	 dd       Ze	 	 	 	 	 	 dd       Zy)#_StarletteRequestPydanticAnnotationc                4    dd}t        j                  |      S )Nc                <    t        | t              r| S t        d      )Nz(Input must be a Starlette Request object)
isinstancer   
ValueError)values    r3   validate_requestzZ_StarletteRequestPydanticAnnotation.__get_pydantic_core_schema__.<locals>.validate_requestE   s    %)GHHr2   )r?   r
   returnr   )r    no_info_plain_validator_function)cls_source_type_handlerr@   s       r3   __get_pydantic_core_schema__z@_StarletteRequestPydanticAnnotation.__get_pydantic_core_schema__?   s    	I
 ;;<LMMr2   c                    dddS )NobjectStarletteRequest)typetitler1   )rC   _core_schemahandlers      r3   __get_pydantic_json_schema__z@_StarletteRequestPydanticAnnotation.__get_pydantic_json_schema__L   s     !+=>>r2   N)rD   r
   rE   r   rA   core_schema.CoreSchema)rL   rO   rM   r   rA   r   )r-   r.   r/   classmethodrF   rN   r1   r2   r3   r:   r:   >   sa    
N
N '
N 
 	
N 
N ?1?<P?	? ?r2   r:   c                      e Zd ZU dZded<   dZded<   ded<   dZded<   dZd	ed
<   dZd	ed<   dZ	ded<   dZ
ded<   ed        Zy)PredictBodyNr8   r(   r+   r6   r7   zOptional[Any]
event_dataOptional[int]r*   
trigger_idFboolsimple_formatzOptional[bool]batchedc                J    ddddiddidddidddiddiddiddiddid	d
gdS )NrR   rH   rJ   stringarray)rJ   itemsintegerboolean)r(   r+   r7   rS   r*   rU   rW   rX   r7   )rK   rJ   
propertiesrequiredr1   )rC   r   rM   s      r3   rN   z(PredictBody.__get_pydantic_json_schema__b   se     #!' 2#X.!(FH3EF%x0#Y/%y1"()!4"I.	  
 	
r2   )r-   r.   r/   r(   r0   r+   rS   r*   rU   rW   rX   rP   rN   r1   r2   r3   rR   rR   V   sf    "&L-&"Hm"
O $J$"Hm" $J$M4 ^  
 
r2   rR   c                       e Zd ZU dZdZded<   y)PredictBodyInternalzOSeparate class to avoid exposing PydanticStarletteRequest in the API validationNz"Optional[PydanticStarletteRequest]request)r-   r.   r/   __doc__rc   r0   r1   r2   r3   rb   rb   u   s    U 	 / r2   rb   c                      e Zd ZU ded<   y)	ResetBodyr'   r+   Nr,   r1   r2   r3   rf   rf   }   s    Mr2   rf   c                  6    e Zd ZU ded<   ded<   ded<   ded<   y)	ComponentServerJSONBodyr'   r(   r)   component_idfn_namer
   r7   Nr,   r1   r2   r3   rh   rh      s    L
Ir2   rh   c                  "    e Zd ZU ded<   ded<   y)DataWithFilesr
   r7   zlist[tuple[str, bytes]]filesNr,   r1   r2   r3   rl   rl      s    
I""r2   rl   c                  6    e Zd ZU ded<   ded<   ded<   ded<   y)	ComponentServerBlobBodyr'   r(   r)   ri   rj   rl   r7   Nr,   r1   r2   r3   ro   ro      s    L
r2   ro   c                  D    e Zd Z e       Z e       Z e       Z e       Zy)InterfaceTypesN)r-   r.   r/   r   STANDARD
INPUT_ONLYOUTPUT_ONLYUNIFIEDr1   r2   r3   rq   rq      s    vHJ&KfGr2   rq   c                  0    e Zd ZddZeedd              Zy)GradioBaseModelc                   t        | t        t        f      st        d      t	        j
                        dfd}| j                  j                  t        | j                         |t        j                              S )Nz must be used in a Pydantic modelc           
         t        di | }|j                  t        t        j                  t        j                  d      z                    j                         S )N
   r1   )FileData_copy_to_dirr'   pathlibPathsecrets	token_hex
model_dump)objr7   dirs     r3   unique_copyz0GradioBaseModel.copy_to_dir.<locals>.unique_copy   sI    ?c?D$$GLLw'8'8'<!<=>jlr2   )x)r   dict)r=   r   r   	TypeErrorr}   r~   	__class__	from_jsonr   r   r{   is_file_data)selfr   r   s    ` r3   copy_to_dirzGradioBaseModel.copy_to_dir   sm    $I 67>??ll3	 ~~''!%% ( 
 	
r2   c                     y Nr1   rC   r   s     r3   r   zGradioBaseModel.from_json   s     	r2   N)r   zstr | pathlib.PathrA   GradioDataModel)rA   r   )r-   r.   r/   r   rP   r   r   r1   r2   r3   rw   rw      s#    
(   r2   rw   c                      e Zd ZU dZded<   y)JsonDatazHJSON data returned from a component that should not be modified further.r"   rootN)r-   r.   r/   rd   r0   r1   r2   r3   r   r      s
    R
Or2   r   c                      e Zd Zedd       Zy)GradioModelc                     | di |S )Nr1   r1   r   s     r3   r   zGradioModel.from_json   s    xQxr2   N)rA   r   r-   r.   r/   rP   r   r1   r2   r3   r   r      s     r2   r   c                      e Zd Zedd       Zy)GradioRootModelc                     | |      S )Nr   r1   r   s     r3   r   zGradioRootModel.from_json   s    {r2   N)rA   r   r   r1   r2   r3   r   r      s     r2   r   c                  T    e Zd ZU ded<   ded<   ded<   ded<   ded<   d	ed
<   ded<   y)FileDataDictr'   pathzNotRequired[Optional[str]]urlzNotRequired[Optional[int]]size	orig_name	mime_typerV   	is_streamzNotRequired[dict]metaNr,   r1   r2   r3   r   r      s*    
I	##
$$))))O
r2   r   c                      e Zd ZU ded<   y)FileDataMetazLiteral['gradio.FileData']_typeNr,   r1   r2   r3   r   r      s    %%r2   r   c                      e Zd ZU dZded<   dZded<   dZded<   dZded	<   dZded
<   dZ	ded<    e
d       Zded<    ed      edd              Zedd       Zedd       ZddZedd       Zy)r{   ad  
    The FileData class is a subclass of the GradioModel class that represents a file object within a Gradio interface. It is used to store file data and metadata when a file is uploaded.

    Attributes:
        path: The server file path where the file is stored.
        url: The normalized server URL pointing to the file.
        size: The size of the file in bytes.
        orig_name: The original filename before upload.
        mime_type: The MIME type of the file.
        is_stream: Indicates whether the file is a stream.
        meta: Additional metadata used internally (should not be changed).
    r'   r   Nr8   r   rT   r   r   r   FrV   r   c                 
    ddiS )Nr   gradio.FileDatar1   r1   r2   r3   <lambda>zFileData.<lambda>   s    AR7S r2   )default_factoryr   r   before)modec                    |j                   r1|j                   j                  d      rt        |      st        d      |S )Nvalidate_metazlThe 'meta' field must be explicitly provided in the input data and be equal to {'_type': 'gradio.FileData'}.)contextgetr   r>   )rC   vinfos      r3   validate_modelzFileData.validate_model   s<     LL  1)!,~  r2   c                    t        d | j                  | j                  | j                  | j                  | j
                  fD              S )z
        Checks if the FileData object is empty, i.e., all attributes are None.

        Returns:
            bool: True if all attributes (except 'is_stream' and 'meta') are None, False otherwise.
        c              3  $   K   | ]  }|d u  
 y wr   r1   ).0fs     r3   	<genexpr>z#FileData.is_none.<locals>.<genexpr>  s      	
 I	
s   )allr   r   r   r   r   r   s    r3   is_nonezFileData.is_none   sE      	
 					
 	
 		
r2   c                     | |      S )z
        Creates a FileData object from a given file path.

        Args:
            path: The file path.

        Returns:
            FileData: An instance of FileData representing the file at the specified path.
        )r   r1   )rC   r   s     r3   	from_pathzFileData.from_path  s     ~r2   c                    t        j                  |      j                  d       t        |       }| j                  st        d      t        j                  | j                  |      }||d<    | j                  di |S )a^  
        Copies the file to a specified directory and returns a new FileData object representing the copied file.

        Args:
            dir: The destination directory.

        Returns:
            FileData: A new FileData object representing the copied file.

        Raises:
            ValueError: If the source file path is not set.
        T)exist_okzSource file path is not setr   r1   )	r}   r~   mkdirr   r   r>   shutilcopyr   )r   r   new_objnew_names       r3   r|   zFileData._copy_to_dir  sk     	S.t*yy:;;;;tyy#."t~~(((r2   c                |    t        |t              r	 t        di |j                   S y# t        t
        f$ r Y yw xY w)z
        Checks if an object is a valid FileData instance.

        Args:
            obj: The object to check.

        Returns:
            bool: True if the object is a valid FileData instance, False otherwise.
        Fr1   )r=   r   r{   r   r   r   )rC   r   s     r3   r   zFileData.is_file_data3  sF     c4 #?c?2222  / s   ) ;;)r   r   )rA   rV   )r   r'   rA   r{   )r   r'   rA   r{   )r   r
   rA   rV   )r-   r.   r/   rd   r0   r   r   r   r   r   r   r   r   rP   r   propertyr   r   r|   r   r1   r2   r3   r{   r{      s     ICD-#I}##I}#It/STD,T(#	  $	 
 
$ 
 
),  r2   r{   c                  &    e Zd ZU ded<   d ZddZy)	ListFileszlist[FileData]r   c                     | j                   |   S r   r   )r   indexs     r3   __getitem__zListFiles.__getitem__I  s    yyr2   c                ,    t        | j                        S r   )iterr   r   s    r3   __iter__zListFiles.__iter__L  s    DIIr2   N)rA   zIterator[FileData])r-   r.   r/   r0   r   r   r1   r2   r3   r   r   F  s    
 r2   r   c                  ,    e Zd ZdZg ZddZed        Zy)_StaticFilesz3
    Class to hold all static files for an app
    c                    || _         |D cg c]%  }t        j                  |      j                         ' c}| _        y c c}w r   )pathsr}   r~   resolve	all_paths)r   r   ps      r3   __init__z_StaticFiles.__init__W  s/    
=BC',,q/113CCs   *?c                    g | _         y r   )r   )rC   s    r3   clearz_StaticFiles.clear[  s	    r2   N)r   zlist[str | pathlib.Path]rA   None)r-   r.   r/   rd   r   r   rP   r   r1   r2   r3   r   r   P  s(     ID  r2   r   c                  6    e Zd ZU ded<   ded<   ded<   ded<   y)BodyCSSr'   body_background_fillbody_text_colorbody_background_fill_darkbody_text_color_darkNr,   r1   r2   r3   r   r   `  s    ""r2   r   c                  "    e Zd ZU ded<   ded<   y)Layoutr)   idzNotRequired[list[int | Layout]]childrenNr,   r1   r2   r3   r   r   g  s    G--r2   r   c                  ,    e Zd ZU ded<   ded<   ded<   y)Pagez	list[int]
componentsdependenciesr   layoutNr,   r1   r2   r3   r   r   l  s    Nr2   r   c                  v   e Zd ZU ded<   ded<   ded<   ded<   ded	<   ded
<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded <   d!ed"<   ded#<   ded$<   ded%<   d&ed'<   d(ed)<   d*ed+<   d*ed,<   ded-<   d.ed/<   d0ed1<   d2ed3<   d4ed5<   d6ed7<   d.ed8<   y9):BlocksConfigDictr'   versionz0NotRequired[Literal['valid', 'invalid', 'none']]deep_link_stater   r)   app_idrV   dev_modeanalytics_enabledzlist[dict[str, Any]]r   z
str | Nonecssconnect_heartbeatzstr | Literal[True] | Nonejsheadzstr | I18nDatarK   space_idenable_queue
show_errorshow_apiis_colabz
int | Nonemax_file_sizez	list[str]stylesheetsthemez>Literal['ws', 'sse', 'sse_v1', 'sse_v2', 'sse_v2.1', 'sse_v3']protocolr   body_cssfill_height
fill_width
theme_hashzNotRequired[Layout]r   z!NotRequired[list[dict[str, Any]]]r   zNotRequired[str | None]r   username
api_prefixzNotRequired[bool]pwazdict[str, Page]pagezlist[tuple[str, str]]pagesNotRequired[str]current_pagez-NotRequired[dict[str, dict[str, str]] | None]i18n_translations
mcp_serverNr,   r1   r2   r3   r   r   r  s    LEE
IKN$$	O""
NNLLO33
!!%%O	
  ""DD!!r2   r   c                  6    e Zd ZU ded<   ded<   ded<   ded<   y	)
MediaStreamChunkbytesr7   floatdurationr'   	extensionr  r   Nr,   r1   r2   r3   r  r    s    
KONr2   r  c                      e Zd ZU  edd      Zded<    edd      Zded<    edd      Zd	ed
<    edd      Zded<    edd      Z	ded<    edd      Z
ded<   ddiZded<    eddi      Zy)	ImageDataNzPath to a local file)defaultdescriptionr8   r   z.Publicly available url or base64 encoded imager   zSize of image in bytesrT   r   zOriginal filenamer   zmime type of imager   FzCan always be set to FalserV   r   r   r   r   r   r  zTFor input, either path or url must be provided. For output, path is always provided.)json_schema_extra)r-   r.   r/   r   r   r0   r   r   r   r   r   r   r   model_configr1   r2   r3   r  r    s    :PQD-Q"RC   :RSD-S$T?RSI}S$T?STI}TE7STItT,-D$-q
Lr2   r  c                  *    e Zd ZU  ed      Zded<   y)Base64ImageDatazbase64 encoded image)r  r'   r   N)r-   r.   r/   r   r   r0   r1   r2   r3   r  r    s    !78C8r2   r  c                  6    e Zd ZU ded<   ded<   ded<   ded<   y)	APIReturnInfor'   labelzdict[str, Any]rJ   zdict[str, str]python_type	componentNr,   r1   r2   r3   r  r    s    J
Nr2   r  c                  6    e Zd ZU ded<   ded<   ded<   ded<   y	)
APIEndpointInfor  r  zlist[ParameterInfo]
parameterszlist[APIReturnInfo]returnsrV   r   Nr,   r1   r2   r3   r   r     s    !!##  Nr2   r   c                  "    e Zd ZU ded<   ded<   y)APIInfozdict[str, APIEndpointInfo]named_endpointsunnamed_endpointsNr,   r1   r2   r3   r$  r$    s    //11r2   r$  )Urd   
__future__r   r}   r   r   abcr   r   collections.abcr   enumr   r   typingr	   r
   r   r   r   r   fastapir   gradio_client.data_classesr   gradio_client.documentationr   gradio_client.utilsr   r   pydanticr   r   r   r   r   r   r   r   r   pydantic.json_schemar   pydantic_corer   typing_extensionsr   r    gradio.i18nr!   r"   ImportErrorr'   r#   r$   r&   r5   r:   PydanticStarletteRequestrR   rb   rf   rh   rl   ro   rq   rw   r   r   r   r   r   r   r{   r   r   r   r   r   r   r  r  r  r  r   r$  r1   r2   r3   <module>r7     s(  @ #    # $    4 0 ?
 
 
 1 % 4  " --s3  '	 '
? ?* %W.Q%QR 
) 
>+ 	 i #I #
i T c 6y /9 oy  _459 &9 & 
i{ i iX   i .Y .
9 $"y $"Ny  $9k 9I i 2i 2q  Is   G6 6H H