ó
    ‚¤jâ  ã                  ó  • S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKJrJrJrJr  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJrJrJrJrJr  SS
KJr   SSK!J"r"  SSK#J$r$J%r%J&r&J'r'Jr  SSK(J)r)J*r*  SSK+J,r,J-r-J.r.  SSK/J0r0J1r1  SSK2J3r3J4r4  SSK5J6r6  SSK7J8r8  SSK9J:r:  SSK;J<r<  SSK=J>r>  \(       a  SSK?J@r@  SrA               S1SSSS.                                       S2S jjjrB\"" 5        " S S5      5       rC      S3S jrD " S S5      rE\"" S S!5       " S" S#\5      5       rFS4S$ jrGS% rHS5S& jrI     S6             S7S' jjrJ   S8         S9S( jjrK\"" 5       S:S) j5       rL\"" 5       S;S* j5       rM   S<         S=S+ jjrN\"" S,S-9    S>       S?S. jj5       rO\"" S,S-9    S@       S?S/ jj5       rP\"" S,S-9    SA       S?S0 jj5       rQg)BzK
Defines helper methods useful for loading and caching Interface examples.
é    )ÚannotationsN)ÚCallableÚIterableÚMutableMappingÚSequence)Úpartial)ÚPath)ÚLock)ÚSimpleNamespace)ÚTYPE_CHECKINGÚAnyÚLiteralÚOptionalÚ
get_origin)Úutils)Údocument)Ú
componentsÚoauthÚprocessing_utilsÚroutesr   )ÚCacheÚresolve_generator)ÚContextÚLocalContextÚget_blocks_context)ÚGradioModelÚGradioRootModel)Ú
DependencyÚ	EventData)ÚError)Ú	CSVLogger)ÚI18nData)ÚHeader)ÚUnhashableKeyDict©Ú	Componentúlog.csvT)Úexample_labelsÚvisibleÚpreloadc               ó¶   • [        S0 SU _SU_SU_SU_SU_SU_SU_SU_S	U_S
U	_SU
_SU_SU_SU_SU_SU_SU_SU_SU_SS_SU_6nUR                  5         U$ )z§Top-level synchronous function that creates Examples. Provided for backwards compatibility, i.e. so that gr.Examples(...) can be used to create the Examples component.ÚexamplesÚinputsÚoutputsÚfnÚcache_examplesÚ
cache_modeÚexamples_per_pageÚ	_api_modeÚlabelÚelem_idÚrun_on_clickÚ
preprocessÚpostprocessÚapi_visibilityÚapi_nameÚapi_descriptionÚbatchr(   r)   Ú_initiated_directlyFr*   © )ÚExamplesÚcreate)r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r(   r)   r*   Úexamples_objs                        ÚœC:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\gradio/helpers.pyÚcreate_examplesrC   *   sð   € ô0 ò Ùðáðñ ðñ ð	ñ
 &ðñ ðñ ,ðñ ðñ ðñ ðñ "ðñ ðñ  ðñ &ðñ ðñ  (ð!ñ" ð#ñ$ &ð%ñ& ð'ñ( "ð)ñ* ð+€Lð. ×ÑÔØÐó    c                  ó  • \ rS rSrSr               SSSSSS.                                         SS jjjrS rSS	 jrSS
 jrSS jr	S r
  S     SS jjr S     SS jjrSrg)r?   é]   av  
This class is a wrapper over the Dataset component and can be used to create Examples
for Blocks / Interfaces. Populates the Dataset component with examples and
assigns event listener so that clicking on an example populates the input/output
components. Optionally handles example caching for fast inference.

Demos: calculator_blocks
Guides: more-on-examples-and-flagging
NTr   )r(   r)   r*   r=   c               ó^  • U(       a  [         R                  " S5        SU l        Uc7  [        R                  " SS5      R                  5       S;   a  Ub
  Ub  SU l        OUS;   a  XPl        O[        S	U 35      eU R                  (       a  Ub  Uc  [        S
5      e[        R                  " S5      =n(       aI  UcF  UR                  5       S:X  a  SnO/UR                  5       S:X  a  SnOSn[         R                  " S5        U R                  (       a  US:X  a  SU l        [        U[        5      (       d  U/nU(       a  [        U[        5      (       d  U/n[        5       R                  5       nUc  [        S5      e[        U[        5      (       a)  [        U5      S:X  d  [        US   [        5      (       a  GOn[        U[        5      (       a$  [        U5      S:X  a  U Vs/ s H  nU/PM     nnGO5[        U[        5      (       Ga  [        U5      R                  5       (       d  [        SU 35      eUn[        U5      [         -  R                  5       (       dI  [        U5      S:X  a(  [        R"                  " U5       Vs/ s H  nU/PM     nnO•[        S[         -   5      e[%        [        U5      [         -  5       n[        [&        R(                  " U5      5      n[+        S[        U5      5       Vs/ s H  nUU   S[        U5       PM     nnSSS5        O[        S5      eS/[        U5      -  nU H#  n[-        U5       H  u  nnUc  M   SUU'   M     M%     [1        UUSS9 VV s/ s H  u  nn U (       d  M  UPM     n!nn U VV"V s/ s H-  n[1        UUSS9 V"V s/ s H  u  n"n U (       d  M  U"PM     sn n"PM/     n#n"nn Ub#  [        U5      [        U5      :w  a  [        S5      eXl        U#U l        X l        UU l        U!U l        U=(       d    / U l        X@l        X€l         XÀl!        XÐl"        Xàl#        Xðl$        UU l%        UU l&        UU l'        UU l(        UU l)        SSK*J+n$  [X        RZ                  " U5         U$R\                  " U![^        R`                  " U#5      SU	UU
UUS9U l1        SSS5        [e        SSSS9U l3        [X        Rh                  " 5       [        U Rb                  Rj                  5      -  U l6        [        Rn                  Rq                  S5      S:X  a?  U Rl                  R                  5       (       a   [r        Rt                  " U Rl                  5        [        U Rl                  5      S-  U l;        [        U Rl                  5      S-  U l<        X°l=        SU l>        [        5       U l@        U R2                   V%s/ s H  n%[ƒ        5       PM     sn%U lB        U Rb                  R†                  (       aT  [-        U R4                  5       H;  u  n&nU R‰                  U5      U R€                  U Rb                  R†                  U&   '   M=     U R                  S:X  ak  [‹        S[X        RŒ                  " U Rl                  5       S 3SS!9  [        U Rv                  5      R                  5       (       a  [‹        S"5        [‹        S#5        ggs  snf s  snf s  snf ! , (       d  f       GNÇ= f! [.         a     GM¹  f = fs  sn nf s  sn n"f s  sn n"nf ! , (       d  f       GNl= fs  sn%f )$aÂ  
Parameters:
    examples: example inputs that can be clicked to populate specific components. Should be nested list, in which the outer list consists of samples and each inner list consists of an input corresponding to each input component. A string path to a directory of examples can also be provided but it should be within the directory with the python file running the gradio app. If there are multiple input components and a directory is provided, a log.csv file must be present in the directory to link corresponding inputs.
    inputs: the component or list of components corresponding to the examples
    outputs: optionally, provide the component or list of components corresponding to the output of the examples. Required if `cache_examples` is not False.
    fn: optionally, provide the function to run to generate the outputs corresponding to the examples. Required if `cache_examples` is not False. Also required if `run_on_click` is True.
    cache_examples: If True, caches examples in the server for fast runtime in examples. If "lazy", then examples are cached (for all users of the app) after their first use (by any user of the app). If None, will use the GRADIO_CACHE_EXAMPLES environment variable, which should be either "true" or "false". In HuggingFace Spaces, this parameter is True (as long as `fn` and `outputs` are also provided). The default option otherwise is False. Note that examples are cached separately from Gradio's queue() so certain features, such as gr.Progress(), gr.Info(), gr.Warning(), etc. will not be displayed in Gradio's UI for cached examples.
    cache_mode: if "lazy", examples are cached after their first use. If "eager", all examples are cached at app launch. If None, will use the GRADIO_CACHE_MODE environment variable if defined, or default to "eager".
    examples_per_page: how many examples to show per page.
    label: the label to use for the examples component (by default, "Examples")
    elem_id: an optional string that is assigned as the id of this component in the HTML DOM.
    run_on_click: if cache_examples is False, clicking on an example does not run the function when an example is clicked. Set this to True to run the function when an example is clicked. Has no effect if cache_examples is True.
    preprocess: if True, preprocesses the example input before running the prediction function and caching the output. Only applies if `cache_examples` is not False.
    postprocess: if True, postprocesses the example output after running the prediction function and before caching. Only applies if `cache_examples` is not False.
    api_visibility: Controls the visibility of the event associated with clicking on the examples. Can be "public" (shown in API docs and callable), "private" (hidden from API docs and not callable by the Gradio client libraries), or "undocumented" (hidden from API docs but callable).
    api_name: Defines how the event associated with clicking on the examples appears in the API docs. Can be a string or None. If set to a string, the endpoint will be exposed in the API docs with the given name. If None, an auto-generated name will be used.
    api_description: Description of the event associated with clicking on the examples in the API docs. Can be a string, None, or False. If set to a string, the endpoint will be exposed in the API docs with the given description. If None, the function's docstring will be used as the API endpoint description. If False, then no description will be displayed in the API docs.
    batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. Used only if cache_examples is not False.
    example_labels: A list of labels for each example. If provided, the length of this list should be the same as the number of examples, and these labels will be used in the UI instead of rendering the example values.
    visible: If False, the examples component will be hidden in the UI.
    preload: If an integer is provided (and examples are being cached eagerly and none of the input components have a developer-provided `value`), the example at that index in the examples list will be preloaded when the Gradio app is first loaded. If False, no example will be preloaded.
zWPlease use gr.Examples(...) instead of gr.helpers.Examples(...) to create the Examples.FNÚGRADIO_CACHE_EXAMPLESÚ )ÚtrueÚlazyT)TFzCThe `cache_examples` parameter should be either True or False, not z8If caching examples, `fn` and `outputs` must be providedÚGRADIO_CACHE_MODEÚeagerrK   zeThe `GRADIO_CACHE_MODE` environment variable must be either 'eager' or 'lazy'. Defaulting to 'eager'.z'The parameter `examples` cannot be Noner   é   z#Could not find examples directory: z8Could not find log file (required for multiple inputs): z»The parameter `examples` must either be a string directory or a list(if there is only 1 input component) or (more generally), a nested list, where each sublist represents a set of inputs.©ÚstrictzlIf `example_labels` are provided, the length of `example_labels` must be the same as the number of examples.)r   Útuple)r   ÚsamplesÚtyper4   Úsamples_per_pager5   r)   Úsample_labelsr'   )Úsimplify_file_dataÚverboseÚdataset_file_nameÚGRADIO_RESET_EXAMPLES_CACHEÚTruezindices.csvzWill cache examples in 'z' directory at first use.)ÚendzYIf method or examples have changed since last caching, delete this folder to reset cache.Ú
)GÚwarningsÚwarnr0   ÚosÚgetenvÚlowerÚ
ValueErrorÚ
isinstancer   r	   ÚabsoluteÚlistÚlenÚstrÚexistsÚFileNotFoundErrorÚLOG_FILEÚlistdirÚopenÚcsvÚreaderÚrangeÚ	enumerateÚ
IndexErrorÚzipr,   Únon_none_examplesr-   Úinput_has_examplesÚinputs_with_examplesr.   r/   r3   r7   r8   r9   r:   r;   r<   r(   Úworking_directoryr*   Úgradior   r   Úset_directoryÚDatasetÚcopyÚdeepcopyÚdatasetr!   Úcache_loggerÚget_cache_folderÚ_idÚcached_folderÚenvironÚgetÚshutilÚrmtreeÚcached_fileÚcached_indices_filer6   Úcache_eventr$   Únon_none_processed_examplesr
   Ú_cache_locksrR   Ú_get_processed_exampleÚprintÚabspath)'Úselfr,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r(   r)   r*   r=   Úcache_mode_envrv   ÚeÚlogsÚirt   ÚexampleÚidxÚexample_for_inputÚinpÚkeepru   Úexrs   r   Ú_Úindexs'                                          rB   Ú__init__ÚExamples.__init__i   so  € ö^ Ü�MŠMØiôð $ˆÔØÑ!ä—	’	Ð1°2Ó6×<Ñ<Ó>ÐBRÓRØ‘NØÑ'à&*�Ô#øØ˜}Ó,Ø"0ÕäØUÐVdÐUeÐfóð ð ×× B¡J°'±/ÜÐWÓXÐXä ŸišiÐ(;Ó<Ð<ˆNÕ<À*ÑBTØ×#Ñ#Ó%¨Ó0Ø$‘
Ø×%Ñ%Ó'¨6Ó1Ø#‘
à$�
Ü—’ð-ôð
 ×× :°Ó#7Ø"(ˆDÔä˜&¤(×+Ñ+Ø�XˆFÞœ: g¬x×8Ñ8Ø�iˆGä ›FŸO™OÓ-ÐàÑÜÐFÓGÐGÜ˜¤$×'Ñ'Ü�‹M˜QÓ¤*¨X°a©[¼$×"?Ñ"?áä�x¤×&Ñ&¬3¨v«;¸!Ó+;á%-Ó.¢X ˜›¡XˆHÐ.‰HÜ˜¤#×&Ò&Ü˜“>×(Ñ(×*Ñ*Ü'Ø9¸(¸ÐDóð ð !)ÐÜ˜“N¤XÑ-×5Ñ5×7Ñ7Ü�v“; !Ó#Ü-/¯ZªZ¸Ô-AÓBÒ-A¨ £Ñ-A�HÐB�Hä+ØRÜ"ñ#óð ô
 œ$˜x›.¬8Ñ3Ô4¸Ü#¤C§J¢J¨tÓ$4Ó5�Hä<AÀ!ÄSÈÃ]Ô<Só Ú<S°q˜ ™ M¤c¨&£kÓ2Ñ<Sð ð  ÷ 5Ð4ô ðGóð ð $˜W¤s¨6£{Ñ2ÐÛˆGÜ*3°GÖ*<Ñ&�Ð&Ø$Ó0ðØ26Ð*¨3Ó/ó +=ñ  ô $' vÐ/AÈ%Ò#Pô 
Ú#P‘K�S˜$ÔTX�CÑ#Pð 	ñ  
ñ $õ
ò $�ô #& gÐ/AÈ%Ò"Pôâ"P‘J�R˜Ü÷ Ù"Põñ
 $ð 	ò 
ð Ñ%¬#¨nÓ*=ÄÀXÃÓ*NÜØ~óð ð !ŒØ!2ˆÔØŒØ"4ˆÔØ$8ˆÔ!Ø—} "ˆŒØŒØ"ŒØ$ŒØ&ÔØ,ÔØ$,ŒØ<KˆÔØˆŒ
Ø,ˆÔØ!2ˆÔØˆŒå%ä× Ò Ð!2Õ3Ø%×-Ò-Ø/ÜŸšÐ&7Ó8ØØØ!2ØØØ,ñ	ˆDŒL÷ 4ô &Ø$¨eÀyñ
ˆÔô #×3Ò3Ó5¼¸D¿L¹L×<LÑ<LÓ8MÑMˆÔä�J‰J�N‰NÐ8Ó9¸VÓCØ×"Ñ"×)Ñ)×+Ñ+ä�MŠM˜$×,Ñ,Ô-Ü × 2Ñ 2Ó3°iÑ?ˆÔÜ#'¨×(:Ñ(:Ó#;¸mÑ#KˆÔ Ø(ÔØ.2ˆÔÜ+<Ó+>ˆÔ(Ø-1¯]ª]Ó;ª]¨œTžV©]Ñ;ˆÔà�<‰<××Ü"+¨D×,BÑ,BÖ"C‘��wà×/Ñ/°Ó8ð ×0Ñ0°·±×1EÑ1EÀeÑ1LÓMñ #Dð
 ×Ñ &Ó(ÜØ*¬5¯=ª=¸×9KÑ9KÓ+LÐ*MÐMfÐgØòô �D×$Ñ$Ó%×,Ñ,×.Ñ.ÜØoôô �$�Kð )ùòY /ùò  Cùò ÷ 5Ö4ûô& &ó Ûðüó 
ùóùô
÷B 4Ö3üò4 <sx   Ç#[Ê[Ë7[!Ë8[Ì[!Í[3Í/\Î\Î\Î$\Î6\Î<\Ò1\×\*Û[!Û!
[0Û3
\Ü\Ü\Ü
\'c                ó¾  • XR                   ;   a  U R                   U   $ [        R                  " U R                  5         / n[	        U R
                  USS9 Hh  u  p4UR                  U5      n[        U[        [        45      (       a  UR                  5       n[        R                  " UUSS9nUR                  U5        Mj     SSS5        U$ ! , (       d  f       W$ = f)aW  
This function is used to get the post-processed example values, ready to be used
in the frontend for each input component. For example, if the input components are
image components, the post-processed example values will be the a list of ImageData dictionaries
with the path, url, size, mime_type, orig_name, and is_stream keys. For any input components
that should be skipped (b/c they are None for all samples), they will simply be absent
from the returned list

Parameters:
    example: a list of example values for each input component, excluding those components
    that have all None values
FrO   T)r8   N)rˆ   r   rx   rv   rr   ru   r8   rc   r   r   Ú
model_dumpr   Úmove_files_to_cacheÚappend)r�   r’   ÚsubÚ	componentÚsampleÚprediction_values         rB   rŠ   ÚExamples._get_processed_exampleD  sÓ   € ð ×6Ñ6Ó6Ø×3Ñ3°GÑ<Ð<Ü× Ò  ×!7Ñ!7Õ8ØˆCÜ%(Ø×)Ñ)¨7¸5ô&Ñ!�	ð $-×#8Ñ#8¸Ó#@Ð ÜÐ.´Ä+Ð0N×OÑOØ'7×'BÑ'BÓ'DÐ$Ü#3×#GÒ#GØ$ØØ $ñ$Ð ð
 —
‘
Ð+Ö,ñ&÷ 9ð ˆ
÷ 9Ô8ð ˆ
ús   ¿BCÃ
Cc                ój  ^ • [        5       n[        R                  =(       d    U(       a  UR                  OST l        U(       GaÂ  T R                  (       a/  T R                  R                  R	                  T R
                  5        T R                  (       Ga¬  U 4S jnSU 4S jjnT R                  R                  UT R                  /T R                  SSSSS9R                  UT R                  /T R                  ST R                  T R                  T R                  S9=T l        T l        T R"                  SLGa  T R                  S	:w  aö  T R                  (       aä  [%        S
 T R&                   5       5      (       dÂ  T R                  R)                  U[*        R,                  " T R"                  T R.                  T R"                     45      /T R                  SSSSS9  T R                  R)                  U[*        R,                  " T R"                  T R.                  T R"                     45      /T R                  SSSS9  gggggU 4S jnT R                  R                  UT R                  /T R&                  SSST R                  T R                  T R                  S9	T l        T R0                  (       aS  T R2                  c  [5        S5      eT R                   R                  T R2                  T R                  T R                  SS9  gg[6        R8                  " ST R                  (       a  SOS S35        g)z2Creates the Dataset component to hold the examplesNc                óZ   >• U u  pTR                  U5      n[        R                  " U5      $ ©N)rŠ   r   Úresolve_singleton)Úexample_tupler˜   Úexample_valueÚprocessed_exampler�   s       €rB   Úload_example_inputÚ+Examples.create.<locals>.load_example_inputo  s.   ø€ Ø'4Ñ$�AØ(,×(CÑ(CÀMÓ(RÐ%Ü ×2Ò2Ð3DÓEÐErD   c                óZ   >• U u  p#TR                  X!5      n[        R                  " U5      $ r§   )Úload_from_cacher   r¨   )r©   ÚrequestÚ
example_idr˜   Úcached_outputsr�   s        €rB   Úload_example_outputÚ,Examples.create.<locals>.load_example_outputt  s+   ø€ Ø$1‘M�JØ%)×%9Ñ%9¸*Ó%N�NÜ ×2Ò2°>ÓBÐBrD   ÚhiddenFÚundocumented)r-   r.   Úshow_progressr8   Úqueuer9   )r-   r.   r8   r:   r;   r9   rK   c              3  ó@   #   • U  H  nS UR                   ;   v •  M     g7f)ÚvalueN)Úconstructor_args)Ú.0r•   s     rB   Ú	<genexpr>Ú"Examples.create.<locals>.<genexpr>�  s"   é € ð  â#<˜Cð   3×#7Ñ#7Ö7Ú#<ùs   ‚)r-   r.   r8   r·   r9   c           	     ó^  >• U u  pTR                  U5      n[        TR                  5      S:X  a'  [        SSUS   0TR                  R
                  S   D6$ [        [        TR                  5      5       Vs/ s H)  n[        SSX4   0TR                  R
                  U   D6PM+     sn$ s  snf )NrN   rº   r   r>   )rŠ   rf   ru   Úupdater|   Úcomponent_propsro   )r©   r˜   rª   r«   r‘   r�   s        €rB   Úload_exampleÚ%Examples.create.<locals>.load_example°  sÄ   ø€ Ø'4Ñ$�AØ(,×(CÑ(CÀMÓ(RÐ%Ü˜4×4Ñ4Ó5¸Ó:Ü%ñ  Ø"3°AÑ"6ð à"Ÿl™l×:Ñ:¸1Ñ=ñ ð ô "'¤s¨4×+DÑ+DÓ'EÔ!Fóò
 "G˜Aô	 ñ Ø"3Ñ"6ðà"Ÿl™l×:Ñ:¸1Ñ=ôñ "Gñð ùò s   Á70B*)r-   r.   r·   r8   r¸   r:   r;   r9   z.Cannot run_on_click if no function is provided)r-   r.   r9   zhIf an Examples object is created outside a Blocks Context, make sure to call `examples.dataset.render()`zand `examples.create()`rI   z) to render the examples in the interface.)r°   zroutes.Request)r   r   Ú
root_blockÚextra_startup_eventsrŸ   Ú_start_cachingr0   r|   Úclickr-   Úthenr.   r:   r;   r9   r‡   Úload_input_eventr*   Úanyru   Úloadr   ÚStaters   r6   r/   rb   r]   r^   )r�   Úblocks_configr¬   r³   rÂ   s   `    rB   r@   ÚExamples.createc  s	  ø€ ä*Ó,ˆÜ!×,Ñ,÷ 
Þ(5ˆM×$Ò$¸4ð 	Œ÷ Ø��Ø—‘×4Ñ4×;Ñ;¸D×<OÑ<OÔPà×"×"Ð"õF÷
Cð
 <@¿<¹<×;MÑ;MØ&Ø ŸL™L˜>Ø ŸK™KØ"*Ø %ØØ#1ð <Nð <÷ ‘$Ø'Ø ŸL™L˜>Ø ŸL™LØ %Ø!Ÿ]™]Ø$(×$8Ñ$8Ø#'×#6Ñ#6ð ð ð�Ô  4Ô#8ð& —L‘L¨Ó-Ø×+Ñ+¨vÓ5ØŸŸÜñ  à#'×#<Ò#<ó ÷ ñ ð
 —O‘O×(Ñ(Ø*ä&×,Ò,Ø!%§¡¨t×/EÑ/EÀdÇlÁlÑ/SÐ Tóð ð
 !%§¡Ø&.Ø$)Ø#Ø'5ð )ñ ð —O‘O×(Ñ(Ø+ä&×,Ò,Ø!%§¡¨t×/EÑ/EÀdÇlÁlÑ/SÐ Tóð ð
 !%§¡Ø$)Ø&.Ø'5ð )ò ð%ð (ð 6ð .õHð  )-¯©×(:Ñ(:Ø Ø ŸL™L˜>Ø ×5Ñ5Ø"*Ø %ØØ!Ÿ]™]Ø$(×$8Ñ$8Ø#'×#6Ñ#6ð );ð 
)�Ô%ð ×$×$Ø—w‘w‘Ü(ØLóð ð ×)Ñ)×.Ñ.ØŸ™Ø#Ÿ{™{Ø $§¡Ø'5ð	 /ò ð %ô �MŠMØzð  Y]÷  Yl÷  Ylñ  |Uð  rtð  {uð  u^ð  _õrD   c              ƒ  ó¬  #   • SSK nUR                  5        nU R                   Vs/ s H  oR                  5       PM       nUR	                  U R
                  U R                  U R                  5        SSS5        WR                  5         UR                  UR                  R                  S   WS5      I Sh  v•N $ s  snf ! , (       d  f       NU= f N7f)a~  
This is a way that we can postprocess the data manually, since we set postprocess=False in the lazy_cache
event handler. The reason we did that is because we don't want to postprocess data if we are loading from
the cache, since that has already been postprocessed. We postprocess this data manually if we are calling
the function using the _handle_callable_as_generator() method.
r   N)rw   ÚBlocksr.   ÚrenderrË   r/   r-   ÚunrenderÚpostprocess_dataÚdefault_configÚfns)r�   ÚoutputÚgrÚdemos       rB   Ú_postprocess_outputÚExamples._postprocess_outputÜ  s—   é € ó 	à�Y‰YŒ[˜DØ+/¯<ª<Ó8ª< �]‰]Ž_©<Ñ8Ø�I‰I�d—g‘g˜tŸ{™{¨D¯L©LÔ9÷ ð 	�‰ŒØ×*Ñ*¨4×+>Ñ+>×+BÑ+BÀ1Ñ+EÀvÈtÓT×TÐTùò 9÷ �[úñ Uùs9   ‚C—C¦B<¿3CÁ2ACÂ7CÂ8CÂ<CÃ
CÃCc                ó@  • [        U R                  5      R                  5       (       a`  [        U R                  5       nU Vs/ s H  n[	        UR                  5       5      PM     nnS S S 5        UW;   a  UR                  U5      nU$ g s  snf ! , (       d  f       N-= fr§   )r	   r†   rh   rl   ÚintÚstripr™   )r�   Úexample_indexÚfÚlineÚcached_indicesÚcached_indexs         rB   Ú_get_cached_index_if_cachedÚ$Examples._get_cached_index_if_cachedë  s€   € Ü�×(Ñ(Ó)×0Ñ0×2Ñ2Ü�d×.Ñ.Ô/°1Ù@AÓ!BÂ¸¤# d§j¡j£lÖ"3Á�Ð!B÷ 0à Ó.Ø-×3Ñ3°MÓB�Ø#Ð#Øùò	 "C÷ 0Õ/ús   ¾BÁ#B
Á&BÂ
BÂ
Bc              ƒ  óP  #   • U R                   (       ab  U R                   HR  n[        U Vs/ s H	  o"c  M  UPM     sn5      [        U R                  5      :w  d  M<  [        R
                  " S5          O   U R                   SL a  U R                  5       I S h  v•N   g g s  snf  N7f)NaQ  Examples will be cached but not all input components have example values. This may result in an exception being thrown by your function. If you do get an error while caching examples, make sure all of your inputs have example values for all of your examples or you provide default values for those particular parameters in your function.T)r0   r,   rf   r-   r]   r^   Úcache)r�   r’   r—   s      rB   rÆ   ÚExamples._start_cachingô  s‡   é € Ø××ØŸ=œ=�Ü¡WÓ?¢W˜rŸ¡WÑ?Ó@ÄCÈÏÉÓDTÕTÜ—M’Mðjôñ ñ )ð ×Ñ $Ò&Ø—*‘*“,×Ñð 'ùò @ñ ùs&   ‚*B&¬B
¶B
¼B&Á<B&ÂB$ÂB&c           
   ƒ  ó  #   • U R                   c  [        S5      e[        U R                  5      R	                  5       (       a1  Uc.  [        S[        R                  " U R                  5       S35        g[        S[        R                  " U R                  5       S35        U R                  R                  U R                  U R                  5        U R                  c   e[        U R                  5      u  p4Uc  / nSSKJn  U R                   R                   R#                  U" [$        R                   S	5      /UU R&                  U R                  U R(                  =(       a    U R*                  (       + U R,                  =(       a    U R*                  (       + U R.                  S
9u  pg U R                  c  [1        S5      eSn[3        U R4                  5       GH“  u  pšUb  X‘:w  a  M  U R7                  U
5      n[3        U R8                  5       H   u  pÍU(       a  M  UR;                  US5        M"     U R.                  (       a  U Vs/ s H  oî/PM     nn[        R<                  " 5          U R                   R?                  U R                   R                   R@                  U   UUU RB                  S:g  S9I Sh  v•N nSSS5        WS   nU(       a  [E        U R                  UU5      I Sh  v•N nU R.                  (       a  U Vs/ s H  oîS   PM	     nnU R                  RG                  U5      S-
  n[I        U RJ                  S5       nURM                  Ub  UOU	 S35        SSS5        GM–     UU R                   R                   R@                  RO                  U5        $ s  snf  Ní! , (       d  f       Nñ= f NÍs  snf ! , (       d  f       GMø  = f! U R                   R                   R@                  RO                  U5        f = f7f)zò
Caches examples so that their predictions can be shown immediately.
Parameters:
    example_id: The id of the example to process (zero-indexed). If None, all examples are cached.
    request: The request that triggered lazy caching, if any.
Nz1Cannot cache examples if not in a Blocks context.zUsing cache from 'zg' directory. If method or examples have changed since last caching, delete this folder to clear cache.
zCaching examples at: 'Ú'r   )ÚEventListenerMethodrË   )r/   r-   r.   r7   r8   r<   úself.outputs is missingrK   )Úblock_fnr-   r°   Úin_event_listenerÚdatarN   Úar\   )(rÄ   r    r	   r…   rh   r‹   r   rŒ   r€   r}   Úsetupr.   r/   r   Úgradio.eventsrê   rÔ   Úset_event_triggerr   r-   r7   r3   r8   r<   rb   rp   rs   rŠ   rt   ÚinsertÚMatplotlibBackendManangerÚprocess_apirÕ   r0   Ú"merge_generated_values_into_outputÚflagrl   r†   ÚwriteÚpop)r�   r±   r°   r/   Úgenerated_valuesrê   r˜   Úfn_indexrâ   r‘   r’   Úprocessed_inputr™   r–   rº   Ú
predictionrÖ   rß   s                     rB   ræ   ÚExamples.cache  s]  é € ð �?‰?Ñ"ÜÐKÓLÐLÜ�× Ñ Ó!×(Ñ(×*Ñ*¨zÑ/AÜØ$¤U§]¢]°4×3EÑ3EÓ%FÐ$Gð  Hpð  qôð~ ôw Ð*¬5¯=ª=¸×9KÑ9KÓ+LÐ*MÈQÐOÔPØ×Ñ×#Ñ# D§L¡L°$×2DÑ2DÔEØ—7‘7Ñ&Ð&Ð&Ü#4°T·W±WÓ#=Ñ ˆBØÑ'Ø#%Ð õ :àŸ/™/×8Ñ8×JÑJÙ$¤W×%7Ñ%7¸Ó@ÐAØØ—{‘{ØŸ™ØŸ?™?×A°4·>±>Ô/AØ ×,Ñ,×C°T·^±^Ô1CØ—j‘jð Kð ‰KˆAð&AØ—<‘<Ñ'Ü$Ð%>Ó?Ð?Ø#�Ü"+¨D×,BÑ,B×"C‘J�AØ!Ñ-°!³/Ù Ø&*×&AÑ&AÀ'Ó&J�OÜ'0°×1HÑ1HÖ'I™˜ß#˜tØ+×2Ñ2°5¸$Ö?ñ (Jð —z—zÙ@OÓ*PÂ°u«7Á˜Ð*PÜ×8Ò8Õ:ð ,0¯?©?×+FÑ+FØ%)§_¡_×%CÑ%C×%GÑ%GÈÑ%QØ#2Ø$+Ø.2×.AÑ.AÀVÑ.Kð	 ,Gð ,÷ &˜
÷	 ;ð (¨Ñ/�FÞ'Ü'IØ ŸL™LØ,Ø"ó(÷ "˜ð
 —z—zÙ8>Ó!?º¨u¨¤(¹˜Ð!?Ø#'×#4Ñ#4×#9Ñ#9¸&Ó#AÀAÑ#E�LÜ˜d×6Ñ6¸Ô<ÀØŸ™°Ñ1G¡:ÈQÐ"OÈrÐ RÔS÷ =Ò<ñ; #Dð> $ð —‘×.Ñ.×2Ñ2×6Ñ6°xÕ@ùò5 +Qñ
&÷	 ;Õ:úñ"ùò "@ç<×<ûð
 —‘×.Ñ.×2Ñ2×6Ñ6°xÕ@üs˜   ‚F#PÆ&A/O È+O ÉNÉO É'AN%Ê5N#Ê6N%Ê:.O Ë(N6Ë)O ÌN8Ì6O ÍN=Í O Í.0PÎO Î#N%Î%
N3	Î/O Î8O Î=
O	Ï	O Ï1PÐPc                ó¸  • U R                   U      U R                  U5      nUc/  [        R                  " U R                  X5      nUc  [        S5      eSSS5        [        U R                  SS9 n[        [        R                  " U5      5      nSSS5        WS-   [        W5      :¼  a  [        S5      eXSS-      n/ nU R                  c  [        S5      e[        U R                  USS9 H‹  u  p‰U	n
 [        R                   " U	5      n[#        U[        5      (       a!  [#        U[$        R&                  5      (       a  Un
[(        R*                  " U5      (       d  [-        S	5      eUR/                  U5        M�     U$ ! , (       d  f       GN/= f! , (       d  f       GN= f! [        [,        [0        4 a$    UR/                  UR3                  U
5      5         Mí  f = f)
zÀLoads a particular cached example for the interface.
Parameters:
    example_id: The id of the example to process (zero-indexed).
    request: The request that triggered lazy caching, if any.
Nz&Cached example not found in cache filezutf-8)ÚencodingrN   rë   FrO   zvalue wasn't an update)r‰   rã   Úclient_utilsÚsynchronize_asyncræ   rq   rl   r…   re   rm   rn   rf   r.   rb   rr   ÚastÚliteral_evalrc   r   ÚFiler   Úis_prop_updateÚ	TypeErrorrŸ   ÚSyntaxErrorÚread_from_flag)r�   r±   r°   râ   ræ   r,   r’   rÖ   r¡   rº   Úvalue_to_useÚvalue_as_dicts               rB   r¯   ÚExamples.load_from_cacheR  s¡  € ð ×Ñ˜zÓ*Ø×;Ñ;¸JÓGˆLØÑ#Ü+×=Ò=Ø—J‘J 
ó �ð  Ñ'Ü$Ð%MÓNÐN÷ +ô �$×"Ñ"¨WÒ5¸ÜœCŸJšJ uÓ-Ó.ˆH÷ 6ð ˜!Ñœs 8›}Ó,ÜÐEÓFÐFØ¨!Ñ+Ñ,ˆàˆØ�<‰<ÑÜÐ6Ó7Ð7Ü # D§L¡L°'À%Ô HÑˆIØ ˆLðFÜ #× 0Ò 0°Ó 7�ô ˜m¬T×2Ñ2´zØœzŸ™÷8ñ 8ð $1�LÜ×+Ò+¨M×:Ñ:Ü#Ð$<Ó=Ð=Ø—‘˜mÖ,ñ !Ið  ˆ÷G +Ö*ú÷ 6Ö5ûô0 ¤	¬;Ð7ó FØ—‘˜i×6Ñ6°|ÓD×EðFús+   �AE<Á0 FÃ3BF Å<
FÆ
FÆ 5GÇG)r3   r‰   r;   r:   r9   r<   r‡   r0   r}   r…   r€   r†   r|   r(   r,   r/   rt   r-   ru   rÉ   rs   rˆ   r.   r8   r*   r7   rÄ   r6   rv   )NNNNé
   Fr?   NFTTr¶   rÂ   NF)*r,   ú!list[Any] | list[list[Any]] | strr-   úComponent | Sequence[Component]r.   ú&Component | Sequence[Component] | Noner/   úCallable | Noner0   úbool | Noner1   úLiteral['eager', 'lazy'] | Noner2   rÜ   r3   Úboolr4   ústr | I18nData | Noner5   ú
str | Noner6   r  r7   r  r8   r  r9   ú,Literal['public', 'private', 'undocumented']r:   r  r;   ústr | None | Literal[False]r<   r  r(   úlist[str] | Noner)   úbool | Literal['hidden']r*   úint | Literal[False]r=   r  ©ÚreturnÚNone)r  re   )r  ú
int | None©NN)r±   r  r°   úroutes.Request | Noner  r  r§   )r±   rÜ   r°   r!  r  z	list[Any])Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rš   rŠ   r@   rÙ   rã   rÆ   ræ   r¯   Ú__static_attributes__r>   rD   rB   r?   r?   ]   s¬  † ñð ;?Ø"Ø&*Ø6:Ø!#ØØ'1Ø"Ø"ØØ ØGUØ-Ø7;Øð%Yð( ,0Ø,0Ø()Ø$(ñ/Yà3ðYð 0ðYð 8ð	Yð
 ðYð $ðYð 4ðYð ðYð ðYð %ðYð ðYð ðYð ðYð ðYð EðYð  ð!Yð" 5ð#Yð$ ð%Yð( )ð)Yð* *ð+Yð, &ð-Yð. "ö/Yòvô>wôrUôòð" "&Ø)-ðMàðMð 'ðMð 
õ	Mðd *.ð-àð-ð 'ð-ð 
÷	-ð -rD   r?   c              ƒ  ó–  #   • SSK Jn  [        U 5       GH’  u  pE[        XS5      (       d  M  UR                  (       d  M+  / nS nS[
        R                  " 5        3n [        U5       HÍ  u  pš[        U 5      S:”  a  X¤   n
UR                  U
5      n[        U[        [        45      (       a  UR                  5       nUR                  X¸U	S:H  5      I S h  v•N nU	S:X  a3  US   R                  S5      =n(       a  [        U5      R                  SS  nUS   (       d  M¶  UR!                  US   S   5        MÏ     UR#                  U5      I S h  v•N =n(       a  UR!                  US   5        UR%                  U5        UR'                  XgS9I S h  v•N nUR                  5       X$'   GM•     U$  NÙ Nb! UR%                  U5        f = f N77f)Nr   )ÚStreamingOutputzcache/rN   Ú	orig_namerî   )Údesired_output_format)Úgradio.components.baser)  rp   rc   Ú	streamingÚuuidÚuuid4rf   r8   r   r   r�   Ústream_outputr‚   r	   ÚsuffixrŸ   Úflush_stream_outputÚend_stream_outputÚcombine_stream)r   rú   rÖ   r)  Úoutput_indexÚoutput_componentÚbinary_chunksr+  Ú	stream_idr‘   ÚchunkÚprocessed_chunkÚstream_chunkr*  Úfinal_chunkÚcombined_outputs                   rB   rö   rö   ‚  s¼  é € õ 7ä*3°J×*?Ñ&ˆÜÐ&×8Ó8Ð=M×=W×=WÑ=WØˆMØ$(Ð!ð !¤§¢£ Ð/ˆIð>Ü )Ð*:Ö ;‘H�AÜ˜:“¨Ó*Ø %Ñ 3˜Ø&6×&BÑ&BÀ5Ó&I�OÜ! /´KÄÐ3Q×RÑRØ*9×*DÑ*DÓ*F˜Ø)9×)GÑ)GØ'°A¸±Fó*÷ $�Lð ˜A“v°¸Q±×0CÑ0CÀKÓ0PÐ#P 9Õ#PÜ04°Y³×0FÑ0FÀqÀrÐ0JÐ-Ø# A—‘Ø%×,Ñ,¨\¸!©_¸VÑ-DÖEñ !<ð )9×(LÑ(LÈYÓ(W×"WÐW�;ÕWØ!×(Ñ(¨°VÑ)<Ô=à ×2Ñ2°9Ô=Ø$4×$CÑ$CØð %Dð %÷ ˆOð $3×#=Ñ#=Ó#?ˆFÔ ñ9 +@ð< €Mñ!$ñ #Xøð !×2Ñ2°9Õ=úñùs_   ‚&G	¬G	¿G	ÁA7F1ÃF-ÃAF1Ä/F1ÅF/ÅF1Å,#G	ÆGÆG	Æ-F1Æ/F1Æ1GÇG	c                  ó@   • \ rS rSr  S             SS jjrSrg)ÚTrackedIterablei¨  Nc                óX   • Xl         X l        X0l        X@l        XPl        X`l        Xpl        g r§   )Úiterabler™   ÚlengthÚdescÚunitÚ_tqdmÚprogress)r�   rA  r™   rB  rC  rD  rE  rF  s           rB   rš   ÚTrackedIterable.__init__©  s'   € ð !ŒØŒ
ØŒØŒ	ØŒ	ØŒ
Ø �rD   )rE  rC  r™   rA  rB  rF  rD  r   )rA  úIterable | Noner™   úint | float | NonerB  rI  rC  r  rD  r  rF  úfloat | Noner  r  )r"  r#  r$  r%  rš   r'  r>   rD   rB   r?  r?  ¨  sX   † ð Ø!%ð!à!ð!ð "ð!ð #ð	!ð
 ð!ð ð!ð ð!ð 
÷!ð !rD   r?  Ú__call__Útqdmc                  ó¨   • \ rS rSrSr S SS jjrS rS rS r    S       SS jjr	    S       SS	 jjr
SSS
 jjrS r\S 5       rSrg)ÚProgressi¼  aÕ  
The Progress class provides a custom progress tracker that is used in a function signature.
To attach a Progress tracker to a function, simply add a parameter right after the input parameters that has a default value set to a `gradio.Progress()` instance.
The Progress tracker can then be updated in the function by calling the Progress object or using the `tqdm` method on an Iterable.
Example:
    import gradio as gr
    import time
    def my_function(x, progress=gr.Progress()):
        progress(0, desc="Starting...")
        time.sleep(1)
        for i in progress.tqdm(range(100)):
            time.sleep(0.1)
        return x
    gr.Interface(my_function, gr.Textbox(), gr.Textbox()).launch()
Guides: progress-bars
c                ó@   • U(       a
  [        5         Xl        / U l        g)z…
Parameters:
    track_tqdm: If True, the Progress object will track any tqdm.tqdm iterations with the tqdm library in the function.
N)Ú
patch_tqdmÚ
track_tqdmÚ	iterables)r�   rQ  s     rB   rš   ÚProgress.__init__Ï  s   € ö ÜŒLØ$ŒØ02ˆ�rD   c                óX   • U R                   (       d  gU R                   S   R                  $ )Nr   éÿÿÿÿ)rR  rB  ©r�   s    rB   Ú__len__ÚProgress.__len__Ü  s!   € Ø�~�~ØØ�~‰~˜bÑ!×(Ñ(Ð(rD   c                ó   • U $ r§   r>   rV  s    rB   Ú__iter__ÚProgress.__iter__á  s   € ØˆrD   c                óV  • U R                  5       nU(       aè  U R                  S   n[        UR                  S5      (       di  [	        U R                  5      S:”  aP  U R                  R                  5       n[        UR                  S5      (       d  [	        U R                  5      S:”  a  MP  U" U R                  5        UR                  c  [        S5      eU=R                  S-  sl         [        UR                  5      $ U $ ! [         a    U R                  R                  5         e f = f)z6
Updates progress tracker with next item in iterable.
rU  Ú__next__r   úIndex not set.rN   )
Ú_progress_callbackrR  ÚhasattrrA  rf   rù   r™   rq   ÚnextÚStopIteration)r�   ÚcallbackÚcurrent_iterables      rB   r]  ÚProgress.__next__ä  sü   € ð ×*Ñ*Ó,ˆÞØ#Ÿ~™~¨bÑ1ÐäÐ,×5Ñ5°z×BÑBÜ˜Ÿ™Ó'¨!Ó+à#'§>¡>×#5Ñ#5Ó#7Ð ô Ð,×5Ñ5°z×BÑBÜ˜Ÿ™Ó'¨!Õ+ñ �T—^‘^Ô$Ø×%Ñ%Ñ-Ü Ð!1Ó2Ð2Ø×"Ò" aÑ'Õ"ðÜÐ,×5Ñ5Ó6Ð6ð
 ˆKøô	 !ó Ø—‘×"Ñ"Ô$Øðús   Ã+D Ä&D(Nc                ó¶   • U R                  5       nU(       aA  [        U[        5      (       a  Uu  psSnOSnU" U R                  [	        SXsX$XQ5      /-   5        gU$ )a‰  
Updates progress tracker with progress and message text.
Parameters:
    progress: If float, should be between 0 and 1 representing completion. If Tuple, first number represents steps completed, and second value represents total steps or None if unknown. If None, hides progress bar.
    desc: description to display.
    total: estimated total number of steps.
    unit: unit of iterations.
N)r_  rc   rQ   rR  r?  )r�   rF  rC  ÚtotalrD  rE  rc  r™   s           rB   rK  ÚProgress.__call__ü  s`   € ð  ×*Ñ*Ó,ˆÞÜ˜(¤E×*Ñ*Ø'‘�Ø‘à�ÙØ—‘Ü" 4¨°tÀ5ÓSÐTñUõð
 ˆOrD   c           
     ó‚  • U R                  5       nU(       a�  Uc=  [        SSX2XE5      nU R                  R                  U5        U" U R                  5        U $ [	        US5      (       a  [        U5      OUnU R                  R                  [        [        U5      SX‚XE5      5        U $ Uc  [        / 5      $ [        U5      $ )zá
Attaches progress tracker to iterable, like tqdm.
Parameters:
    iterable: iterable to attach progress tracker to.
    desc: description to display.
    total: estimated total number of steps.
    unit: unit of iterations.
Nr   rW  )r_  r?  rR  rŸ   r`  rf   Úiter)	r�   rA  rC  rg  rD  rE  rc  Únew_iterablerB  s	            rB   rL  ÚProgress.tqdm  s©   € ð  ×*Ñ*Ó,ˆÞØÑÜ.¨t°Q¸ÀTÓQ�Ø—‘×%Ñ% lÔ3Ù˜Ÿ™Ô(Ø�Ü&-¨h¸	×&BÑ&B”S˜”]ÈˆFØ�N‰N×!Ñ!Ü¤ X£°°6ÀÓMôð ˆKØÑÜ˜“8ˆOÜ�H‹~ÐrD   c                ó  • U R                  5       nU(       ah  [        U R                  5      S:”  aO  U R                  S   nUR                  c  [	        S5      eU=R                  U-  sl        U" U R                  5        gg)zi
Increases latest iterable with specified number of steps.
Parameters:
    n: number of steps completed.
r   rU  Nr^  )r_  rf   rR  r™   rq   )r�   Únrc  rd  s       rB   rÀ   ÚProgress.update:  sl   € ð ×*Ñ*Ó,ˆÞœ˜DŸN™NÓ+¨aÓ/Ø#Ÿ~™~¨bÑ1ÐØ×%Ñ%Ñ-Ü Ð!1Ó2Ð2Ø×"Ò" aÑ'Õ"Ù�T—^‘^Õ$àrD   c                ó:  • U R                  5       nU(       a„  [        [        U R                  5      5       HO  n[	        U R                  U   R
                  5      [	        U5      :X  d  M4  U R                  R                  U5          O   U" U R                  5        gg)z$
Removes iterable with given _tqdm.
N)r_  ro   rf   rR  ÚidrE  rù   )r�   rE  rc  r‘   s       rB   ÚcloseÚProgress.closeJ  ss   € ð ×*Ñ*Ó,ˆÞÜœ3˜tŸ~™~Ó.Ö/�Ü�d—n‘n QÑ'×-Ñ-Ó.´"°U³)Õ;Ø—N‘N×&Ñ& qÔ)Ùñ 0ñ �T—^‘^Õ$àrD   c                 óÜ   • [         R                  R                  S 5      n [         R                  R                  S 5      nU (       a  U(       d  g [	        U R
                  R                  U5      $ r§   )r   Úblocksr‚   Úevent_idr   Ú_queueÚset_progress)ru  rv  s     rB   r_  ÚProgress._progress_callbackX  sM   € ä×$Ñ$×(Ñ(¨Ó.ˆÜ×(Ñ(×,Ñ,¨TÓ2ˆÞž8ØÜ�v—}‘}×1Ñ1°8Ó<Ð<rD   )rR  rQ  )F)rQ  r  )NNÚstepsN)rF  z%float | tuple[int, int | None] | NonerC  r  rg  rI  rD  rg   )rA  rH  rC  r  rg  rI  rD  rg   ©rN   )rn  zint | float)r"  r#  r$  r%  r&  rš   rW  rZ  r]  rK  rL  rÀ   rr  Ústaticmethodr_  r'  r>   rD   rB   rN  rN  ¼  sº   † ñð& !ð3àõ3ò)ò
òð6  Ø$(ØØðà7ðð ðð "ð	ð
 õðB  Ø$(ØØðà!ðð ðð "ð	ð
 õö@ò ð ñ=ó ó=rD   rN  c                 ó  •  [        S5      n  SS jnS nSS jnS nS n[        U R                  S5      (       d%  U R                  R                  U R                  l        [        U R                  S5      (       d%  U R                  R                  U R                  l        [        U R                  S	5      (       d%  U R                  R                  U R                  l	        [        U R                  S
5      (       d%  U R                  R                  U R                  l        [        U R                  S5      (       d%  U R                  R                  U R                  l        XR                  l        X0R                  l        X@R                  l        XPR                  l
        X R                  l        [        U S5      (       a8  [        U R                  S5      (       a  U R                  U R                  l        g g g ! [         a     g f = f)NrL  c                óB  • [         R                  R                  S 5      U l        U R                  bU  U R                  R	                  5       nUb8  U R                  R                  XX4U S9  [        [        R                  S5      US'   U R                  " XU/UQ7SU0UD6  g )N)rE  ÚwÚfilerD  )
r   rF  r‚   Ú	_progressr_  rL  rl   r_   ÚdevnullÚ__init__orig__)r�   rA  rC  rg  rD  ÚargsÚkwargsrc  s           rB   Ú	init_tqdmÚpatch_tqdm.<locals>.init_tqdmg  sŠ   € ô &×.Ñ.×2Ñ2°4Ó8ˆŒØ�>‰>Ñ%Ø—~‘~×8Ñ8Ó:ˆHØÑ#Ø—‘×#Ñ# H°EÀtÐ#ÑLÜ!%¤b§j¡j°#Ó!6��v‘Ø×Ò˜H¨EÐN°DÒN¸tÐNÀvÓNrD   c                óŽ   • U R                   b)  U R                   R                  5       nUb  U R                   $ U R                  5       $ r§   )r�  r_  Ú__iter__orig__©r�   rc  s     rB   Ú	iter_tqdmÚpatch_tqdm.<locals>.iter_tqdmr  s=   € Ø�>‰>Ñ%Ø—~‘~×8Ñ8Ó:ˆHØÑ#Ø—~‘~Ð%Ø×"Ñ"Ó$Ð$rD   c                ó®   • U R                   b8  U R                   R                  5       nUb  U R                   R                  U5        U R                  U5      $ r§   )r�  r_  rÀ   Ú__update__orig__)r�   rn  rc  s      rB   Úupdate_tqdmÚpatch_tqdm.<locals>.update_tqdmy  sG   € Ø�>‰>Ñ%Ø—~‘~×8Ñ8Ó:ˆHØÑ#Ø—‘×%Ñ% aÔ(Ø×$Ñ$ QÓ'Ð'rD   c                ó¬   • U R                   b8  U R                   R                  5       nUb  U R                   R                  U 5        U R                  5       $ r§   )r�  r_  rr  Ú__close__orig__rŠ  s     rB   Ú
close_tqdmÚpatch_tqdm.<locals>.close_tqdm€  sE   € Ø�>‰>Ñ%Ø—~‘~×8Ñ8Ó:ˆHØÑ#Ø—‘×$Ñ$ TÔ*Ø×#Ñ#Ó%Ð%rD   c                ó°   • U R                   b8  U R                   R                  5       nUb  U R                   R                  U 5        U R                  XU5      $ r§   )r�  r_  rr  Ú__exit__orig__)r�   Úexc_typeÚ	exc_valueÚ	tracebackrc  s        rB   Ú	exit_tqdmÚpatch_tqdm.<locals>.exit_tqdm‡  sI   € Ø�>‰>Ñ%Ø—~‘~×8Ñ8Ó:ˆHØÑ#Ø—‘×$Ñ$ TÔ*Ø×"Ñ" 8¸	ÓBÐBrD   rƒ  rŽ  r’  r–  r‰  Úauto)NNNrz  r{  )Ú
__import__ÚModuleNotFoundErrorr`  rL  rš   rƒ  rÀ   rŽ  rr  r’  Ú__exit__r–  rZ  r‰  rœ  )rE  r†  r‹  r�  r“  rš  s         rB   rP  rP  a  sy  € ðÜ˜6Ó"ˆð
 :Aô	Oò%ô(ò&òCô �5—:‘:Ð/×0Ñ0Ø$)§J¡J×$7Ñ$7ˆ�
‰
Ô!Ü�5—:‘:Ð1×2Ñ2Ø&+§j¡j×&7Ñ&7ˆ�
‰
Ô#Ü�5—:‘:Ð0×1Ñ1Ø%*§Z¡Z×%5Ñ%5ˆ�
‰
Ô"Ü�5—:‘:Ð/×0Ñ0Ø$)§J¡J×$7Ñ$7ˆ�
‰
Ô!Ü�5—:‘:Ð/×0Ñ0Ø$)§J¡J×$7Ñ$7ˆ�
‰
Ô!ð $‡J�JÔØ#‡J�JÔØ!‡J�JÔØ#‡J�JÔØ#‡J�JÔäˆu�f×Ñ¤'¨%¯*©*°f×"=Ñ"=ØŸ*™*ˆ�
‰
�ð #>Ðøô{ ó Ùðús   ‚G; Ç;
HÈHc           	     ó¾   • [        US9nU(       d  X 4$ U[        R                  " U [        R                  R
                  U4[        R                  R
                  SS94$ )N)rQ  r§   )rß   Ú	before_fnÚbefore_argsÚafter_fnÚ
after_args)rN  r   Úfunction_wrapperr   rF  Úset)r/   rQ  rF  s      rB   Úcreate_trackerr§  ¥  sZ   € Ü :Ñ.€HÞØˆ|ÐØ”U×+Ò+Ø
Ü×'Ñ'×+Ñ+Ø�KÜ×&Ñ&×*Ñ*Øñð ð rD   c                óÌ   • U c  0 $ [        U SS5      =(       d    U n[        USS5      n[        U[        5      (       a  UR                  S0 5      $ [        USS5      =(       d    0 $ )a-  Return the request's session, or an empty mapping if there is no session
to read (the normal case for apps without OAuth / SessionMiddleware).

For a real Starlette/fastapi request the session lives in `scope["session"]`;
touching `.session` directly would raise Starlette's "SessionMiddleware must
be installed" assertion when it's absent, so we gate on `scope` membership
instead. A `gr.Request` exposes the fastapi request as `.request`; objects
without a Starlette `scope` (a queued `gr.Request` rebuilt from kwargs) may
still carry a plain `.session`.
Nr°   ÚscopeÚsession)Úgetattrrc   Údictr‚   )r°   Ú
underlyingr©  s      rB   Ú_session_from_requestr®  ²  sa   € ð �Øˆ	Ü˜ )¨TÓ2×=°g€JÜ�J ¨Ó.€EÜ�%œ×ÑØ�y‰y˜ BÓ'Ð'Ü�:˜y¨$Ó/×5°2Ð5rD   c                ó"  •  [         R                  " U 5      nSSKJn  [
        R                  " U 5      n/ n	UR                  R                  5        H<  n
U
R                  U
R                  U
R                  4;  a    OU	R                  U
5        M>     SnSn/ n[        U	5       GH�  u  pêUR                  U
R                  5      n[!        U
R"                  [$        5      (       a$  UnUb  UR'                  XêR"                  5        Mb  Md  [!        U
R"                  [(        5      (       a"  Ub  UR'                  XêR"                  5        M£  M¥  U[*        R,                  [.        [*        R,                     4;   a  Ub  UR'                  Xâ5        Mæ  Mè  U[0        R2                  S-  [0        R4                  S-  [0        R2                  [0        R4                  4;   Ga<  UGb5  [7        U5      n[0        R8                  " U5      nU[.        [0        R2                     [0        R2                  4;   aX  Ub  US   OSnUb  [0        R2                  " U5      nOU[0        R2                  :X  a  [;        S5      eUR'                  UU5        GMÙ  U[.        [0        R4                     [0        R4                  4;   ac  Ub  [0        R4                  " US   US   US   S	9OSnUc  Ub  UnUc  U[0        R4                  :X  a  [;        S5      eUR'                  UU5        GMg  GMj  GMm  U[<        [.        [<           4;   a¹  Ub³  Ub­  U
R                  R?                  S
S5      RA                  5       nSn[C        US5      (       aE  [E        URF                  5      RI                  5        H  u  nnURA                  5       U:X  d  M  Un  O   [K        U5      U:”  a  UX'   GM"  UR'                  UU5        GM7  GM:  GM=  U(       a�  [         RL                  " U5      (       ar  [O        U[P        5      (       a]  UnUbU  UbO  [R        RT                  " URV                  5        UR'                  Xï" URX                  URV                  5      5        GMË  GMÎ  GMÑ  U(       av  [[        U5      cj  [         RL                  " U5      (       aO  [O        X÷5      (       a?  UR                  U5        Ub(  U(       a  Xä;   a  []        S0 XN   DSS0D6X'   GME  GMH  GMK  GMN  U
R"                  U
R^                  Ld  GMj  Uc  GMp  [K        U5      U::  d  GM‚  UR'                  XêR"                  5        GM      Ubž  [K        U5      [K        U	5      :  a†  [K        U5      nXž   n
U
R"                  U
R^                  :X  a(  [`        Rb                  " S5        UR                  S5        OUR                  U
R"                  5        [K        U5      [K        U	5      :  a  M†  U=(       d    / X¼U4$ ! [         a    U=(       d    / SS/ 4s $ f = f)a•  
Checks if function has special arguments Request or EventData (via annotation) or Progress (via default value).
Also checks if any parameters are type-hinted with gr.Component types, in which case all component props should be passed.
If inputs is provided, these values will be loaded into the inputs array.
Parameters:
    fn: function to check.
    inputs: array to load special arguments into.
    request: request to load into inputs.
    event_data: event-related data to load into inputs.
    component_props: dictionary mapping input indices to their full component props.
    token: an OAuthToken to inject into OAuthToken-annotated params when one cannot
        be derived from the request session (e.g. server-side workflow calls that
        resolve the token outside of a browser session).
Returns:
    updated inputs, progress index, event data index, list of input indices that need component props.
Nr   r%   Úuserinfoz@This action requires a logged in user. Please sign in and retry.Úaccess_tokenr©  Ú
expires_at)Útokenr©  r²  r˜   Ú-ÚheadersÚ_is_component_updateTz'Unexpected argument. Filling with None.r>   )2ÚinspectÚ	signaturerb   r,  r&   r   Úget_type_hintsÚ
parametersÚvaluesÚkindÚPOSITIONAL_ONLYÚPOSITIONAL_OR_KEYWORDrŸ   rp   r‚   Únamerc   ÚdefaultrN  ró   r   r   ÚRequestr   r   ÚOAuthProfileÚ
OAuthTokenr®  Ú"_get_valid_oauth_info_from_sessionr    r#   Úreplacera   r`  r¬  rµ  Úitemsrf   ÚisclassÚ
issubclassr   r   Úcheck_all_files_in_cacheÚ_dataÚtargetr   r   Úemptyr]   r^   )r/   r-   r°   Ú
event_datarÁ   r³  r¸  r&   Ú
type_hintsÚpositional_argsÚparamÚprogress_indexÚevent_data_indexÚcomponent_prop_indicesr‘   Ú	type_hintrª  Ú
oauth_infoÚoauth_profileÚoauth_tokenÚheader_nameÚheader_valueÚkÚvs                           rB   Úspecial_argsrÜ  Æ  s4  € ð0,Ü×%Ò% bÓ)ˆ	õ 1ä×%Ò% bÓ)€JØ€OØ×%Ñ%×,Ñ,Ö.ˆØ�:‰:˜e×3Ñ3°U×5PÑ5PÐQÓQÙØ×Ñ˜uÖ%ñ /ð €NØÐØÐÜ˜o×.‰ˆØ—N‘N 5§:¡:Ó.ˆ	Ü�e—m‘m¤X×.Ñ.ØˆNØÑ!Ø—‘˜a§¡Ö/ñ "ä˜Ÿ™¤u×-Ñ-ØÑ!Ø—‘˜a§¡Ö/ñ "àœ6Ÿ>™>¬8´F·N±NÑ+CÐDÓDØÑ!Ø—‘˜aÖ)ñ "àÜ×Ñ Ñ%Ü×Ñ˜tÑ#Ü×ÑÜ×Ñð	
ô 
ð Ò!ô 0°Ó8�ô
 #×EÒEÀgÓN�
ð ¤¬%×*<Ñ*<Ñ!=¼u×?QÑ?QÐ RÓRà2<Ñ2H˜
 :Ò.Èdð "ð %Ñ0Ü(-×(:Ò(:¸=Ó(I™Ø"¤e×&8Ñ&8Ó8Ü#Ø^óð ð —M‘M ! ]×3ð ¤8¬E×,<Ñ,<Ñ#=¼u×?OÑ?OÐ"PÓPð &Ñ1ô ×(Ò(Ø",¨^Ñ"<Ø",¨WÑ"5Ø'1°,Ñ'?òð "ð  ð #Ñ*¨uÑ/@Ø&+˜Ø"Ñ*¨y¼E×<LÑ<LÓ/LÜ#Ø^óð ð —M‘M ! [×1ò% Qò3 "ðX œ6¤8¬FÑ#3Ð4Ó4ØÑ! gÑ&9Ø#Ÿj™j×0Ñ0°°cÓ:×@Ñ@ÓB�Ø#�Ü˜7 I×.Ñ.Ü $ W§_¡_Ó 5× ;Ñ ;Ö =™˜˜1ØŸ7™7›9¨Õ3Ø+,˜LÙ!ñ !>ô �v“; “?Ø ,�F”Ià—M‘M ! \×2ò ':Ò!ö Ü—’ 	×*Ñ*Ü˜9¤i×0Ñ0à ÐØÑ! jÑ&<Ü ×9Ò9¸*×:JÑ:JÔKØ—‘˜a ¨:×+<Ñ+<¸j×>NÑ>NÓ!O×Pò '=Ò!ö Ü˜9Ó%Ñ-Ü—’ 	×*Ñ*Ü˜9×0Ñ0à"×)Ñ)¨!Ô,ØÑ!¦o¸!Ó:NÜ+ñ Ø%Ñ(ñØ?Cò�”	ò ;O¢oÒ!ð
 �M‰M §¡Õ,°Ô1CÌÈFËÐWXÖHXà�M‰M˜!Ÿ]™]×+ñE /ðF ÑÜ�&‹kœC Ó0Ó0Ü�F“ˆAØ#Ñ&ˆEØ�}‰} §¡Ó+Ü—’ÐGÔHØ—‘˜dÕ#à—‘˜eŸm™mÔ,ô �&‹kœC Ó0Õ0ð �<�R˜Ð;QÐQÐQøôs ó ,Ø�|˜˜T 4¨Ð+Ò+ð,ús   ‚W2 ×2XØXc                ó:   • SUS'   U b  XS'   Ub  XS'   Ub  X#S'   U$ )a  
Updates a component's properties. When a function passed into a Gradio Interface or a Blocks
events returns a value, it typically updates the value of the output component. But it is also possible
to update the *properties* of an output component (such as the number of lines of a `Textbox` or
the visibility of an `Row`) by returning a component and passing in the parameters to update in
the constructor of the component. Alternatively, you can return `gr.update(...)` with any arbitrary
parameters to update. (This is useful as a shorthand or if the same function can be called with different
components to update.) For `gr.State` components, only the `value` parameter is supported.

Parameters:
    elem_id: Use this to update the id of the component in the HTML DOM
    elem_classes: Use this to update the classes of the component in the HTML DOM
    visible: Use this to update the visibility of the component
    kwargs: Any other keyword arguments to update the component's properties.
Example:
    import gradio as gr
    with gr.Blocks() as demo:
        radio = gr.Radio([1, 2, 4], label="Set the value of the number")
        number = gr.Number(value=2, interactive=True)
        radio.change(fn=lambda value: gr.update(value=value), inputs=radio, outputs=number)
    demo.launch()
rÀ   Ú__type__r5   Úelem_classesr)   r>   )r5   rß  r)   r…  s       rB   rÀ   rÀ   \  s=   € ð8 "€Fˆ:ÑØÑØ#ˆyÑØÑØ!-ˆ~ÑØÑØ#ˆyÑØ€MrD   c                ó   • SXS.$ )zt
A special function that can be returned from a Gradio function to set the validation error of an output component.
Úvalidate)rÞ  Úis_validÚmessager>   )râ  rã  s     rB   rá  rá  ‚  s   € ð
 #°ÑMÐMrD   c                 ó
   • SS0$ )aÌ  
A special function that can be returned from a Gradio function to skip updating the output component. This may be useful when
you want to update the output component conditionally, and in some cases, you want to skip updating the output component.
If you have multiple output components, you can return `gr.skip()` as part of a tuple to skip updating a specific output component,
or you can return a single `gr.skip()` to skip updating all output components.
rÞ  rÀ   r>   r>   rD   rB   Úskiprå  Š  s   € ð ˜Ð!Ð!rD   c           	     ó"  • SSK Jn  UR                  R                  S 5      nUR                  R                  S 5      nUb  Uc/  US;   a  [        U 5        g US:X  a  [        R                  " U 5        g UR                  R                  UU UUUUS9  g )Nr   )r   )ÚinfoÚsuccessÚwarning)rv  ÚlogÚtitleÚlevelÚdurationr)   )
Úgradio.contextr   ru  r‚   rv  r‹   r]   r^   rw  Úlog_message)rã  rë  rì  rí  r)   r   ru  rv  s           rB   rï  rï  •  s–   € õ ,à× Ñ ×$Ñ$ TÓ*€FØ×$Ñ$×(Ñ(¨Ó.€HØ�~˜Ñ)ð Ð'Ó'Ü�'ŒNð 	ð �iÓÜ�MŠM˜'Ô"ØØ
‡M�M×ÑØØØØØØð ò rD   Úmodals)Údocumentation_groupc                ó   • [        XSXS9  g)a‡  
This function allows you to pass custom warning messages to the user. You can do so simply by writing `gr.Warning('message here')` in your function, and when that line is executed the custom message will appear in a modal on the demo. The modal is yellow by default and has the heading: "Warning." Queue must be enabled for this behavior; otherwise, the warning will be printed to the console using the `warnings` library.
Demos: blocks_chained_events
Parameters:
    message: The warning message to be displayed to the user. Can be HTML, which will be rendered in the modal.
    duration: The duration in seconds that the warning message should be displayed for. If None or 0, the message will be displayed indefinitely until the user closes it.
    visible: Whether the error message should be displayed in the UI.
    title: The title to be displayed to the user at the top of the modal.
Example:
    import gradio as gr
    def hello_world():
        gr.Warning('This is a warning message.')
        return "hello world"
    with gr.Blocks() as demo:
        md = gr.Markdown()
        demo.load(hello_world, inputs=None, outputs=[md])
    demo.launch()
ré  ©rë  rì  rí  r)   N©rï  ©rã  rí  r)   rë  s       rB   ÚWarningrö  ²  s   € ô2 Ø I¸órD   c                ó   • [        XSXS9  g)aN  
This function allows you to pass custom info messages to the user. You can do so simply by writing `gr.Info('message here')` in your function, and when that line is executed the custom message will appear in a modal on the demo. The modal is gray by default and has the heading: "Info." Queue must be enabled for this behavior; otherwise, the message will be printed to the console.
Demos: blocks_chained_events
Parameters:
    message: The info message to be displayed to the user. Can be HTML, which will be rendered in the modal.
    duration: The duration in seconds that the info message should be displayed for. If None or 0, the message will be displayed indefinitely until the user closes it.
    visible: Whether the error message should be displayed in the UI.
    title: The title to be displayed to the user at the top of the modal.
Example:
    import gradio as gr
    def hello_world():
        gr.Info('This is some info.')
        return "hello world"
    with gr.Blocks() as demo:
        md = gr.Markdown()
        demo.load(hello_world, inputs=None, outputs=[md])
    demo.launch()
rç  ró  Nrô  rõ  s       rB   ÚInforø  Ð  s   € ô2 �¨F¸XÓWrD   c                ó   • [        XSXS9  g)a;  
This function allows you to pass custom success messages to the user. You can do so simply by writing `gr.Success('message here')` in your function, and when that line is executed the custom message will appear in a modal on the demo. The modal is green by default and has the heading: "Success." Queue must be enabled for this behavior; otherwise, the message will be printed to the console.
Parameters:
    message: The success message to be displayed to the user. Can be HTML, which will be rendered in the modal.
    duration: The duration in seconds that the success message should be displayed for. If None or 0, the message will be displayed indefinitely until the user closes it.
    visible: Whether the error message should be displayed in the UI.
    title: The title to be displayed to the user at the top of the modal.
Example:
    def hello_world():
        gr.Success('Operation completed successfully!')
        return "hello world"
    with gr.Blocks() as demo:
        md = gr.Markdown()
        demo.load(hello_world, inputs=None, outputs=[md])
    demo.launch()
rè  ró  Nrô  rõ  s       rB   ÚSuccessrú  ì  s   € ô. Ø I¸órD   )NNNNr  FNNFTTr¶   rÂ   NF)(r,   r  r-   r  r.   r  r/   r  r0   r  r1   r  r2   rÜ   r3   r  r4   r  r5   r  r6   r  r7   r  r8   r  r9   r  r:   r  r;   r  r<   r  r(   r  r)   r  r*   r  )r   zSequence[Component]rú   re   rÖ   re   r  )r°   r   r  zMutableMapping[str, Any])NNNNN)r/   r   r-   zlist[Any] | Noner°   r!  rÍ  zEventData | NonerÁ   z dict[int, dict[str, Any]] | Noner³  zoauth.OAuthToken | Noner  z.tuple[list, int | None, int | None, list[int]])NNN)
r5   r  rß  zlist[str] | str | Noner)   zbool | Literal['hidden'] | Noner…  r   r  zdict[str, Any])râ  r  rã  rg   )r  r¬  )rç  r  T)
rã  rg   rë  rg   rì  z%Literal['info', 'warning', 'success']rí  rJ  r)   r  )zWarning issued.r  Trö  )rã  rg   rí  rJ  r)   r  rë  rg   )zInfo issued.r  Trø  )zSuccess.r  Trú  )Rr&  Ú
__future__r   r  rz   rm   r·  r_   rƒ   r.  r]   Úcollections.abcr   r   r   r   Ú	functoolsr   Úpathlibr	   Ú	threadingr
   Útypesr   Útypingr   r   r   r   r   Úgradio_clientr   r  Úgradio_client.documentationr   rw   r   r   r   r   Úgradio.cachingr   r   rî  r   r   r   Úgradio.data_classesr   r   rñ   r   r   Úgradio.exceptionsr    Úgradio.flaggingr!   Úgradio.i18nr"   Úgradio.route_utilsr#   Úgradio.utilsr$   Úgradio.componentsr&   rj   rC   r?   rö   r?  rN  rP  r§  r®  rÜ  rÀ   rá  rå  rï  rö  rø  rú  r>   rD   rB   Ú<module>r     sñ  ðñõ #ã 
Û Û 
Û Û 	Û Û Û ß HÓ HÝ Ý Ý Ý !ß DÕ Då /Ý 0ç EÕ Eß 3ß DÑ Dß <ß /Ý #Ý %Ý  Ý %Ý *æÝ+à€ð 7;ØØ"&Ø26ØØØ#'ØØØØØCQØ)Ø37Øð#0ð& (,Ø(,Ø$%ñ+0Ø/ð0à+ð0ð 4ð0ð 	ð	0ð
  ð0ð 0ð0ð ð0ð ð0ð !ð0ð ð0ð ð0ð ð0ð ð0ð Að0ð ð0ð  1ð!0ð" ð#0ð& %ð'0ð( &ð)0ð* "ö+0ñf 
ƒ÷að aó ðaðH#Ø#ð#Ø7;ð#ØEIô#÷L!ñ !ñ( 
ˆ*�fÓôa=ˆxó a=ó ða=ôHA%òH
ô6ð,  $Ø%)Ø#'Ø8<Ø%)ðSRØðSRàðSRð #ðSRð !ð	SRð
 6ðSRð #ðSRð 4õSRðn Ø+/Ø/3ð#Øð#à(ð#ð -ð#ð ð	#ð
 õ#ñL 
ƒóNó ðNñ 
ƒó"ó ð"ð 4:ØØðØðàðð 1ðð ð	ð
 õñ: 
˜hÑ'à$ØØØð	Øðàðð ðð ô	ó (ðñ: 
˜hÑ'à!ØØØð	XØðXàðXð ðXð ô	Xó (ðXñ6 
˜hÑ'àØØØð	Øðàðð ðð ô	ó (ñrD   