
    Pi=2                       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 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.m/Z/ 	 ddlm0Z0 n# e1$ r eZ0Y nw xY w ede2          Z3 ede2          Z4 G d de          Z5 G d de          Z6 G d d          Z7eee7f         Z8 G d de          Z9 G d de9          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/e#          ZC G d0 d1eBe          ZD G d2 d3eBe#          ZEeeDeEf         ZF G d4 d5e-          ZG G d6 d7e-          ZH e             G d8 d9eD                      ZI G d: d;eE          ZJ G d< d=          ZK G d> d?e-          ZL G d@ dAe-          ZM G dB dCe-          ZN G dD dEe-          ZO G dF dGe-          ZP G dH dIeD          ZQ G dJ dKeD          ZR G dL dMe-          ZS G dN dOe-          ZT G dP dQe-          ZUdS )RzPydantic 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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<   dS )
CancelBodystrsession_hashintfn_indexevent_idN__name__
__module____qualname____annotations__     g/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/gradio/data_classes.pyr%   r%   2   s.         MMMMMMMMr1   r%   c                  (    e Zd ZU ded<   dZded<   dS )SimplePredictBody	list[Any]dataN
str | Noner'   )r,   r-   r.   r/   r'   r0   r1   r2   r4   r4   8   s,         OOO#L######r1   r4   c                  >    e Zd Zedd            Zedd            ZdS )#_StarletteRequestPydanticAnnotation_source_typer
   _handlerr   returncore_schema.CoreSchemac                2    dd}t          j        |          S )Nvaluer
   r<   r   c                N    t          | t                    r| S t          d          )Nz(Input must be a Starlette Request object)
isinstancer   
ValueError)r?   s    r2   validate_requestzZ_StarletteRequestPydanticAnnotation.__get_pydantic_core_schema__.<locals>.validate_requestD   s(    %)) GHHHr1   )r?   r
   r<   r   )r    no_info_plain_validator_function)clsr:   r;   rC   s       r2   __get_pydantic_core_schema__z@_StarletteRequestPydanticAnnotation.__get_pydantic_core_schema__>   s.    	I 	I 	I 	I
 ;<LMMMr1   _core_schemahandlerr   r   c                    dddS )NobjectStarletteRequest)typetitler0   )rE   rG   rH   s      r2   __get_pydantic_json_schema__z@_StarletteRequestPydanticAnnotation.__get_pydantic_json_schema__K   s     !+=>>>r1   N)r:   r
   r;   r   r<   r=   )rG   r=   rH   r   r<   r   )r,   r-   r.   classmethodrF   rN   r0   r1   r2   r9   r9   =   sV        
N 
N 
N [
N ? ? ? [? ? ?r1   r9   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dS )PredictBodyNr7   r'   r*   r5   r6   z
Any | None
event_data
int | Noner)   
trigger_idFboolsimple_formatzbool | None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 )NrQ   rJ   rL   stringarray)rL   itemsintegerboolean)r'   r*   r6   rR   r)   rT   rV   rW   r6   )rM   rL   
propertiesrequiredr0   )rE   r   rH   s      r2   rN   z(PredictBody.__get_pydantic_json_schema__a   sr     #!' 2#X.!(FH3EFF%x0#Y/%y1"()!4"I.	 	  
 
 	
r1   )r,   r-   r.   r'   r/   r*   rR   r)   rT   rV   rW   rO   rN   r0   r1   r2   rQ   rQ   U   s         #L####HOOO!J!!!!H!J!!!!M      
 
 [
 
 
r1   rQ   c                  "    e Zd ZU dZdZded<   dS )PredictBodyInternalzOSeparate class to avoid exposing PydanticStarletteRequest in the API validationNzPydanticStarletteRequest | Nonerequest)r,   r-   r.   __doc__rb   r/   r0   r1   r2   ra   ra   t   s:         UU 	       r1   ra   c                      e Zd ZU ded<   dS )	ResetBodyr&   r*   Nr+   r0   r1   r2   re   re   |   s         MMMMMr1   re   c                      e Zd ZU ded<   dS )VibeEditBodyr&   promptNr+   r0   r1   r2   rg   rg      s         KKKKKr1   rg   c                      e Zd ZU ded<   dS )VibeCodeBodyr&   codeNr+   r0   r1   r2   rj   rj      s         IIIIIr1   rj   c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )	ComponentServerJSONBodyr&   r'   r(   component_idfn_namer
   r6   Nr+   r0   r1   r2   rm   rm      s:         LLLIIIIIr1   rm   c                  $    e Zd ZU ded<   ded<   dS )DataWithFilesr
   r6   zlist[tuple[str, bytes]]filesNr+   r0   r1   r2   rq   rq      s'         III""""""r1   rq   c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )	ComponentServerBlobBodyr&   r'   r(   rn   ro   rq   r6   Nr+   r0   r1   r2   rt   rt      s?         LLLr1   rt   c                  ^    e Zd Z e            Z e            Z e            Z e            ZdS )InterfaceTypesN)r,   r-   r.   r   STANDARD
INPUT_ONLYOUTPUT_ONLYUNIFIEDr0   r1   r2   rv   rv      s:        tvvHJ$&&KdffGGGr1   rv   c                  >    e Zd ZddZeed	d                        ZdS )
GradioBaseModeldirstr | pathlib.Pathr<   GradioDataModelc                   t          | t          t          f          st          d          t	          j                  dfd}| j                            t          | 	                                |t          j                            S )Nz must be used in a Pydantic modelobjdictc                    t          di | }|                    t          t          j                  t          j        d          z                                                      S )N
   r0   )FileData_copy_to_dirr&   pathlibPathsecrets	token_hex
model_dump)r   r6   r}   s     r2   unique_copyz0GradioBaseModel.copy_to_dir.<locals>.unique_copy   sX    ??c??D$$GL%%(9"(=(==>> jllr1   )x)r   r   )rA   r   r   	TypeErrorr   r   	__class__	from_jsonr   r   r   is_file_data)selfr}   r   s    ` r2   copy_to_dirzGradioBaseModel.copy_to_dir   s    $I 677 	@>???l3	 	 	 	 	 	 ~''!!%  ( 
 
 	
r1   c                    d S Nr0   rE   r   s     r2   r   zGradioBaseModel.from_json   s	     	r1   N)r}   r~   r<   r   )r<   r   )r,   r-   r.   r   rO   r   r   r0   r1   r2   r|   r|      sR        
 
 
 
(    ^ [  r1   r|   c                      e Zd ZU dZded<   dS )JsonDatazHJSON data returned from a component that should not be modified further.r!   rootN)r,   r-   r.   rc   r/   r0   r1   r2   r   r      s         RROOOOOr1   r   c                  &    e Zd Zedd            ZdS )GradioModelr<   c                     | di |S )Nr0   r0   r   s     r2   r   zGradioModel.from_json   s    sxxQxxr1   N)r<   r   r,   r-   r.   rO   r   r0   r1   r2   r   r      s2           [  r1   r   c                  &    e Zd Zedd            ZdS )GradioRootModelr<   c                     | |          S )Nr   r0   r   s     r2   r   zGradioRootModel.from_json   s    s{{{r1   N)r<   r   r   r0   r1   r2   r   r      s2           [  r1   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S )FileDataDictr&   pathNotRequired[str | None]urlzNotRequired[int | None]size	orig_name	mime_typerU   	is_streamzNotRequired[dict]metaNr+   r0   r1   r2   r   r      s`         III    !!!!&&&&&&&&OOOr1   r   c                      e Zd ZU ded<   dS )FileDataMetazLiteral['gradio.FileData']_typeNr+   r0   r1   r2   r   r      s         %%%%%%r1   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dS )$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   Nr7   r   rS   r   r   r   FrU   r   c                 
    ddiS )Nr   gradio.FileDatar0   r0   r1   r2   <lambda>zFileData.<lambda>   s    AR7S r1   )default_factoryr   r   before)modeinfor   c                    |j         r8|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   rB   )rE   vr   s      r2   validate_modelzFileData.validate_model   sV     L	  11	 *!,,	
 ~   r1   r<   c                p    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 V  	d S r   r0   ).0fs     r2   	<genexpr>z#FileData.is_none.<locals>.<genexpr>  s:       	
 	
 I	
 	
 	
 	
 	
 	
r1   )allr   r   r   r   r   r   s    r2   is_nonezFileData.is_none  sO      	
 	
 			
 	
 	
 	
 	
 		
r1   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   r0   )rE   r   s     r2   	from_pathzFileData.from_path  s     s~~~r1   r}   c                    t          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   r0   )	r   r   mkdirr   r   rB   shutilcopyr   )r   r}   new_objnew_names       r2   r   zFileData._copy_to_dir$  s}     	S...t**y 	<:;;;;ty#.."t~(((((r1   r   r
   c                    t          |t                    r+	 t          di |j         S # t          t
          f$ r Y dS w xY wdS )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.
        Fr0   )rA   r   r   r   r   r   )rE   r   s     r2   r   zFileData.is_file_data:  s]     c4   	#??c??222/   uuus   ) >>)r   r   )r<   rU   )r   r&   r<   r   )r}   r&   r<   r   )r   r
   r<   rU   )r,   r-   r.   rc   r/   r   r   r   r   r   r   r   r   rO   r   propertyr   r   r   r   r0   r1   r2   r   r      sL          IIICD I     I    I/S/STTTDTTTT_(###	 	 	 [ $#	 
 
 
 X
$ 
 
 
 [
) ) ) ),    [  r1   r   c                  (    e Zd ZU ded<   d ZddZdS )		ListFileszlist[FileData]r   c                    | j         |         S r   r   )r   indexs     r2   __getitem__zListFiles.__getitem__P  s    yr1   r<   Iterator[FileData]c                *    t          | j                  S r   )iterr   r   s    r2   __iter__zListFiles.__iter__S  s    DIr1   N)r<   r   )r,   r-   r.   r/   r   r   r0   r1   r2   r   r   M  sE                   r1   r   c                  4    e Zd ZdZg Zd	dZed             ZdS )
_StaticFilesz3
    Class to hold all static files for an app
    pathslist[str | pathlib.Path]r<   Nonec                6    || _         d |D             | _        d S )Nc                Z    g | ](}t          j        |                                          )S r0   )r   r   resolve)r   ps     r2   
<listcomp>z)_StaticFiles.__init__.<locals>.<listcomp>`  s,    CCC',q//1133CCCr1   )r   	all_paths)r   r   s     r2   __init__z_StaticFiles.__init__^  s"    
CCUCCCr1   c                    g | _         d S r   )r   )rE   s    r2   clearz_StaticFiles.clearb  s    r1   N)r   r   r<   r   )r,   r-   r.   rc   r   r   rO   r   r0   r1   r2   r   r   W  sX          ID D D D   [  r1   r   c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )BodyCSSr&   body_background_fillbody_text_colorbody_background_fill_darkbody_text_color_darkNr+   r0   r1   r2   r   r   g  sB         """"r1   r   c                  $    e Zd ZU ded<   ded<   dS )Layoutr(   idzNotRequired[list[int | Layout]]childrenNr+   r0   r1   r2   r   r   n  s'         GGG------r1   r   c                  .    e Zd ZU ded<   ded<   ded<   dS )Pagez	list[int]
componentsdependenciesr   layoutNr+   r0   r1   r2   r   r   s  s1         NNNNNr1   r   c                     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<   d9ed:<   d;S )<BlocksConfigDictr&   versionz0NotRequired[Literal['valid', 'invalid', 'none']]deep_link_stater   r(   app_idrU   dev_mode	vibe_modeanalytics_enabledzlist[dict[str, Any]]r   r7   cssconnect_heartbeatzstr | Literal[True] | Nonejsheadzstr | I18nDatarM   space_idenable_queue
show_erroris_colabrS   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   r   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_serverzlist[str | dict[str, str]]footer_linksNr+   r0   r1   r2   r   r   y  s        LLLEEEEIIIKKKNNNOOO$$$$OOO""""NNNLLLLOOO3333!!!!%%%%OOO    """"DDDD!!!!,,,,,,r1   r   c                  8    e Zd ZU ded<   ded<   ded<   ded<   d	S )
MediaStreamChunkbytesr6   floatdurationr&   	extensionr  r   Nr+   r0   r1   r2   r  r    s9         KKKOOONNNr1   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dS )	ImageDataNzPath to a local file)defaultdescriptionr7   r   z.Publicly available url or base64 encoded imager   zSize of image in bytesrS   r   zOriginal filenamer   zmime type of imager   FzCan always be set to FalserU   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   r/   r   r   r   r   r   r   r   model_configr0   r1   r2   r  r    s        uT7MNNNDNNNNe"R  C     uT7OPPPDPPPP!E$<OPPPIPPPP!E$<PQQQIQQQQeE7STTTITTTT,-D----:q
  LLLr1   r  c                  2    e Zd ZU  ed          Zded<   dS )Base64ImageDatazbase64 encoded image)r!  r&   r   N)r,   r-   r.   r   r   r/   r0   r1   r2   r%  r%    s1         u!7888C888888r1   r%  c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )	APIReturnInfor&   labelzdict[str, Any]rL   zdict[str, str]python_type	componentNr+   r0   r1   r2   r'  r'    s:         JJJNNNNNr1   r'  c                  8    e Zd ZU ded<   ded<   ded<   ded<   d	S )
APIEndpointInfor  r!  zlist[ParameterInfo]
parameterszlist[APIReturnInfo]returnsz,Literal['public', 'private', 'undocumented']api_visibilityNr+   r0   r1   r2   r,  r,    sB         !!!!####    @@@@@@r1   r,  c                  $    e Zd ZU ded<   ded<   dS )APIInfozdict[str, APIEndpointInfo]named_endpointsunnamed_endpointsNr+   r0   r1   r2   r1  r1    s*         ////111111r1   r1  )Vrc   
__future__r   r   r   r   abcr   r   collections.abcr   enumr   r   typingr	   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%   r4   r9   PydanticStarletteRequestrQ   ra   re   rg   rj   rm   rq   rt   rv   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r%  r'  r,  r1  r0   r1   r2   <module>rD     s  @ @ # " " " " "    # # # # # # # # $ $ $ $ $ $                            4 4 4 4 4 4 0 0 0 0 0 0 ? ? ? ? ? ? ? ?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 1 0 0 0 0 0 % % % % % % 4 4 4 4 4 4 4 4            """""""   III --7-s33        $ $ $ $ $	 $ $ $
? ? ? ? ? ? ? ?* %W.Q%QR 
 
 
 
 
) 
 
 
>    +       	       9       9       i   # # # # #I # # #
    i       T       c   6    y       /9       oy    _45    9   & & & & &9 & & & 
i i i i i{ i i iX                   i   . . . . .Y . . .
    9   %- %- %- %- %-y %- %- %-P    y          $9 9 9 9 9k 9 9 9    I   A A A A Ai A A A2 2 2 2 2i 2 2 2 2 2s   B BB