
    8P[i=2                    0   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  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-      ZUy# e1$ r eZ0Y w xY w)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<   y)
CancelBodystrsession_hashintfn_indexevent_idN__name__
__module____qualname____annotations__     a/var/www/html/chatbot/Makanify-Chatbot-2/venv/lib/python3.12/site-packages/gradio/data_classes.pyr%   r%   2   s    MMr1   r%   c                  &    e Zd ZU ded<   dZded<   y)SimplePredictBody	list[Any]dataN
str | Noner'   )r,   r-   r.   r/   r'   r0   r1   r2   r4   r4   8   s    
O#L*#r1   r4   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    r2   validate_requestzZ_StarletteRequestPydanticAnnotation.__get_pydantic_core_schema__.<locals>.validate_requestD   s    %)GHHr1   )r>   r
   returnr   )r    no_info_plain_validator_function)cls_source_type_handlerr?   s       r2   __get_pydantic_core_schema__z@_StarletteRequestPydanticAnnotation.__get_pydantic_core_schema__>   s    	I
 ;;<LMMr1   c                    dddS )NobjectStarletteRequest)typetitler0   )rB   _core_schemahandlers      r2   __get_pydantic_json_schema__z@_StarletteRequestPydanticAnnotation.__get_pydantic_json_schema__K   s     !+=>>r1   N)rC   r
   rD   r   r@   core_schema.CoreSchema)rK   rN   rL   r   r@   r   )r,   r-   r.   classmethodrE   rM   r0   r1   r2   r9   r9   =   sa    
N
N '
N 
 	
N 
N ?1?<P?	? ?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y)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   rG   rI   stringarray)rI   itemsintegerboolean)r'   r*   r6   rR   r)   rT   rV   rW   r6   )rJ   rI   
propertiesrequiredr0   )rB   r   rL   s      r2   rM   z(PredictBody.__get_pydantic_json_schema__a   se     #!' 2#X.!(FH3EF%x0#Y/%y1"()!4"I.	  
 	
r1   )r,   r-   r.   r'   r/   r*   rR   r)   rT   rV   rW   rO   rM   r0   r1   r2   rQ   rQ   U   sf    #L*#Hj
O!J
!Hj!J
!M4 [  
 
r1   rQ   c                       e Zd ZU dZdZded<   y)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 	 , r1   ra   c                      e Zd ZU ded<   y)	ResetBodyr&   r*   Nr+   r0   r1   r2   re   re   |   s    Mr1   re   c                      e Zd ZU ded<   y)VibeEditBodyr&   promptNr+   r0   r1   r2   rg   rg      s    Kr1   rg   c                      e Zd ZU ded<   y)VibeCodeBodyr&   codeNr+   r0   r1   r2   rj   rj      s    
Ir1   rj   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
   r6   Nr+   r0   r1   r2   rm   rm      s    L
Ir1   rm   c                  "    e Zd ZU ded<   ded<   y)DataWithFilesr
   r6   zlist[tuple[str, bytes]]filesNr+   r0   r1   r2   rq   rq      s    
I""r1   rq   c                  6    e Zd ZU ded<   ded<   ded<   ded<   y)	ComponentServerBlobBodyr&   r'   r(   rn   ro   rq   r6   Nr+   r0   r1   r2   rt   rt      s    L
r1   rt   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UNIFIEDr0   r1   r2   rv   rv      s    vHJ&KfGr1   rv   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
   r0   )FileData_copy_to_dirr&   pathlibPathsecrets	token_hex
model_dump)objr6   dirs     r2   unique_copyz0GradioBaseModel.copy_to_dir.<locals>.unique_copy   sI    ?c?D$$GLL%(9(9"(==>jlr1   )x)r   dict)r<   r   r   	TypeErrorr   r   	__class__	from_jsonr   r   r   is_file_data)selfr   r   s    ` r2   copy_to_dirzGradioBaseModel.copy_to_dir   sm    $I 67>??ll3	 ~~''!%% ( 
 	
r1   c                     y Nr0   rB   r   s     r2   r   zGradioBaseModel.from_json   s     	r1   N)r   zstr | pathlib.Pathr@   GradioDataModel)r@   r   )r,   r-   r.   r   rO   r   r   r0   r1   r2   r|   r|      s#    
(   r1   r|   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.   rc   r/   r0   r1   r2   r   r      s
    R
Or1   r   c                      e Zd Zedd       Zy)GradioModelc                     | di |S )Nr0   r0   r   s     r2   r   zGradioModel.from_json   s    xQxr1   N)r@   r   r,   r-   r.   rO   r   r0   r1   r2   r   r      s     r1   r   c                      e Zd Zedd       Zy)GradioRootModelc                     | |      S )Nr   r0   r   s     r2   r   zGradioRootModel.from_json   s    {r1   N)r@   r   r   r0   r1   r2   r   r      s     r1   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&   pathNotRequired[str | None]urlzNotRequired[int | None]size	orig_name	mime_typerU   	is_streamzNotRequired[dict]metaNr+   r0   r1   r2   r   r      s*    
I	  
!!&&&&O
r1   r   c                      e Zd ZU ded<   y)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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   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)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=   )rB   vinfos      r2   validate_modelzFileData.validate_model   s<     LL  1)!,~  r1   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   r0   ).0fs     r2   	<genexpr>z#FileData.is_none.<locals>.<genexpr>  s      	
 I	
s   )allr   r   r   r   r   r   s    r2   is_nonezFileData.is_none  sE      	
 					
 	
 		
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   )rB   r   s     r2   	from_pathzFileData.from_path  s     ~r1   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   r0   )	r   r   mkdirr   r   r=   shutilcopyr   )r   r   new_objnew_names       r2   r   zFileData._copy_to_dir$  sk     	S.t*yy:;;;;tyy#."t~~(((r1   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.
        Fr0   )r<   r   r   r   r   r   )rB   r   s     r2   r   zFileData.is_file_data:  sF     c4 #?c?2222  / s   ) ;;)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      s     ICD* Iz  Iz It/STD,T(#	  $	 
 
$ 
 
),  r1   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     r2   __getitem__zListFiles.__getitem__P  s    yyr1   c                ,    t        | j                        S r   )iterr   r   s    r2   __iter__zListFiles.__iter__S  s    DIIr1   N)r@   zIterator[FileData])r,   r-   r.   r/   r   r   r0   r1   r2   r   r   M  s    
 r1   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      r2   __init__z_StaticFiles.__init__^  s/    
=BC',,q/113CCs   *?c                    g | _         y r   )r   )rB   s    r2   clearz_StaticFiles.clearb  s	    r1   N)r   zlist[str | pathlib.Path]r@   None)r,   r-   r.   rc   r   r   rO   r   r0   r1   r2   r   r   W  s(     ID  r1   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+   r0   r1   r2   r   r   g  s    ""r1   r   c                  "    e Zd ZU ded<   ded<   y)Layoutr(   idzNotRequired[list[int | Layout]]childrenNr+   r0   r1   r2   r   r   n  s    G--r1   r   c                  ,    e Zd ZU ded<   ded<   ded<   y)Pagez	list[int]
componentsdependenciesr   layoutNr+   r0   r1   r2   r   r   s  s    Nr1   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:<   y;)<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 | I18nDatarJ   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    LEE
IKNO$$	O""
NLLO33
!!%%O	
  ""DD!!,,r1   r   c                  6    e Zd ZU ded<   ded<   ded<   ded<   y	)
MediaStreamChunkbytesr6   floatdurationr&   	extensionr  r   Nr+   r0   r1   r2   r  r    s    
KON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y)	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    T7MND*N"RC  T7OPD*P!$<OPIzP!$<PQIzQE7STItT,-D$-q
Lr1   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   r/   r0   r1   r2   r   r     s    !78C8r1   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]rI   zdict[str, str]python_type	componentNr+   r0   r1   r2   r"  r"    s    J
Nr1   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]returnsz,Literal['public', 'private', 'undocumented']api_visibilityNr+   r0   r1   r2   r'  r'    s    !!##  @@r1   r'  c                  "    e Zd ZU ded<   ded<   y)APIInfozdict[str, APIEndpointInfo]named_endpointsunnamed_endpointsNr+   r0   r1   r2   r,  r,    s    //11r1   r,  )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'  r,  r0   r1   r2   <module>r?     sB  @ #    # $    4 0 ?
 
 
 1 % 4  " --s3  $	 $
? ?* %W.Q%QR 
) 
>+ 	 9 9 i #I #
i T c 6y /9 oy  _459 &9 & 
i{ i iX   i .Y .
9 %-y %-Py  $9k 9I Ai A2i 2C  Is   H
 
HH