
    +jʭ                      U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlZddlZddlZddlmZmZmZ ddlmZ ddlmZmZmZmZmZ ddlZddlZddlZddl Z ddlm!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z' ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. dd	l/m0Z0 dd
l1m2Z2 ddl3m4Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZD ddlEmFZG ddlHmIZI ddlJmKZK ddlLZLddlLmMZMmNZNmOZOm4Z4 ddlPmQZQ ddlRmSZS ddlTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZa ddlbmcZcmdZd ddlemfZf ddlgmhZh ddlimjZj ddlkmlZl ddlmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZmZmZmZmZ dd lmZ dd!lmZmZmZmZmZmZmZ dd"lmZ dd#lmZ dd$lmZmZmZmZ erdd%lmZ ddlZddlZddlZddlZ e
j                     d&  eOj                     eOj                     eOj                     eOj                     eOj                     eOj                     eOj                     eOj                     eOj                    f	D             Zd'ed(<    G d) d*e+          Zd+ Z e2er,          Zeej        j        d-<    ej         ej        d.d/0          1          Z ev            Z G d2 d3e%          Zdpdqd7Zdrd:Z e7            	 	 	 	 dsdddddddd=ddddddddddddddd>dtdn            Zg doZdS )uzImplements a FastAPI server to run the gradio interface. Note that some types in this
module use the Optional/Union notation so that they work correctly with pydantic.    )annotationsN)AsyncIteratorCallableSequence)Path)TYPE_CHECKINGAnyLiteralUnioncast)	APIRouterBackgroundTasksBodyDependsFastAPIHTTPExceptionstatus)FileResponseHTMLResponseJSONResponsePlainTextResponseResponseStreamingResponse)OAuth2PasswordRequestForm)Jinja2Templates)utils)document)generate_code_snippets)ServerMessage)_condense_infogenerate_cli_snippet)TemplateNotFound)parse_options_header)BackgroundTask)
UploadFile)MultiPartException)RedirectResponse)cachingroute_utilsthemesr   )BrotliMiddleware)Context)
CancelBodyComponentServerBlobBodyComponentServerJSONBodyDataWithFilesDeveloperPathJsonDataPredictBodyPredictBodyInternal	ResetBodySimplePredictBodyUserProvidedPathVibeCodeBodyVibeEditBody)ErrorInvalidPathError)special_args)I18n)start_node_server)attach_oauth)
API_PREFIXBUILD_PATH_LIBDEFAULT_TEMP_DIRSTATIC_PATH_LIBSTATIC_TEMPLATE_LIBVERSIONXSS_SAFE_MIMETYPESCustomCORSMiddlewareFileUploadProgress FileUploadProgressNotQueuedError!FileUploadProgressNotTrackedErrorGradioMultiPartParserGradioUploadFileRequestcompare_passwords_securelycreate_lifespan_handlerfavicon
file_fetchfile_responsemove_uploaded_files_to_cacheroutes_safe_join	upload_fn)process_video_with_ffmpeg)CloseStreamMessageEstimationMessageEventMessageHeartbeatMessageProcessCompletedMessageProcessGeneratingMessageUnexpectedErrorMessage)StateHolder)
ThemeClass)cancel_tasksget_node_pathget_upload_foldersafe_aclose_iterator)Blockc                ,    i | ]}|j         	|j         |S N)name.0ts     Q/home/wildlama/visual-decline/.venv/lib/python3.11/site-packages/gradio/routes.py
<dictcomp>rl      s2     % % %	 	v FA     zdict[str, Theme]BUILT_IN_THEMESc                  b    e Zd ZdZedd            Zedd            Zdd	Zedd
            ZdS )ORJSONResponseapplication/jsoncontentr	   returnstrc                r    t          | t                    r|                                 S t          |           S rf   )
isinstancer2   
model_dumprt   rr   s    rk   defaultzORJSONResponse.default   s2    gx(( 	(%%'''7||rm   bytesc                r    t          j        | t           j        t           j        z  t          j                  S )Noptionry   )orjsondumpsOPT_SERIALIZE_NUMPYOPT_PASSTHROUGH_DATETIMErp   ry   rx   s    rk   _renderzORJSONResponse._render   s2    |-0OO"*
 
 
 	
rm   c                6    t                               |          S rf   )rp   r   )selfrr   s     rk   renderzORJSONResponse.render   s    %%g...rm   c                \    t                               |                               d          S )Nutf-8)rp   r   decoderx   s    rk   _render_strzORJSONResponse._render_str   s$    %%g..55g>>>rm   N)rr   r	   rs   rt   )rr   r	   rs   rz   )	__name__
__module____qualname__
media_typestaticmethodry   r   r   r    rm   rk   rp   rp      s        #J   \
 
 
 
 \
/ / / / ? ? ? \? ? ?rm   rp   c                    t          j        t                              |                               dd                              dd                              dd                              dd                    S )	N<z\u003c>z\u003e&z\u0026'z\u0027)
markupsafeMarkuprp   r   replace)values    rk   toorjsonr      sd    ""5))	i	 	 	i	 	 	i	 	 	i	 	   rm   )	directoryr   d      )max_connectionsmax_keepalive_connections)limitsc                       e Zd ZdZdZ	 dd fdZdd
ZddZd Zd Z	e
	 dd d            Ze
	 	 	 	 	 	 d!d"d            Z xZS )#Appz
    FastAPI App Wrapper
    Nauth_dependency.Callable[[fastapi.Request], str | None] | Nonec                   i | _         d | _        t          j        d          | _        d| _        d | _        t                      | _        i | _	        t                      | _        t          j                    | _        t          j                    | _        t          j        d          | _        t          j        d          | _        d| _        t)                      | _        d| _        d | _        d | _        g | _        || _        d | _        d | _        d | _        d| _        |                    dd            |                    dd            i | _          tC                      j"        di | d S )N   F    r   r   docs_url	redoc_url)#tokensauthsecretstoken_urlsafeanalytics_keymonitoring_enabledblocksr^   state_holder	iteratorssetiterators_to_resetr   safe_get_locklocksafe_get_stop_event
stop_event	cookie_idqueue_tokenstartup_events_triggeredrb   uploaded_file_dirchange_countchange_typereload_error_message_asyncio_tasksr   api_infostatic_worker_poolall_app_info_static_prefixes
setdefaultcustom_component_hashessuper__init__)r   r   kwargs	__class__s      rk   r   zApp.__init__   sT   
 	$2266"',0'MM35,/EE'))	355 .r22"044(-%!2!4!4!">B04!24."&   	 	*d++++t,,,79$""6"""""rm   r   gradio.Blocksrs   Nonec                ,   |j         }|)t          |          sd |D             | _         n|| _         nd | _         || _        t          j                    | _        |j        | _        i | _        |j        pd| _        | j	        
                    |           d S )Nc                ,    i | ]}|d          |d         S )r      r   )ri   accounts     rk   rl   z%App.configure_app.<locals>.<dictcomp>  s"    HHHWQZHHHrm    )r   callabler   osgetcwdcwdfavicon_pathr   	root_pathr   
set_blocks)r   r   r   s      rk   configure_appzApp.configure_app	  s    {D>> !HH4HHH		 		DI9;;"/)/R$$V,,,,,rm   c                <    | j         t          d          | j         S )Nz+No Blocks has been configured for this app.)r   
ValueError)r   s    rk   
get_blockszApp.get_blocks  s!    ;JKKK{rm   c                D   t          j        |          | j        sJ t          fd| j        j        D                       }|st          d          j                            d          st          d          i }t          j	        dt          j	         |d<   |fS )Nc              3  \   K   | ]&}j         t          j        |          j         k    V  'd S rf   )hosthttpxURL)ri   rooturls     rk   	<genexpr>z*App.build_proxy_request.<locals>.<genexpr>#  sF       
 
15CH	$,,
 
 
 
 
 
rm   zThis URL cannot be proxied.z	.hf.spacezBearer Authorization)
r   r   r   any
proxy_urlsPermissionErrorr   endswithr,   token)r   url_pathis_safe_urlheadersr   s       @rk   build_proxy_requestzApp.build_proxy_request  s    i!!{{  
 
 
 
9=9O
 
 
 
 
  	A!"?@@@ x  -- 	A!"?@@@=$'@'@'@GO$ G|rm   c                P    | j         D ]}|                                 g | _         d S rf   )r   cancel)r   tasks     rk   _cancel_asyncio_taskszApp._cancel_asyncio_tasks4  s1    ' 	 	DKKMMMM rm   
app_kwargsdict[str, Any]
mcp_serverbool | Nonec                    t           dz   }|6t          j                            dd                                          dk    }|r	 dd l}n"# t          $ r}t          d          |d }~ww xY w	 |j                                        _	        d _
        d d|v r|d         t          j        d fd            }||d<   n(# t          $ r}d _
        d|  _        Y d }~nd }~ww xY w                                  _        |S )Nz/mcpGRADIO_MCP_SERVERFalsetruer   zIn order to use `mcp_server=True`, you must install gradio with the `mcp` extra. Please install it with `pip install "gradio[mcp]"`Tlifespanappr   c               R  K   t          j                    4 d {V }j        r3|                    j                            |                      d {V  $|                     |                      d {V  d W V  d d d           d {V  d S # 1 d {V swxY w Y   d S rf   )
contextlibAsyncExitStackmcp_server_objenter_async_contextr   )r   stackr   user_lifespans     rk   	_lifespanz'App.setup_mcp_server.<locals>._lifespanP  si     )8::       e!0 "'";"; & 5 > >s C C# #        )4"'";";MM#<N<N"O"OOOOOOOO                             s   A&B
B #B FzError launching MCP server: )r   r   )r@   r   environgetlower
gradio.mcpImportErrormcpGradioMCPServerr   r   r   asynccontextmanager	Exception	mcp_errorget_config_fileconfig)r   r   r   mcp_subpathgradioer  r  s   `      @rk   setup_mcp_serverzApp.setup_mcp_server9  s    !6)(;WEEKKMMQWWJ 	F!!!!!   ! Z F(.
(B(B6(J(J%$(! $++$.z$:M/      0/ *3
:&& F F F$)!#E!#E#E      F
 ""$$ 	 s1   A 
A,A''A,0AC 
C(C##C(TFr   
App | Nonedict[str, Any] | Nonestrict_corsbooldebugc                   9:;<=>?@ABCDEFGHIJKLMNOPQR |pi }|                     dt                     t                               ||          } j        pd}7t          |                    dd           g|R  |d<   t          dd|i|d|in+t          |                    dd           g|R  j        _         j	        r! j	        
                    | j                   t          t                    }	                                                    t           |                               t"          d|g	           |	                    d
          |	                    d          dfd                        C|	                    d          |	                    d          t%          C          fd fd                        }
|	                    d          |	                    d          dfd                        }|	                    d          |	                    d          dfd                        }|	                    dt%          |
          g          dfd            }                    d                               d!          t%                      fdfd$                        }j        j        j        rt-                     n1                    d%          t%          C          d&fdfd)            }                    d*          dd,            }CIfd-} j        D ]}|d.         }|d/k    r ||           	 ddfd4H                    d5t2          6                              d5t2          6          t%          C          d/d/fd:Hfd7                        I                    d8          dfd:            }|	                    d;t%          |
          g          |	                    d<t%          |
          g          dfd=                        :|	                    d>t%          |
          g          d:fd?            }                    d@t%          |
          g                              dAt%          |
          g          dd CHfdB                        }                    dC          ddD            }|	                    dE          dfdL            }                    dM          ddN            }                    dO          fdP            }|	                    dQt%          |
          g          |	                    dQt%          |
          g          dfdS                        }|	                    dTt%          |
          g          |	                    dTt%          |
          g          dfdV                        A|	                    dW          dfd[            }|	                    d\          dfd]            }|	                    d^          dfdb            }|	                    dc          dfdf            }|	                    dg          dfdh            }|	                    dit%          |
          g          dAfdj            }|	                    dk          |	                    dl          ddn                        }|	                    do          t%          C          fdfds            }|	                    dtt%          |
          g          |	                    dut%          |
          g          |	                    dvt%          |
          g          |	                    dwt%          |
          g          t%          C          fd fdy                                                }dd}J|	                    d~t%          |
          g          |	                    dt%          |
          g          t%          C          fdJLfd                        }|	                    dt%          |
          g          |	                    dt%          |
          g          t%          C          fdJLfd                        }|	                    dt%          |
          g          t%          C          fdLfd            } dfdL|	                    d          dfd            }!|	                    dt%          |
          g          |	                    dt%          |
          g          dKfd                        }"|	                    dt%          |
          g          dKfd            }#dfdKd	dD|	                    dt%          |
          g          |	                    dt%          |
          g          dDfd                        }$|	                    dt%          |
          gt4                    fd            }%|	                    d          d
d            }&ddN|	                    dt%          |
          g          	 dd9 Nfd            }'|	                    d          fd            }(|	                    dt6          6                              dt6          6          fd                        })                    dt6          6          fd            }*                    d                              d          ddfd                        }+                    d           fd            },                    dt%          |
          g          d fd            }-                    d          fd            }                    d          d fd            }.|	                    dt%          |
          g          d=fd            }/t9          t:                    dz  RR                    d&d&           dd/i;i EdddGt?          j         d          ?t?          j         dt>          j!                  Bt?          j         dt>          j!                  @t?          j         dt>          j!        t>          j"        z            Mt?          j         dt>          j!        t>          j"        z            Qd?@BfdƄ<dQfdȄPdMfdʄO j#        rd.dl$m%}0  |0            F|	                    d̦          |	                    dͦ          d ;<EFGOPRf	dτ                        }1|	                    dЦ          |	                    dѦ          tM          dd&Ӧ          fd ;ERfdՄ                        }2|	                    d֦          |	                    dצ           fd؄                        }3|	                    d֦          |	                    dצ          d fdڄ                        }4|	                    dۦ          |	                    dܦ           <FPfd݄                        }5dބ =d.dl'm(9 9rjd.dl'm)> |	                    d          	 dd>fd            }6|	                    d          >fd            }7|	                    d          >fd            }8*                    |	           S (  Ndefault_response_class)NNr   r   r  )prefix)r     )qualityexcluded_handlersz/userz/user/requestfastapi.Requestrs   
str | Nonec                    j                              |           S | j                            dj                   p!| j                            dj                   }j                            |          S )Naccess-token-access-token-unsecure-)r   cookiesr  r   r   r  r   r   s     rk   get_current_userz(App.create_app.<locals>.get_current_user  s     ".**7333O''///  O$$%Mcm%M%MNN  :>>%(((rm   z/login_checkz/login_check/userrt   c                n    j         j        | d S t          t          j        dj        d          )NNot authenticatederrorauth_messagestatus_codedetail)r   r   r   r   HTTP_401_UNAUTHORIZEDr-  )r(  r   r   s    rk   login_checkz#App.create_app.<locals>.login_check  sO      S%8%@TEU"80$*$7    rm   z/tokenz/token/dictc                    | j                             dj                   }|j                            |          dS )Nr#  )r   r(  )r%  r  r   r   r&  s     rk   	get_tokenz!App.create_app.<locals>.get_token  sA     O''(G(G(GHHE"CJNN5,A,ABBBrm   z/app_idz/app_id/c                :    d                                 j        iS )Napp_id)r   r7  )r  r   s    rk   r7  zApp.create_app.<locals>.app_id  s     cnn..566rm   z/dev/reload)dependenciesc                H   K   dfd}t           ||           d          S )Nr  r   c                 K   d}d}t          j                    }j        }	 |                                  d {V rd S j        |k    r?j        }j        dk    rt          j        j                   nd}dj         d| dW V  t          j	        |           d {V  t          j                    |z
  |k    rd	W V  t          j                    })
N   皙?Tr,  z{}event: 
data: 

zevent: heartbeat
data: {}

)
timeperf_counterr   is_disconnectedr   jsonr   r   asynciosleep)r  heartbeat_rate
check_ratelast_heartbeatcurrent_countmsgr   s         rk   reload_checkerz>App.create_app.<locals>.notify_changes.<locals>.reload_checker  s      !#!
!%!2!4!4 # 0=$4466666666 '=88(+(8  #'99 !J#*B'DEEE!% 
 O#/NN3NNNNNNN!-
333333333(**^;nLLBBBBB)-):)<)<!=rm   text/event-streamr   r  r   )r   )r  rK  r   s     rk   notify_changesz&App.create_app.<locals>.notify_changes  sN      = = = = = =0 %w''.   rm   /loginz/login/	form_datar   c                  K   |j                                         |j        }}j        7t	          j        | dj                  }t          |t          j	                  S t          j                  s$|j        v rt          |j        |                   s`t          j                  rt          j        j                  r                    ||           d {V rn                    ||          rtt          j        d          }|j        |<   t#          ddi          }|                    dj         |dd	d
           |                    dj         |d           |S t)          dd          )NrP  r  
route_pathr   r   r/  r   successTrx   r#  none)keyr   httponlysamesitesecurer$  )rX  r   rY    zIncorrect credentials.r.  )usernamestrippasswordr   r)   get_root_urlr   r'   r   HTTP_302_FOUNDr   rN   inspectiscoroutinefunctionr   r   r   r   
set_cookier   r   )r  rQ  r]  r_  r   r   responser   s          rk   loginzApp.create_app.<locals>.login  s     
 "+!3!9!9!;!;Y=OhHx"/#'!m  
 (Df>STTTTSX&&V((.x(9KLL ) "" ) 238<< )
 ((8X66666666 )( (H55 )  -b11$,
5!'D0ABBB##777!# $    ##@@@! $   
  #<TUUUUrm   /logoutTall_sessionr  c                   t          j        | dj                  }t          |t          j                  }|                    dj         d           |                    dj         d           |rCt          j	        
                                          D ]}j	        |         |k    rj	        |= nQ| j                            dj                   j	        v r(j	        | j                            dj                   = |S )Nrg  rS  rU  r#  /)rX  pathr$  )r)   r`  r   r'   r   ra  delete_cookier   listr   keysr%  r  )r  r(  rh  r   re  r   r   s         rk   logoutzApp.create_app.<locals>.logout  s3    #/#(!m  
 ,&BWXXX&&+J3=+J+JQT&UUU&&@@@s '     Y!%cjoo&7&7!8!8 2 2:e,44 #
5 12 _(()H)H)HIISZWW
7?#6#67Vs}7V7V#W#WXrm   z/svelte/{path:path}rk  c                   K   t          t          t          t                    dz                      }t	          |t          |                     S )Nsvelte)r1   rt   r   rA   rR   r7   )rk  svelte_paths     rk   _zApp.create_app.<locals>._&  sA      'D,@,@8,K(L(LMMK .>t.D.DEEErm   c                                          d  t                    t                    dfd fd	            }                     d  d           fd
            }d S )Nrj  response_classr   r  r   r(  rt   	deep_linkc                      | ||          S rf   r   )r  r(  rw  mainpages      rk   
page_routez7App.create_app.<locals>.attach_page.<locals>.page_route,  s     tGT4;;;rm   c                 @    t          d  t          j                  S )Nrj  rU  )r'   r   HTTP_301_MOVED_PERMANENTLYrz  s   rk   page_redirectz:App.create_app.<locals>.attach_page.<locals>.page_redirect4  s(    '"D

0Q   rm   )r  r   r(  rt   rw  rt   )r  r   r   )rz  r{  r  r   r'  ry  s   `  rk   attach_pagez#App.create_app.<locals>.attach_page+  s    WWZZZW== $$455!#< < < < < < < >=< WW[[[[!!    "!  rm   r   r   rw  r  r   rz  c           
        d         }	 t          d          | z  dz  }t          t          t          j                  t	          t          |                                        }|                                r)t          j        |	                                          }d}nd}n&# t          t          t          j        f$ r d}g }Y nw xY wrfd|D             }||fS )N
components
deep_links
state.jsonvalidinvalidc                L    g | ] }|d          d                  d         v |!S idrz  r  r   ri   	componentr  rz  s     rk   
<listcomp>z:App.create_app.<locals>.load_deep_link.<locals>.<listcomp>T  @       ! &.*>|*LLL LLLrm   )r   rT   r1   r   r7   rt   existsr~   loads
read_bytesFileNotFoundErrorOSErrorJSONDecodeError)rw  r  rz  r  	user_pathrk  deep_link_stater   s    ``    rk   load_deep_linkz&App.create_app.<locals>.load_deep_link?  s     -J  ..:\I	$%c&;<<(Y88   ;;== 0!'doo.?.?!@!@J&-OO&/O%w0FG      "+


       %/  

 ..s   BB+ + CCrj  ru  c           
        t          j        dd                                           }t          j        | d j        p | j                            d          p|j                  }j	        j
        |t          j        |j                  d}fdd         D             }|r |          \  }}|d	<   |d
<   |d<   fd                    dg           D             d<   d                  d         d<   d<   t          j        |          nEj
        r#t          t           j        d|j        d          d|j        |j        |ddi iidgg g dd		 |j        rdnd} |           }	t*                              | ||	d          }
|
S # t.          $ r,}|j        rt1          d          |t1          d          |d }~ww xY w)Nzapplication/javascriptz.jsrj  r   rS  rW  c                L    g | ] }|d          d                  d         v |!S r  r   r  s     rk   r  z0App.create_app.<locals>.main.<locals>.<listcomp>o  r  rm   r  r]  r  c                L    g | ] }|d          d                  d         v |!S )r  rz  r8  r   )ri   
dependencyr  rz  s     rk   r  z0App.create_app.<locals>.main.<locals>.<listcomp>}  sA     * * *"!$'6&>$+?+OOO OOOrm   r8  rz  layoutcurrent_pager*  r+  r.  Tr   )	auth_requiredr-  space_idr   rz  pagesr  r8  r  zfrontend/share.htmlzfrontend/index.html)r  gradio_api_info)r  rg   contextzqDid you install Gradio from source files? Share mode only works when Gradio is installed through the pip package.znDid you install Gradio from source files? You need to build the frontend by running /scripts/build_frontend.sh)	mimetypesadd_typer   r)   r`  r   scoper  custom_mount_pathr   r   r   safe_deepcopyr  update_root_in_configr   r   r1  r-  r  share	templatesTemplateResponser"   r   )r  r(  rz  rw  r   r   r  r  templater  resperrr  r   r   r  s     `         @rk   ry  zApp.create_app.<locals>.main[  s    7???^^%%F+%t::- ,=$$[11,+  D  S%8%@TEU,V];;"(    %+L%9  

  2@.!3 3/J
 &*z",;()'1|$* * * * *&,jj&D&D* * *~&
 $*&>$#7#Ax )-~& %:64HH$ # & <!4(.(;     &*$*$7 & (B0 T"$$&$&
 
-3\T))?T  #+(7"3"3 11#!"(+:  2   # 
 
 
< 	$R  
 %M  
s   ,7F$ $
G.'GGz/gradio_api/deep_linksession_hashc                   | j         v rd j         |          j        D             }t          j        |t          j        t          j        z  t                    }t          j        |          }t          j
                  dz  |z  }|                    dd           t          |dz  d          5 }|                    |           d d d            n# 1 swxY w Y   |S dS )	Nc                6    g | ]}t          j        |          S r   )r   r  )ri   cs     rk   r  z5App.create_app.<locals>.deep_link.<locals>.<listcomp>  s3        '**  rm   r|   r  T)parentsexist_okr  wbr   )r   r  r~   r   r   r   rt   r)   create_url_safe_hashr   r   mkdiropenwrite)r  r  components_jsonrw  r   fr   s         rk   rw  z!App.create_app.<locals>.deep_link  s,   s///  -l;F  
 #),!58WW# # #
 (<_MM	 !677,FR	t<<<)l2D99 -QGGO,,,- - - - - - - - - - - - - - -  rs   2CCCz/info//infoc                   | j                             dd          }|r;j        s-                                                    d          _        j        S j        s{t          j                                                                                  }t          t          t          t          f         |          }t          j        |          }t          j        | t           dj                  }                                j        }t%          |d                   }|                                D ]-\  }}|                    d|pt          |                    ||<   .t          d	z   }|                    di                                           D ]:\  }	}
t+          |	|
t          |          ||
          |
d<   ||	         |
d         d<   ;|_        j        S )Nall_endpointsFT)r  r  rS  named_endpointsz
{space_id}rj  )r  
api_prefixcode_snippetscli)query_paramsr  r   r   get_api_infor   r   r  r   r3  rt   r	   r)   'update_example_values_to_use_public_urlr`  r@   r   r  r!   itemsr   r   )r  r  r   r   r  cli_snippetskvr  ep_nameep_infor   s              rk   r   z App.create_app.<locals>.api_info  s    $044_eLLM (' Y'*~~'7'7'D'DSW'D'X'XC$''< ( .s~~/?/?/L/L/N/NOOS#X99&NxXX"/#",333!m  
 >>++43H=N4OPP(..00 U UDAq&'iih>S#d))&T&TLOO'#-
(05F(K(K(Q(Q(S(S L L$GW/ED		!)#-0 0 0GO, 7C76KGO,U33'<rm   z/openapi.jsonc                    |           }t          |d          }dt                                          dd          t                                          dd          t          dd	d
dddddddddddgdddddddddddidgdiidd d!ddd"did#iid$d%d&dd"diiid$d'd&dd"diiid$d(d)g igd*iid+i id,}|                    d-i                                           D ]\  }}|                    d.d/          d0k    r!|                    d1                              d1d2          }t          d3 ||                             d4g           D                       }|                    dd          pd5| }|r|d6z  }d
||                    dd          |dd!ddi d7iidd8d9d!ddd:d"diid7iid$id;i}	|	d
         d<         d=         d!         d         d>         }
||                             d4g           D ]}|d?         }|                    d"i           }d@|v r%t          |          }|
                    d@d           d>|v rd"|vrt          |          }d|d"<   |                    d"          dAk    rt          |          }d|d"<   dA|dB<   ||
|<   dC|v rrdD|	d
         d<         d=         d!         vr!dEdFi ii|	d
         d<         d=         d!         dD<   |dC         |	d
         d<         d=         d!         dD         dE         dF         |<   g }t          ||                             dGg                     D ]O\  }}|dHk    rdI| ndJ}|                    d"i           }d}|                    |s| dK| dLdz   ndM|            P|	d
         dxx         dN| dOt          |           dP| z  cc<   |	|dQ         dR| <   dS| dT}dUdV| dW| dXd:dYdd"didZdgd8d[d\dd"diiid$id]i|dQ         |<   |S )^z:Generate an OpenAPI schema from the Gradio app's API info.T)url_onlyz3.0.2titlez
Gradio Appdescriptionr   )r  r  versionz/gradio_api/uploadpostzUpload Fileupload_file_upload_post	upload_idqueryFstringN)typenullablery   z$Optional ID to track upload progress)rg   inrequiredschemar  multipart/form-datar  objectfilesarraybinary)r  formatzOne or more files to upload)r  r  r  )r  
propertiesr  )r  rr   z6List of file paths where the uploaded files were savedrq   r  )r  r  )r  rr   z)Invalid content type or invalid file namez
text/plainz!File exceeds maximum allowed size)200400413r2  )summaryoperationId
parametersrequestBody	responsessecurityschemas)openapiinfopathsr  r  api_visibilitypublicprivaterj  rs  c              3  p   K   | ]1}|                     d i                                d           dk    V  2dS )r  filepathN)r  )ri   ps     rk   r   z9App.create_app.<locals>.openapi_schema.<locals>.<genexpr>D  sW       & & EE&"%%))&11Z?& & & & & &rm   r  z	Endpoint z. File inputs must first be uploaded via POST /gradio_api/upload (multipart/form-data with a "files" field). Use the returned path in the request body as {"path": "<uploaded_path>", "meta": {"_type": "gradio.FileData"}}.)r  r  r  zSuccessful responseevent_id)r  r  r  r  r  r  rr   r  rg   additional_descriptionr  r  example_inputexamplesexample1r   returnsr   output_outputz ()zdesc: z0Output must be fetched from GET /gradio_api/callz!/{event_id}. Returns an array of z# elements of the following format: r  z/gradio_api/call/v2z/gradio_api/callz/{event_id}r  zFetch results for zReturns a stream of server-sent events (SSE). The final event has `event: complete` with `data` containing a JSON array of outputs._getrk  z)The event_id returned by the POST requestzBSSE stream with event: complete containing a JSON array of outputsrL  )r  r  r  r  r  )r    getattrr   rE   r  r  r^  r   r   r3  pop	enumerateappendlen)r  r  info_simpler  endpoint_pathendpoint_infoendpoint_namehas_file_paramsr  	path_itemrequest_propertiesparam
param_name
param_typereturns_infoiretret_nameret_typedescget_pathr   r   s                        rk   openapi_schemaz&App.create_app.<locals>.openapi_schema  s    8G$$D(===K"$S^^%5%5wMM#*3>>+;+;]B#O#O&  )'4+D -8*105084837/& /&
 4Z
!" 
!"+ -1$9(04<07<C@HBJ>6 >6 Da:2 :2	;. :A	3* 3*<&,", ,. 4l(:,48?:@(9K7. 7.=*0&
(" 
(" 4_(4x&(AS6T0&(" (" 4W(4x&(AS6T0&(" ("%* *2 +8)<(=}?! ?!A+CH  )"oWL LF\ 159JB0O0O0U0U0W0W v v,} $$%5x@@IMM - 3 3C 8 8 @ @c J J"% & &(7;;L"MM& & & # #
 "%%mR88W<W<W<W  # ~   ~  ~G#*'4'8'8'K'K'4(, 2$,xr.R.R5"(( ( "/D$6(04<0:VX<N;.3* 3*9&	,"$ $& 	> &/v%6}%Ei%P&&&(&*" )7;;L"MM T TE!&vJ!&62!6!6J/:==%)*%5%5
"'?FFF#z11fJ6N6N%)*%5%5
-5
6*!~~f--;;%)*%5%5
-5
6*/9
8,5?&z2&%//&#,V#4]#CI#N 2$  .8'2,G &f-m<YG 2(*
 >C?=S "&)-8CDVW&$&&-//9;  "'M(B(F(FyRT(U(UVV  FAs01A}}}}8H"wwvr22HD ''?CX822x222R77RV    &!-000 ~}  ~  ~y|  ~J  zK  zK  ~  ~  p|  ~  ~000 JSw Em E EFJmJJJ#G#G#G (m*7'='='= )3&,,0+18*</Z ' "/s$7(VXDV9W,"$ $& -w))2 Mrm   z/config//configc                   t          j                                        j                  }t	          j        | dj        p | j                            d          pj	                  } |           |d<   |r 	||d          \  }}||d<   ||d<   t          d	          rj        rj        j        |d
<   nd |d
<   t	          j        ||          }t          |          S )Nr  r   rS  r]  r   r~  r  r  i18n_instancei18n_translationsrx   )r   r  r   r  r)   r`  r   r  r  r  hasattrr  translations_dictr  rp   )
r  rw  r  r   r  r  r   r   r'  r  s
         rk   
get_configz"App.create_app.<locals>.get_config  s    ()9)9)@AAF+$- ,=$$[11,+  D "2!1'!:!:F: <.<nYUW.X.X.X+
O'1|$,;()v// 3F4H 3.4.B.T*++.2*+ 6vtDDF!&1111rm   z/static/{path:path}c                J   K   t          t          t          |                     S rf   )rR   rC   r7   rk  s    rk   static_resourcez'App.create_app.<locals>.static_resource  s       2B42H2HIIIrm   z7/custom_component/{id}/{environment}/{type}/{file_name}r  environmentLiteral['client', 'server']r  	file_namereqc           
     0    t          d  d| d| d|            |dvrt          dd          t          j                    }t	           fd	|D             d           }|t          dd
          |j        }t          j        |         j        }|t          dd
          	 t          j	        |j
        t          | d|                     }	n # t          $ r t          dd
          d w xY wt          t          t          t!          |          j                            t          |	                    }
  d| d| }|j        vrat'          j        t!          |
                              d                                                                                    j        |<   j                            |          }ddi}|r||d<   |r/|j                            d          |k    rt5          d|          S t7          |
|          S )Nzid=z, environment=z, type=z, file_name=)clientserver  zEnvironment not supported.r.  c              3  L   K   | ]}|                                 k    |V  d S rf   )get_component_class_id)ri   itemr  s     rk   r   z@App.create_app.<locals>.custom_component_path.<locals>.<genexpr>  s:      TT$0K0K0M0MQS0S0S0S0S0S0STTrm   zComponent not found.rj  -r   )encodingzCache-Controlzmax-age=0, must-revalidateETagzif-none-matchi0  )r/  r   r   )printr   r   get_all_componentsnextr   sysmodules__file__	safe_joinTEMPLATE_DIRr7   r;   rT   r1   rt   r   parentr   hashlibsha256	read_textencode	hexdigestr  r   r   r   )r  r  r  r!  r"  r  locationmodule_namemodule_pathrequested_pathrk  rX  r  r   r   s   `             rk   custom_component_pathz-App.create_app.<locals>.custom_component_path  s    YbYYYYDYYiYY   "666# #,H    133JTTTT*TTT H #<RSSSS"-K+k2;K"#<RSSSS!&)$%:%:y%:%:;;" " $   # #,B  
 $c${"3"3":;;<< 00 D ,,$,,,,C#5553:>JJ(('(::AACC4 4)++ +C0 155c::G&(DEG *") K3;???;;wFF(S'JJJJg6666s   ',C C1z/assets/{path:path}c                J   K   t          t          t          |                     S rf   )rR   rA   r7   r  s    rk   build_resourcez&App.create_app.<locals>.build_resource  s       1A$1G1GHHHrm   z/favicon.icoc                 X   K                                    j        } t          |           S rf   )r   r   rP   )r   r   s    rk   rs  zApp.create_app.<locals>._  s'      >>++8L<(((rm   z/proxy={url_path:path}r   c                  K   	 t          j        t          t          j        d                    }	                    |           \  }}|                    d||          }n1# t          $ r$}t          dt          |                    |d }~ww xY w|	                    |d           d {V }t          j        |           \  }}|t          vr8|j                            d	d
i           |j                            ddi           t          |                                |j        |j        t%          |j                            S )Ng      $@)	transporttimeoutGETr-  r\  r.  T)streamzContent-Disposition
attachmentContent-Typezapplication/octet-stream)r/  r   
background)r   AsyncClient_proxy_transportTimeoutr   build_requestr   r   rt   sendr  
guess_typerF   r   updater   	aiter_rawr/  r$   aclose)
r   proxy_clientr   r   rp_reqr  rp_resp	mime_typers  r   s
            rk   reverse_proxyz%App.create_app.<locals>.reverse_proxy  si     O$0.!M$//       #66x@@W%33E33PP" O O O#CHHEEE3NO )--fT-BBBBBBBBG$/99LIq 222&&(=|'LMMM&&8R'STTT$!!###/)'.99	   s   AA# #
B-BBz/file={path_or_url:path}path_or_urlc                ^   K                                    }t          | ||j                  S rf   )r   rQ   r   )rZ  r  r   r   s      rk   filezApp.create_app.<locals>.file:  s/       ^^%%Fk7FC<QRRRrm   z/stream/{event_id}r  bodyr3   c                   K                                    j        j        |          }t          di |                                d|i}||_        |j                                         ddiS )Nr  rJ  rV  r   )r   _queueevent_ids_to_eventsr4   rw   datasignalr   )r  r]  r  eventr   s       rk   rs  zApp.create_app.<locals>._@  so      NN$$+?IE&LL):):LLGLLLDEJL9%%rm   z/stream/{event_id}/closec                   K                                    j        j        |          }t          j        |_        d|_        |j                                         ddiS )NTrJ  rV  )	r   r_  r`  mathinfrun_timeclosedrb  r   )r  rc  r   s     rk   rs  zApp.create_app.<locals>._H  sP      NN$$+?IE!XENELL9%%rm   z9/stream/{session_hash}/{run}/{component_id}/playlist.m3u8runintcomponent_idc                  K                                    j        |                              |i                               |d           }|st          d          S d|j         d}|j        D ]9}|d|d         ddz  }||d	          |d
          dz  }|d
         dk    r|dz  }:|j        r|dz  }t          |d          S )Nr&  r/  z9#EXTM3U
#EXT-X-PLAYLIST-TYPE:EVENT
#EXT-X-TARGETDURATION:z*
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
z#EXTINF:durationz.3fz,
r  	extension
z.tsz#EXT-X-DISCONTINUITY
z#EXT-X-ENDLIST
zapplication/vnd.apple.mpegurlrr   r   )r   pending_streamsr  r   max_durationsegmentsended)r  ri  rk  rH  playlistsegmentr   s         rk   rs  zApp.create_app.<locals>._P  s         /S"\4((	   1C0000 XU[Uh  X  X  XH!? 9 9Cwz':CCCCCwt}Fgk.BFFFF ;'500 88H| /.. -L   rm   z>/stream/{session_hash}/{run}/{component_id}/{segment_id}.{ext}
segment_idextc                  K   |dvrt          dd          S                                 j        |                              |i                               |d           }|st          dd          S t	          fd|j        D             d           }|t          dd          S |d	k    rt          |d
         d          S t          |d
         d          S )N)aactsr\  zUnsupported file extension)r/  rr   r&  zStream not foundc              3  4   K   | ]}|d          k    |V  dS )r  Nr   )ri   srx  s     rk   r   z,App.create_app.<locals>._.<locals>.<genexpr>}  s1      PP!!D'Z:O:OA:O:O:O:OPPrm   zSegment not foundr{  ra  z	audio/aacrq  z
video/MP2T)r   r   rr  r  r0  rt  )r  ri  rk  rx  ry  rH  rw  r   s      `   rk   rs  zApp.create_app.<locals>._m  s       -''C9UVVVV   /S"\4((	   MC9KLLLLPPPPvPPPRVWWGC9LMMMMe||KPPPPLQQQQrm   z9/stream/{session_hash}/{run}/{component_id}/playlist-filec                  K                                    j        |                              |i                               |d           }|st          d          S |j        sed |j        D             }                                                     |                              |d|j                   d {V }|j	        |_        t          |j                  S )Nr&  rm  c                    g | ]
}|d          S ra  r   )ri   r~  s     rk   r  z-App.create_app.<locals>._.<locals>.<listcomp>  s    BBBQqyBBBrm   T)	only_filedesired_output_format)r   rr  r  r   combined_filert  get_componentcombine_streamr  rk  r   )r  ri  rk  rH  stream_datar  r   s         rk   rs  zApp.create_app.<locals>._  s          /S"\4((	   1C0000' :BB&/BBB..**"]<00#^#"&.4.J $         (5'9$ 4555rm   z/file/{path:path}c                ,   K    | |           d {V S rf   r   )rk  r  r\  s     rk   file_deprecatedz'App.create_app.<locals>.file_deprecated  s+      dG,,,,,,,,,rm   z/reset/z/resetr5   c                   K   ddiS )NrV  Tr   )r]  s    rk   reset_iteratorz&App.create_app.<locals>.reset_iterator  s       t$$rm   z/heartbeat/{session_hash}background_tasksr   r]  c                z     t          j                     fd}t           |            d          S )zClients make a persistent connection to this endpoint to keep the session alive.
            When the client disconnects, the session state is deleted.
            c            
      K   t          j        j                                                  } 	 	 dW V  t          j        t          j                            }t          j        || gt           j                   d {V \  }}| |v rt          j                    n# t           j        $ r |                                 s|                                  t                    }t          j        t           d j                  }t          g           }d                                 j                                        D             }|D ]D}                    t          j        ||                                j        |         |	           Ej        j        v rdj        j                 _        t/          j                                                   j        j                            g           D ]P}	                                j        j        |	         }
t:          j        |
_        |
j         !                                 QY d S w xY w3)
NTzdata: ALIVE

)return_whenr  z/heartbeat/rS  )r  ra  r  c                T    g | ]%\  }}t          d  |j        D                       #|&S )c              3  2   K   | ]}|d          dk    |V  dS )r   unloadNr   rh   s     rk   r   zQApp.create_app.<locals>.heartbeat.<locals>.iterator.<locals>.<listcomp>.<genexpr>  s0      "N"NQqTX=M=M1=M=M=M=M"N"Nrm   )r   targets)ri   r  deps      rk   r  zGApp.create_app.<locals>.heartbeat.<locals>.iterator.<locals>.<listcomp>  sK     - - - &3""N"Nck"N"N"NNN-- - -rm   r   r]  
gr_requestfnr   )"rD  create_taskr   waitrE  FIRST_COMPLETEDCancelledErrordoner   rM   r)   r`  r@   r   r4   r   fnsr  add_taskcall_process_apir   session_data	is_closedr(   clear_session_cachesr_  pending_event_ids_sessionr  r`  re  rf  rg  rb  r   )stop_stream_task	wait_taskr  rs  r"  r   r]  unload_fn_indicesfn_indexr  rc  r   r  rF  r  r  r]  s              rk   iteratorz3App.create_app.<locals>.heartbeat.<locals>.iterator  s     #*#6s~7J7J7L7L#M#M 76///// %,$7n8U8U$V$V	(/&(89(/(?) ) ) # # # # # #a ,t33")"8":":: 4"1 + + +/4466 6,33555%gxlSSS$/$<$+*4'O'O'O'O&)m% % %	
  3)5B     - -*-..*:*:*>*D*D*F*F- - -)
 ): 
 
H -55 + <$'%)+.#&>>#3#3#7#A*3 6     (3+;+HHHTXC,9,GQ4\BBB !^^--4NRR(" 	/ 	/$ %(NN$4$4$;$O (%E .2XEN!L,,....W+7s   A-B   F:IIrL  rM  )r   get_heartbeat_rater   )r  r  r  r]  r  rF  r   s   ```` @rk   	heartbeatz!App.create_app.<locals>.heartbeat  sg     #577N9 9 9 9 9 9 9 9 9 9v %XXZZ<OPPPPrm   z/run/{api_name}z/run/{api_name}/z/api/{api_name}z/api/{api_name}/api_namec                  K   t          d
i |                                d|i}t          j        
                                | |          }
                                j        s"|j        rt          dt          j	                  t          j
        ||||          }t          j        ||j        j        
j                  }	 t          j        
||||           d {V }n# t           $ rv}t#          j        |
                                j                  }	t)          |t*                    r|j        rt/          j                     t3          |	d	          cY d }~S d }~ww xY wt5          |          S )Nr  r   r  r]  zcThis API endpoint does not accept direct HTTP POST requests. Please join the queue to use this API.)r0  r/  )r  r]  r  rS  r    )rr   r/  r   )r4   rw   r)   get_fnr   api_openqueuer   r   HTTP_404_NOT_FOUNDcompile_gr_requestr`  r   rk  r   r  BaseExceptionr   error_payload
show_errorrv   r:   print_exception	traceback	print_excr   rp   )r  r]  r  r]  r  r  r   r  r,  rr   r   s             rk   predictzApp.create_app.<locals>.predict  s      'LL):):LLGLLLD#~~''(  B >>##,  # A & 9    %7!	  J $0";+-  I
*;)'            !   -eS^^5E5E5PQQ!%// *53H *')))## #        	 "&)))s   	C) )
E)3A+E$E)$E)r  r	   r   c                (   t          | j                  t          |j                  k    rd S d |j        D             }t          | j                  t          |          k    rd S t          | j                  fd|j        D             | _        d S )Nc                     g | ]}|j         	|S r   )skip_api)ri   blocks     rk   r  zCApp.create_app.<locals>.prepare_simple_api_data.<locals>.<listcomp>)  s    MMMEenM%MMMrm   c                @    g | ]}|j         rd nt                    S rf   )r  r0  )ri   r  ra  s     rk   r  zCApp.create_app.<locals>.prepare_simple_api_data.<locals>.<listcomp>-  s*    WWWE?T$ZZWWWrm   )r  ra  inputsiter)r]  r  
api_inputsra  s      @rk   prepare_simple_api_dataz/App.create_app.<locals>.prepare_simple_api_data&  s    49~~RY//MMRYMMMJ49~~Z00	??DWWWWRYWWWDIIIrm   z/call/v2/{api_name}z/call/v2/{api_name}/c                x  K   	j         d         d| z            d         }t          j        |d|          }t          |          }t	          di |                                ddi}t          j        	                                | |          } 
||           |j	        |_
         |||           d {V S )	Nr  rj  r  r   r  simple_formatTr  )r   client_utilsconstruct_argsr6   r3   rw   r)   r  r   _idr  )r  r]  r  r]  parameters_infoprocessed_argssimple_body	full_bodyr  r   r  queue_join_helpers            rk   rs  zApp.create_app.<locals>._/  s       "l+<=cHnMO *8 N
 ,@@@K#SSk&<&<&>&>SSdSSSI#~~''(  B $#Ir222!#I**9gxHHHHHHHHHrm   z/call/{api_name}z/call/{api_name}/r6   c                   K   t          di |                                ddi}t          j                                        | |          } ||           |j        |_         |||           d {V S )Nr  Tr  r   )r3   rw   r)   r  r   r  r  )	r  r]  r  r]  r  r  r   r  r  s	         rk   simple_predict_postz+App.create_app.<locals>.simple_predict_postH  s       $LLdoo&7&7LLtLLLI#~~''(  B $#Ir222!#I**9gxHHHHHHHHHrm   z/queue/joinc                r   K   | j         t          t          j        d           | ||           d {V S )NzSession hash not found.r.  )r  r   r   HTTP_400_BAD_REQUEST)r]  r  r]  r  s      rk   
queue_joinz"App.create_app.<locals>.queue_joinX  s[        (# & ;4    +*4(CCCCCCCCCrm   c                  K   	                                 }|j        j        |j                            	           |j        j        rt          t          j        d          t          di | 	                                d|i} |j        
                    | ||           d {V \  }}}t          j        t          j        t          j        t          j        d}|s||         }t          ||          d|iS )NzQueue is stopped.r.  r  )r]  r  r]  )
queue_fullvalidator_errorr,  rV  r  r   )r   r_  
server_appset_server_appstoppedr   r   HTTP_503_SERVICE_UNAVAILABLEr4   rw   pushHTTP_422_UNPROCESSABLE_ENTITYr  HTTP_200_OK)
r]  r  r]  r   rV  r  state	error_mapr/  r   s
            rk   r  z)App.create_app.<locals>.queue_join_helpere  s2     
 ^^%%F}'/,,S111}$ # & C.    'LL):):LLGLLLD-3]-?-?7X .@ . . ( ( ( ( ( ($GXu %A#)#G4!-	 I  N'.#HMMMM))rm   z/cancelr-   c                  K   t          | j         d| j         h           d {V                                  }| j        |j        j        v }| j        |j        j                            | j        i           v }|j        	                    | j                   d {V  |rC|rAt          i d| j                  }|j        j        | j                                     |           | j        j        v rj        4 d {V  	 t          j        | j                            d {V  n# t          $ r Y nw xY wj        | j        = j                            | j                   d d d           d {V  n# 1 d {V swxY w Y   ddiS )Nrs  T)r  rV  r  rV  )r`   r  r  r   r_  pending_messages_per_sessionr  r  r  remove_from_queuer[   
put_nowaitr   r   rc   r  r   add)r]  r   session_openevent_runningmessager   s        rk   cancel_eventz$App.create_app.<locals>.cancel_event  sW     4#4 F Ft} F FGHHHHHHHHH^^%%F !V]%OO  =:>>t?PRTUUV  -11$-@@@@@@@@@ & &1tdm   :%*W%%%}--8 > > > > > > > >23=3OPPPPPPPPPP$   dm4*..t}===> > > > > > > > > > > > > > > > > > > > > > > > > > > t$$s6   E7%D)(E7)
D63E75D66/E77
FFz/call/v2/{api_name}/{event_id}z/call/{api_name}/{event_id}c                   K   dd}                                 j        j                            |          }|r|j        n|} | ||           d {V S )Nr  rY   rs   r!  c                   |                                  }t          | t                    r6| j        rdnd}| j        r|d                             d          n|d         }nt          | t
                    r6| j        rdnd}| j        r|d                             d          n|d         }n;t          | t                    rd}d }n!t          | t                    r
d}| j        }nd S d| dt          j
        |           d	S )
Ncompleter,  r  ra  
generatingr  r=  r>  r?  )rw   rv   r[   rV  r  r\   rZ   r]   r  rC  r   )r  rJ  rc  ra  s       rk   process_msgz?App.create_app.<locals>.simple_predict_get.<locals>.process_msg  s   ((**g'>??  *1/FJJwE5<_WH))&111#h- D  )ABB  ,3OHLLE5<_WH))&111#h- D  )9::  'EDD)?@@  #E"?DD4FFF
40@0@FFFFrm   )r  rY   rs   r!  )r   r_  r`  r  r  )r  r  r  rc  r  r   queue_data_helpers        rk   simple_predict_getz*App.create_app.<locals>.simple_predict_get  s}      G G G G, NN$$+?CCHMME16D5--HL**7L+NNNNNNNNNrm   z/queue/datac                6   K   dd} | ||           d {V S )Nr  rY   rs   rt   c                    dt          j        |                                 t                                        d           dS )Ndata: )ry   r   r?  )r~   r   rw   rt   r   )r  s    rk   r  z7App.create_app.<locals>.queue_data.<locals>.process_msg  s=    eW-?-?-A-A3 O O O V VW^ _ _eeeerm   )r  rY   rs   rt   r   )r  r  r  r  s      rk   
queue_dataz"App.create_app.<locals>.queue_data  sH      
f f f f +*7L+NNNNNNNNNrm   r  $Callable[[EventMessage], str | None]c                   K                                    t          j                    fddfd}t           ||           d          S )Nc                    K   j         rkt          j                   d {V  j        j                                      } | r'|                     t                                 d {V  j         id S d S rf   )
is_runningrD  rE  r_  r  r  putrZ   )r  r   rF  r  s    rk   r  z<App.create_app.<locals>.queue_data_helper.<locals>.heartbeat  s      ' <!-777777777 #MFJJ<XXE <#ii(8(:(:;;;;;;;;; ' < < < < <rm   r  r   c                 K   t          j                               }	 	 |                                  d {V r7j                            	           d {V  |                                 d S 	j        j        vrt          t          j	                  d }	 j        j        	         }t          j
        |                                d           d {V }n# t          t           j        f$ r Y nw xY wj        j        rt          dd          }|r |          }||W V  t          |t                     r|j        r|j        j        j        	         v r*j        j        	                             |j                   |j        t*          j        k    s8|j        t*          j        k    rYt1          j        j        	                   d	k    r6t3                      } |          }||W V  |                                 d S # t4          $ r}t          t7          |          t          |t                    
          } |          }t          |t           j                  r.j        j        	= j                            	           d {V  ||W V  |                                 |d }~ww xY w)NTr  rm  
   rF  zServer stopped unexpectedly.F)r  rV  r   )r  session_not_found)rD  r  rB  r_  clean_eventsr   r  r   r   r  wait_forr  TimeoutErrorr  r]   rv   r[   r  r  removerJ  r   server_stoppedprocess_completedr  rW   r  rt   r  )
r  heartbeat_taskr  messagesre  r  r   r  r  r  s
         rk   
sse_streamz=App.create_app.<locals>.queue_data_helper.<locals>.sse_stream  sf     !(!4YY[[!A!APB+!(!8!8!:!::::::: #"(-"<"<,"<"W"WWWWWWWW*11333"F )#)=#MN N #0,2,E# # #  #'!'-}'Q ,(H -4,<X\\^^UW,X,X,X&X&X&X&X&X&XGG ,g.BC ! ! ! D! "=0 &<(F(-' ' 'G # &+'2{7';';H'3&. *74K L L"+$+$4"+ %,$4(.(O,8)*%& %& %+M$K(4%&&,fW-=&>&>&>#*;-2N#N#N$+K=3R$R$R(+,2M,S0<-.)* )*
 ,-)- )- /A.B.BG/:{7/C/CH'/';.6$2$9$9$;$;$;$*FEB+F %   4 #A*4Q*F*F  G  +{733H!!W%;<< T"MF|T$m88l8SSSSSSSSS+&"))+++GsK   AH 3*H A C H C85H 7C88DH H 
K B!J;;K rL  rM  rN  )r   r   r  r   )r  r  r  r  r   r  rF  r   s    `` @@@rk   r  z)App.create_app.<locals>.queue_data_helper  s      
 ^^%%F"577N< < < < < < <R R R R R R R R Rh %
7##.   rm   7Union[ComponentServerJSONBody, ComponentServerBlobBody]c                  K   | j                             d          }t          |t                    r|                    d          rg }i }|                                 4 d {V }|                                D ]\  }}t          |t                    rt          |          dk    rt          |d         t                    rnt          |          D ]]\  }}t          |t                    r9|j        }	|                                 d {V }
|                    |	|
f           S||| d| <   ^t          |t                    r:|j        }	|                                 d {V }
|                    |	|
f           |||<   	 d d d           d {V  n# 1 d {V swxY w Y   t          t          ||          |d         |d         |d	         
          S 	 |                                  d {V }t#          |d         |d         |d         |d	         
          S # t$          $ r t'          t(          j        d          d w xY w)NrJ  r  r   r   r*  )ra  r  rk  r  fn_name)ra  rk  r  r  ra  zInvalid JSON body.r.  )r   r  rv   rt   
startswithformr  rm  r  StarletteUploadFiler   filenamereadr  r.   r0   rC  r/   r  r   r   r  )r  content_typer  ra  r
  rX  r   r  r  r  contentss              rk   get_item_or_filez(App.create_app.<locals>.get_item_or_file8  s(      #?..~>>L,,, . 1H1H%2 2 .  "<<>> . . . . . . .T&*jjll . .
U&ud33. #E

Q *585H I I !/ )2%(8(8 ; ;1#-a1D#E#E !;/0zH56VVXX~~~~~~H$)LL(H1E$F$F$F$F9:DC!$6$6; (/BCC .',~H-2ZZ\\'9'9'9'9'9'9H!LL(H)=>>>>(-DII%.. . . . . . . . . . . . . . . . . . . . . . . . . . .* /&D>>>!%n!5!%n!5 O	    !(//////D2!&\%).%9%).%9 $Y	    !      '$*$?3      s    'D"F
F&)F&"AH' ''Iz/component_serverz/component_server/c                  K    	|            d {V }j         |j                 }|j        }||v r	||         }n                                j        |         }t          ||j        d           }|t          |dd          st          t          j	        d          t          ||j        g| d           ^}}t          j        |          r ||  d {V S  || S )N_is_server_fnFzFunction not found.r.  )r   r  rk  r   r   r  r  r   r   r  r<   ra  rb  rc  )
r  r]  r  rk  r  r  processed_inputrs  r   r  s
           rk   component_serverz(App.create_app.<locals>.component_serverm  s       *)'22222222D$T%67E,Lu$$l+((/=d33Bz_e!D!Dz# & 90    #/	# #Oa *2.. ,R11111111r?++rm   z/queue/status)r8  response_modelc                 ^   K                                     j                                        S rf   )r   r_  
get_statusr   s   rk   get_queue_statusz(App.create_app.<locals>.get_queue_status  s(       >>##*55777rm   z/upload_progressr  c                   K   d fd}	 t          j        t                                         d           d {V  n-# t           j        t          f$ r t          dd          cY S w xY wt           ||          d	
          S )Nr  r   c                 K   t          j                    }d}	 |                                  d {V rt                                         d S |rt                                         d S d}d}	 t                                        rddi}d}n*t                                        }d|j        |j        d}d	t          j
        |           d
W V  n# t          $ r Y d S t          $ ri t          j        |           d {V  t          j                    |z
  |k    r2ddi}d	t          j
        |           d
W V  t          j                    }Y nw xY wD)NFTr;  r<  rJ  r  rR  )rJ  	orig_name
chunk_sizer  r?  r  )r@  rA  rB  file_upload_statusesstop_trackingis_doner  r  r  rC  r   rJ   rI   rD  rE  )r  rH  r   rF  rG  r  rR  r  s          rk   r  z?App.create_app.<locals>.get_upload_progress.<locals>.sse_stream  s     !%!2!4!4A$4466666666 ,::9EEE ,::9EEE%'N!%JA/77	BB 	',foG&*GG%9%=%=i%H%HF'/-3_.4.?' 'G
 Atz'':':@@@@@@@@<   ; A A A%mJ777777777,..?.PP',k&:G"D4:g+>+>"D"D"DDDDD-1->-@-@NA1As   3A&C 
E'A/EE   r  zUpload not foundr&  rm  rL  rM  rN  )rD  r  r  
is_trackedr  r   r   )r  r  r  s   `  rk   get_upload_progressz+App.create_app.<locals>.get_upload_progress  s       A  A  A  A  A  ADN&(33I>>           (,7 N N N();MMMMMMN %
7##.   s   4A   'A*)A*startfloatc                    dd l }ddlm}m}m} |rb |t          |                                          d|           }t          j                    |z
  dz  |_	        |
                    |           d S d S )Nr   )PROFILING_ENABLEDRequestTrace	collectorgradio_file_upload)r  r  r  i  )uuidgradio.profilingr'  r(  r)  rt   uuid4r@  	monotonic	upload_msr  )r  r$  r+  r'  r(  r)  traces          rk   set_upload_tracez(App.create_app.<locals>.set_upload_trace  s    KKKSSSSSSSSSS  %$ ..0!-  
 $(>#3#3e#;t"Ce$$$$$% %rm   z/uploadbg_tasksc                  K   d }	rt          j                    }	 t          | 
j        j        j        nt
          j        |d|rt          nd            d {V \  }}}n:# t          $ r-}d|j	        v rdnd}t          |j	        |          cY d }~S d }~ww xY w|r|                    t          ||           	r0|                    | j                            dd          |           j                            |           |S )	NF)
force_moveupload_progressmaximum allowed size  r\  rm  r  r   )r@  r.  rU   r   max_file_sizere  rf  r  r&   r  r   r  rS   r   r  upload_file_setrR  )r  r2  r  r$  output_filesfiles_to_copy	locationsexccoder'  r   r   r1  s            rk   upload_filez#App.create_app.<locals>.upload_file  s~      E  )((H?H)+7 (($<E$O$8$84	@ 	@ 	@ 	: 	: 	: 	: 	: 	:6mYY & H H H4CCss($GGGGGGGGGH  !!0-   ! !!$go&9&9."&M&Mu   ")),777s   AA" "
B,"BBBz/startup-eventsc                    K    j         s[                                                                                                                                    d {V  d _         dS dS )NTF)r   r   run_startup_eventsrun_extra_startup_eventsr  s   rk   startup_eventsz&App.create_app.<locals>.startup_events  sn      /   33555nn&&??AAAAAAAAA/3,t5rm   z
/theme.cssc                 T    t                                           j        d          S )Nztext/cssrM  )r   r   	theme_cssr  s   rk   rE  z!App.create_app.<locals>.theme_css  s%     %S^^%5%5%?JWWWWrm   z/robots.txtc                 >                                      j        rdS dS )NzUser-agent: *
Disallow: /zUser-agent: *
Disallow: )r   r  r  s   rk   
robots_txtz"App.create_app.<locals>.robots_txt	  s$    ~~% 33322rm   z	/pwa_iconz/pwa_icon/{size}size
int | Nonec                  K                                    }|j        }|t          d          | t          |          S dd l}|j                            |          }|                    | | f          }t          j	                    }|
                    |d           |                    d           t          t          j	        |                                          d          S )Nr&  rm  r   PNG)r  	image/pngrM  )r   r   r   r   	PIL.ImageImager  resizeioBytesIOsaveseekr   r  )rH  r   r   PILimgimg_byte_arrayr   s         rk   pwa_iconz App.create_app.<locals>.pwa_icon  s       ^^%%F!.L##4444|#L111)....C**dD\**CZ\\NHH^EH222"""$
>..0011k   rm   z/manifest.jsonc                    j         } t          | t                    rt          |           } | 	dddddg}ni|                     d          r                    d          ddddg}n8                    dd          d	d
dd                    dd          dd
ddg}t                                          j        pd|dddd          S )Nzstatic/img/logo_nosize.svgr   zimage/svg+xml)srcsizesr  purposez.svgrW     )rH  192x192rL  i   512x512Gradioz./
standalone)rg   icons	start_urldisplayzapplication/manifest+jsonrq  )	r   rv   r   rt   r   url_path_forrp   r   r  )r   ra  r   r   s     rk   manifest_jsonz%App.create_app.<locals>.manifest_json(  s=   !.L,-- 1"<00#  <!& /#(	  &&v..   #//
;;!& /#(	   #//
/EE!* +#(	   #//
/EE!* +#(	  "  NN,,2>h"!%+  7	 	 	 	rm   /monitoringc                   K   j         st          dd          t          j        | t           dj                  }| dj         }t          d| d           t          d	          S )
N  Monitoring is not enabled.r.  rf  rS  /monitoring/z* Monitoring URL: z *zSee console for monitoring URL.)	enable_monitoringr   r)   r`  r@   r   r   r.  r   )r  root_urlmonitoring_urlr   r   s      rk   analytics_loginz'App.create_app.<locals>.analytics_loginZ  s      + # #,H    #/(555-  H
 !)IIc6GIIN9~999::: ABBBrm   z/monitoring/summaryc                 D   K                                     j        j        S rf   )r   r_  cached_event_analytics_summaryr  s   rk   rs  zApp.create_app.<locals>._i  s      >>##*IIrm   z/monitoring/{key}rX  c                  K   j         st          dd          t          | j                  rdj         d}j        sbddlm} ddlm} t          ||d	
           |j	        
                                                                 j	        j        }||d<   d_        t          |t          j                  S t          dd          )Nrh  ri  r.  rj  z
/dashboardr   r  )demoF)rk  r   ra  TrU  zInvalid key.)rk  r   rN   r   r   gradio.monitoring_dashboardra  rr  mount_gradio_appr_  r$  r   event_analyticsr'   r   ra  )rX  analytics_urlra  	dashboard	analyticsr   r   s        rk   analytics_dashboardz+App.create_app.<locals>.analytics_dashboardm  s     + # #,H    *#s/@AA L Ls/@ L L L- 
2@@@@@@MMMMMM$Y]u    $**,,, # 0 0 7 GI#,DL-1C*'%63H    $NKKKKrm   z/process_recordingc           
       K   	 | j                             d          }t          |pd          \  }}|dk    rt          dd          | j        }t          |d          r|                                j        nd }||nt          j	        }t          | j         |                                 dd	|
          }|                                 d {V }n:# t          $ r-}d|j        v rdnd}	t          |j        |	          cY d }~S d }~ww xY w|                    d          }
|
rt#          |
d         t$                    st          dd          |
d         }i }|                    d          E|                    d          0|                    d          |d<   |                    d          |d<   |                    d          }|r@	 t'          j        t+          |                    |d<   n# t&          j        $ r g |d<   Y nw xY wt/          j        ddt2                    5 }|j                            d           t9          j        |j        |           |j        d d d            n# 1 swxY w Y   t9          j        d          $tA          ddtC          fd                    S t/          j"        dt2                    d         }	 tG          ||           d {V \  }tA          |ddtC          fd                    S # tH          $ r' tA          ddtC          fd                    cY S w xY w) NrJ  r   s   multipart/form-datar\  zInvalid content type.r.  r   r   r  )	max_files
max_fieldsr8  r6  r7  rm  videor   zNo video file providedremove_segment_startremove_segment_endzoom_effectsFz.mp4)deletesuffixdirffmpegz	video/mp4zgradio-screen-recording.mp4c                       g          S rf   r   cleanup_files
input_paths   rk   <lambda>z;App.create_app.<locals>.process_recording.<locals>.<lambda>      mmZL6Q6Q rm   )r   r  rK  z_processed.mp4)r  r  c                                 S rf   r   )r  
temp_filess   rk   r  z;App.create_app.<locals>.process_recording.<locals>.<lambda>  s    mmJ6O6O rm   c                       g          S rf   r   r  s   rk   r  z;App.create_app.<locals>.process_recording.<locals>.<lambda>  r  rm   )%r   r  r#   r   r   r  r   r8  re  rf  rK   rH  parser&   r  r   getlistrv   rL   rC  r  rt   r  tempfileNamedTemporaryFilerB   r\  rS  shutilcopyfileobjrg   whichr   r$   mkstemprV   r  )r  content_type_headerr  rs  r   r8  multipart_parserr
  r=  r>  video_files
video_fileparamszoom_effects_json
input_fileoutput_pathprocessed_pathr  r  r  s                    @@rk   process_recordingz)App.create_app.<locals>.process_recording  s_     H&-o&9&9.&I&I#"67J7Pb"Q"Qa#999'C@WXXXXk sL11CNN$$22 
 2?1JPTPX#8ONN$$!"/$ $ $  .3355555555% H H H4CCss($GGGGGGGGGH ,,w//K VjQAQ&R&R V#<TUUUU$QJF/00<HH122>15:P1Q1Q-./3xx8L/M/M+, $ 8 8  00-1Z<M8N8N-O-OF>**+ 0 0 0-/F>***0 ,V1A   -$$Q'''":?J???'_
- - - - - - - - - - - - - - - |H%%-#*:-.Q.Q.Q.Q.QRR	    #*'-=  K3LV4 4 . . . . . .*
 $"*:-.O.O.O.O.OPP	       #*:-.Q.Q.Q.Q.QRR	     sT   CC 
D"D DD$G2 2H	H	(<I00I47I4=L .MMvibe_edit_history)r  r  history   	max_pairsc                N   |                                  sdS |                     d          }t          |          |k    r| S || d         }t          |          dk    rF|d                             d          r	|d         }nd|d         z   }|dd         D ]
}|d|z   z  }|S dS )zLLimit chat history in the prompt to the last max_pairs user-assistant pairs.r   
User: Nr   zUser: r   )r^  splitr  r	  )r  r  user_messagesrecent_messagesresultrJ  s         rk   limit_chat_historyz*App.create_app.<locals>.limit_chat_history  s    ==?? r#MM*55M=!!Y..+YJKK8O?##a''"1%00:: ;,Q/FF%(::F*122. / /Cj3..FF2rm   z<\|[^>]*\|>z3<\|start\|>assistant<\|channel\|>final<\|message\|>z	<\|end\|>z9<\s*reasoning\s*>\s*(?P<body>.*?)\s*<\s*/\s*reasoning\s*>z!<\s*think\s*>.*?<\s*/\s*think\s*>rawc                T   | s| S                      |           }|rc| |                                d          }                     |          }|r|d |                                         }|                                S                     d|           }|                                S )Nr   )searchendr$  r^  sub)r  mtextm_endcontrol_token_reend_refinal_start_res       rk   clean_out_markersz)App.create_app.<locals>.clean_out_markers  s     
%%c**A $1557799~d++ 1%++--0Dzz||##''C00D::<<rm   r  c                0                         d|           S )z/Remove any <think> ... </think> blocks entirelyr   )r  )r  think_block_res    rk   strip_think_blocksz*App.create_app.<locals>.strip_think_blocks  s    !%%b$///rm   tuple[str, str]c                   g }t                      }                    |           D ]Y}|                    d                                          }|r.||vr*|                    |           |                    |           Zd                    |                                          }                    d|                                           }||fS )z
            Extract all <reasoning>...</reasoning> and code. If multiple, concatenate with blank lines, de-duping exact copies.
            r]  r?  r   )r   finditergroupr^  r  r  joinr  )r  reasoning_chunksseenr  r]  reasoning_text	code_textreasoning_block_res          rk   split_reasoning_codez,App.create_app.<locals>.split_reasoning_code  s      "55D'0066 # #wwv,,.. #D,,$++D111HHTNNN#[[)9::@@BBN*..r488>>@@I!9,,rm   )InferenceClientz/vibe-edit/z
/vibe-editr9   c                  	K   j         st          dd          ddlm} t	          |          5 }|                                }d d d            n# 1 swxY w Y   t          j        d          }| dz  }t	          |d          5 }|                    |           d d d            n# 1 swxY w Y   d	         |<   d
} d	                   }d| d| j	         d|r|nd d}t                      }	                    dd|	dd|dgd          j        d         j        j        }|t          dd           |          } |          }d	xx         d| j	         d| dz  cc<    |          \  }
}d|v rU|                    d          t!          d          z   }|                    d|          }|dk    r
|||         n	||d          }|                    d          }|                    d          }t'          t)          j        ||d                    }d}d}|D ]a}|                    d           r|                    d!          s|d"z  }2|                    d#          r|                    d$          s|d"z  }bt	          |d          5 }|                    |           d d d            n# 1 swxY w Y   |||d%|
d&S )'Nrh  6Vibe editor is not enabled. Use --vibe flag to enable.r.  r   GRADIO_WATCH_DEMO_PATHr   .pywr  r   z
You are a code generator for Gradio apps. Given the following existing code and prompt, return the full new code.
Existing code:
```python
z
```

Prompt:
z

History:
zNo chat history.rp  openai/gpt-oss-120bsystemrolerr   r(  '  modelr  
max_tokensr  Error generating coder  z
Assistant: z
```python
z
```T)keepends)n+z+++r   r*  z---)lines_addedlines_removed)hash
diff_stats	reasoning)	vibe_moder   gradio.http_serverr  r  r  r   	token_hexr  promptload_system_promptchat_completionchoicesr  rr   indexr  find
splitlinesrm  difflibunified_diffr	  )r]  r  r  original_codesnapshot_hashsnapshot_filerr   limited_historyr  system_promptr  r$  r  original_lines	new_linesdiffr  r  liner   chat_historyr  hash_to_chat_historyinference_clientr  r  r  vibe_edit_history_dirs                      rk   	vibe_editz!App.create_app.<locals>.vibe_edit4  sh      # # #S   
 BAAAAA,-- ) !) ) ) ) ) ) ) ) ) ) ) ) ) ) ) $-b11M1}4I4I4IIMmS)) 'Q&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 3?y2I /G00i1HIIO 	    $;);  F /00M 00/!)mDD!'F;;  % 1      #<STTTT''00G((11G###'W$+'W'WG'W'W'WW###!5!5g!>!>Iw''m44s=7I7IIll7E2203r		'%),,wuvv +55t5DDN**D*99I,^Y!LLLMMDKM ' '??3'' '0F0F '1$KK__S)) '$//%2H2H '!Q&M,c22 !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! &#.%2  '  s5   AAA	B++B/2B/ KK	Kz/undo-vibe-edit/z/undo-vibe-edit.)embedr  c                  K   j         st          dd          ddlm} |  dz  }|                                st          dd          t          |          5 }|                                }d d d            n# 1 swxY w Y   t          |d	          5 }|                    |           d d d            n# 1 swxY w Y                       | d
          d<   ddiS )Nrh  r  r.  r   r  r  r&  zSnapshot not foundr  r   r  rV  T)	r  r   r  r  r  r  r  r  r  )	r  r  r  r  saved_contentr   r  r  r  s	        rk   undo_vibe_editz&App.create_app.<locals>.undo_vibe_edit  s      # # #S   
 BAAAAA1tLLL@M '')) R#<PQQQQ m$$ ) !) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ,c22 'a&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ';&>&>tR&H&HL#t$$s$   A??BBB<<C C z/vibe-code/z
/vibe-codec                 b  K   j         st          dd          ddlm}  	 t	          |           5 }|                                }d d d            n# 1 swxY w Y   d|iS # t          $ r t          dd          d t          $ r'}t          d	d
t          |                     |d }~ww xY w)Nrh  r  r.  r   r  r>  r&  zDemo file not foundr  zError reading file: )	r  r   r  r  r  r  r  r  rt   )r  r  r>  r  r   s       rk   get_vibe_codez%App.create_app.<locals>.get_vibe_code  sD      # # #S   
 BAAAAA011 $Q6688D$ $ $ $ $ $ $ $ $ $ $ $ $ $ $~%$   # #,A      # #,K3q66,K,K  s:   A" AA" AA" AA" "%B."B))B.r8   c                :  K   j         st          dd          ddlm} 	 t	          |d          5 }|                    | j                   d d d            n# 1 swxY w Y   ddiS # t          $ r'}t          d	d
t          |                     |d }~ww xY w)Nrh  r  r.  r   r  r  rV  Tr  zError writing file: )	r  r   r  r  r  r  r>  r  rt   )r]  r  r  r  r   s       rk   update_vibe_codez(App.create_app.<locals>.update_vibe_code  s      # # #S   
 BAAAAA0#66 '!GGDI&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' '!4((   # #,K3q66,K,K  s:   A) AA) AA) !A"A) )
B3"BBz/vibe-starter-queries/z/vibe-starter-queriesc                   K   j         st          dd          ddlm}  t	          |           5 }|                                }d d d            n# 1 swxY w Y   d| d}t          d	          }	                    d
d|dd|dgd          j        d         j	        j
        }|t          dd           
|          } |          }|                    d          }d|iS )Nrh  r  r.  r   r  z
You are a prompt generator for a gradio vibe editor. Given the following existing code, return a list of starter queries that can be used to generate a new code.
Existing code:
```python
z
```
T)starter_queriesr  r  r  r(  r  r  r  r  rp  r  )r  r   r  r  r  r  r  r  r  r  rr   r  )r  r  r>  r  r  rr   r  r   r  r  r  s          rk   get_vibe_starter_queriesz0App.create_app.<locals>.get_vibe_starter_queries  s      # # #S   
 BAAAAA,--  vvxx                              	  F /tDDDM 00/!)mDD!'F;;  % 1      #<STTTT((11G''00G%mmD11O "? s   AAAc           
         | D ]q}	 |r3t           j                            |          rt          j        |           9# t          $ r,}t          d| dt          |                      Y d }~jd }~ww xY wd S )NzError cleaning up file z: )r   rk  r  unlinkr  r.  rt   )r  r\  r  s      rk   r  z%App.create_app.<locals>.cleanup_files	  s     F FF (t 4 4 (	$  F F FDDDDCFFDDEEEEEEEEF	F Fs   5<
A2"A--A2)r'  r)  z/profiling/traceslast_nc                N   K   t                              |                     S )N)r  )rp   get_all)r  r)  s    rk   profiling_tracesz(App.create_app.<locals>.profiling_traces	  s(       &i&7&7v&7&F&FGGGrm   z/profiling/summaryc                 J   K   t                                                     S rf   )rp   get_summaryr  s   rk   profiling_summaryz)App.create_app.<locals>.profiling_summary	  s!      %i&;&;&=&=>>>rm   z/profiling/clearc                 R   K                                      t          ddi          S )Nr   cleared)clearrp   r  s   rk   profiling_clearz'App.create_app.<locals>.profiling_clear	  s*      !!!%x&;<<<rm   r   )r  r   rs   r!  )r(  rt   )r  r   rs   r3  rN  )r  r   rQ  r   )r  r   r(  rt   rh  r  )rk  rt   rf   )rw  rt   r  r   rz  r!  )r  r   r(  rt   rz  rt   rw  rt   )r  rt   )r   )r  r   rw  rt   )
r  rt   r  r   r  rt   r!  rt   r"  r   )r   rt   )rZ  rt   r  r   )r  rt   r]  r3   r  r   )r  rt   )r  rt   ri  rj  rk  rj  )
r  rt   ri  rj  rk  rj  rx  rt   ry  rt   )rk  rt   r  r   )r]  r5   )r  rt   r  r   r  r   r]  rt   )r  rt   r]  r3   r  r   r]  rt   )r]  r3   r  r	   rs   r   )r  rt   r]  r   r  r   r]  rt   )r  rt   r]  r6   r  r   r]  rt   )r]  r3   r  r   r]  rt   )r]  r-   )r  r   r  rt   )r  r   r  rt   )r  r   r  rt   r  r  )r  r   rs   r  )r  rt   r  r   )r  rt   r$  r%  )r  r   r2  r   r  r!  )rH  rI  )rX  rt   )r  )r  rt   r  rj  rs   rt   )r  rt   rs   rt   )r  rt   rs   rt   )r  rt   rs   r  )r]  r9   )r  rt   )r]  r8   )r  rI  )+r   rp   r   r  delete_cacherO   r  routerlifespan_contextr   launch_mcp_on_sser   r   r@   r   add_middlewarerG   r+   r   r  r   expects_oauthr?   r  headr   rX   r   r   rB   r  recompile
IGNORECASEDOTALLr  huggingface_hubr  r   r,  r'  r)  include_router)Sr   r   r   r   r  r   r  r  r  r  r2  r5  r7  rO  rf  ro  rs  r  pagesetrz  rw  r  r  r  r@  rB  rY  r  r  r  r  r  r  r  r  r  r  r  r#  r?  rC  rE  rG  rW  re  rn  ry  r  r  r  r  r  r  r  r	  r  r  r'  r   r  r  r  r)  r  r  r\  r  r'  r  r  r  r  r  ry  r  r  r  r  r1  r  r  r  r  sS   ``                                                       @@@@@@@@@@@@@@@@@@@@@@@@@@rk   
create_appzApp.create_appe  s     %2
6GGG**6:zJJ*:l;%<z400&3?& & &Jz" QQoQQQ5QQQCC*Az400+3?+ + +CJ'   	X!33CfFVWWW*---&!!!/[III*m 	 	
 	
 	
 
G			H			) 	) 	) 	) 	) 
	 
		) 
N	#	#	O	$	$$+,<$=$= 		 		 		 		 		 		 		 
%	$ 
$	#		 
H			I			C 	C 	C 	C 	C 
	 
		C 
I			J			7 	7 	7 	7 	7 
 	 
		7 
M1E1E0F	G	G	 	 	 	 	 
H	G	@ 
(			)		MTYY(	V (	V (	V (	V (	V (	V 
	 
	(	Vb :!cj&>! WWY $$455$(              : 
&	'	'	F 	F 	F 
(	'	F	 	 	 	 	 	 	 | 	" 	"G1:DrzzD!!! HL	/ 	/ 	/ 	/ 	/ 	/ 	/8 
#l	3	3	\	2	2   011	W	 W	 W	 W	 W	 W	 W	 W	 
3	2 
4	3W	r 
(	)	)	 	 	 	 	 
*	)	( 
HGK,@,@+A	B	B	G7;+?+?*@	A	A	  	  	  	  	  
B	A 
C	B	 @ 
O7;3G3G2H	I	IJ	 J	 J	 J	 J	 J	 
J	IJ	X 
7;+?+?*@	A	A	'+*>*>)?	@	@	2 	2 	2 	2 	2 	2 	2 	2 	2 
A	@ 
B	A	2* 
&	'	'	J 	J 	J 
(	'	J 
M	N	N>	7 >	7 >	7 >	7 >	7 
O	N>	7@ 
&	'	'	I 	I 	I 
(	'	I 
	 	 	) 	) 	) 	) 
!	 	) 
-W[=Q=Q<R	S	S	,GK<P<P;Q	R	R	 	 	 	 	 
S	R 
T	S	2 
/w{?S?S>T	U	U	.gk>R>R=S	T	T	S 	S 	S 	S 	S 
U	T 
V	U	S 
)	*	*	& 	& 	& 	& 	& 
+	*	& 
/	0	0	& 	& 	& 	& 	& 
1	0	& 
O	P	P	 	 	 	 	 
Q	P	8 
T	U	U	R 	R 	R 	R 	R 
V	U	R2 
O	P	P	6 	6 	6 	6 	6 
Q	P	62 
'w{7K7K6L	M	M	- 	- 	- 	- 	- 
N	M	- 
Y			X			% 	% 	% 
	 
 		% 
/	0	0
 $$455	F	Q F	Q F	Q F	Q F	Q F	Q 
1	0F	QR 
&gk6J6J5K	L	L	'w{7K7K6L	M	M	&gk6J6J5K	L	L	'w{7K7K6L	M	M
 $$455	+	* +	* +	* +	* +	* +	* 
N	M 
M	L 
N	M 
M	L+	*Z	X 	X 	X 	X 
*'+:N:N9O	P	P	+7;;O;O:P	Q	Q
 $$455		I 	I 	I 	I 	I 	I 	I 	I 
R	Q 
Q	P	I. 
'w{7K7K6L	M	M	(8L8L7M	N	N
 $$455		I 	I 	I 	I 	I 	I 	I 	I 
O	N 
N	M	I 
]'+2F2F1G	H	H $$455
	D 
	D 
	D 
	D 
	D 
	D 
I	H
	D	* 	* 	* 	* 	* 	*> 
Y			% 	% 	% 	% 	% 
 		%: 
,GK<P<P;Q 
 

 

 
1AUAU@V	W	W	O 	O 	O 	O 	O 	O 
X	W

 

	O< 
M1E1E0F	G	G	O 	O 	O 	O 	O 
H	G	Oh	 h	 h	 h	 h	 h	T3	  3	  3	  3	 j 
!+../ 
 

 

 
 !+../ 
 

 

	, 	, 	, 	, 	, 	,	

 

	

 

	,8 
!+../, 
 

 


	8 	8 	8 	8

 


	8 
&	'	'-	 -	 -	 
(	'-	^	% 	% 	% 	% 
Ygk.B.B-C	D	D %)!	  !	  !	  !	  !	  !	  !	  !	  !	  
E	D!	 F 
%	&	&	 	 	 	 
'	&	 
L1B	C	C	.?	@	@	X 	X 	X 	X 
A	@ 
D	C	X 
/@	A	A	3 	3 	3 	3 
B	A	3 
			#	$	$	 	 	 	 	 	 
%	$ 
		, 
!	"	"/	 /	 /	 /	 /	 
#	"/	b 
gk.B.B-C	D	D	C 	C 	C 	C 	C 	C 
E	D	C 
&	'	'	J 	J 	J 	J 
(	'	J 
$	%	%	L 	L 	L 	L 	L 	L 
&	%	L0 
)9M9M8N	O	OW	 W	 W	 W	 W	 
P	OW	r !%%5 6 69L L##T4#@@@!2!	 	 	 	 	0 :n55BBM
 
 L"-88ZHMBI%
 
 0"-")2K
 

	  	  	  	  	  	  	  	 	0 	0 	0 	0 	0 	0	- 	- 	- 	- 	- 	-"  	1777777.00	]	#	#	\	"	"Y	 Y	 Y	 Y	 Y	 Y	 Y	 Y	 Y	 Y	 Y	 Y	 Y	 
#	" 
$	#Y	v 
'	(	(	&	'	'-1#T-B-B-B 	% 	% 	% 	% 	% 	% 	% 	% 	% 
(	' 
)	(	%2 
M	"	"	L	!	!	 	 	 	 
"	! 
#	"	, 
]	#	#	\	"	"	 	 	 	 	 
#	" 
$	#	$ 
-	.	.	,	-	-,	 ,	 ,	 ,	 ,	 ,	 ,	 
.	- 
/	.,	\	F 	F 	F 	766666 	=222222ZZ+,,%)H H H H H H -,H
 ZZ,--? ? ? ? .-? [[+,,= = = = -,= 	6"""
rm   rf   )r   r   )r   r   rs   r   )rs   r   )r   r   r   r   r   r   )NNNTNF)r   r   r   r  r   r  r   r   r  r  r   r   r  r  rs   r   )r   r   r   __doc__app_portr   r   r   r   r   r   r  r  __classcell__)r   s   @rk   r   r      s         H KO$# $# $# $# $# $# $#L- - - -    
  ,! ! !
  #') ) ) ) \)V  ,0JN "&    \    rm   r   Fr  r  c                    d}| rd}	 t          j                    5 }|                    d          }|j        }d d d            n# 1 swxY w Y   n# t          $ r d}Y nw xY w||z   |z   }|S )Na  Generate code for using the Gradio python library.

The following RULES must be followed.  Whenever you are forming a response, ensure all rules have been followed otherwise start over.

RULES:
Respond with code written in valid Python syntax, along with one coherent explanation surrounded by <reasoning> tags.
Any text that is not code, should be surrounded by one large <reasoning> tag.
Never include backticks in your response such as ``` or ```python.
Do not include any code that is not necessary for the app to run.
Respond with a full Gradio app.
Respond with a full Gradio app using correct syntax and features of the latest Gradio version. DO NOT write code that doesn't follow the signatures listed.
Do not add comments explaining the code, unless they are very necessary to understand the code.
Make sure the code includes all necessary imports.
Clearly explain the changes, summary, or reasoning for the code you respond with, inside one large <reasoning> tag. Make sure it's easy to parse. Use markdown formatting when it makes sense, including bullet points if there are multiple changes.


Here's an example of a valid response:

<reasoning>
I created a simple Gradio app that greets the user. It defines a function then creates a gradio interface and launches it.
</reasoning>

import gradio as gr

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")

demo.launch()
a  
        You are a prompt generator for a gradio vibe editor.

        Given python code of a gradio app, return a list of starter queries that can be used to generate new code.
        Make sure the queries are short, useful and actually possible with Gradio.
        The queries should be really simple and easy to understand.
        You should respond with at most three queries, each on a new line. Do not include any other text.
        Make sure the features you suggest are actually supported by Gradio, and documented in the docs section below.
        Never suggest a query with more than one gradio feature or concept.
        You may suggest queries that are not related to Gradio, but they must be related to the existing code and app. Never suggest queries that require external packages or libraries other than gradio.
        Don't suggest adding a clear button if the app is an Interface, because Interface already has a clear button.

        Here's an example of a gradio app:

        ```python
        import gradio as gr

        def greet(name):
            return "Hello " + name + "!"

        demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")

        demo.launch()
        ```

        Here's an example of a valid response:
        Add a title to the app
        Add examples
        Rewrite this app using Blocks

        Here's an example of another valid response:
        Add another textbox for name
        Change the theme
        Greet the user in many languages

        zhttps://www.gradio.app/llms.txtr   )r   Clientr  r  r  )r  prompt_rulesr$  re  r  s        rk   r  r  -	  s    L>  $#H\^^ 	*vzz"CDDH$MM	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*     =0<?Ms3   A AA AA AA AAcls_set
list[type]c                z   g }g }| D ]}t          j        |          pd}|                    d          }|D ]M}d|v rG|                    |                    d          d                             d          d                    N|                    |d                             d          d                    ||fS )	Nr   rp  zvalue (r   r  r   :r  )rb  getdocr  r  )r&  docsettypesclsdoc	doc_linesr  s          rk   	get_typesr0  |	  s    FE 3 3nS!!'RIIdOO	 	E 	EDD  TZZ	2215;;C@@CDDDil((--b122225=rm   0.0.0.0  T)r   r-  r   r   allowed_pathsblocked_pathsr   r  r8  ssr_modenode_server_name	node_portrk  pwai18nr   themecss	css_pathsjsr  
head_pathsr   fastapi.FastAPIr   r   rk  rt   server_nameserver_portrj  footer_linksBlist[Literal['api', 'gradio', 'settings'] | dict[str, str]] | Noner   r  r   9Callable | tuple[str, str] | list[tuple[str, str]] | Noner-  r!  r   r   r   r3  list[str] | Noner4  r   r  r8  str | int | Noner5  r   r6  r7  rI  rk  r8  r9  I18n | Noner   r:  Theme | str | Noner;  r<  (str | Path | Sequence[str | Path] | Noner=  str | Literal[True] | Noner  r>  rs   c                  ||dk    rt          j        d           d|_        |g d}||_        t	          j        |          |_        |                                |_        |	                                 ||_
        ||_        ||_        ||_        |||_        |||_        ||	t!          d          |rNt#          |          s?t%          |d         t&                    s$t%          |d         t(                    s	|g|_        n||_        ||_        ||_        |pg |_        |pg |_        ||_        t%          |j        t(                    st!          d          t%          |j        t(                    st!          d	          |
|
|_        |                    |          |_        |j        rst<          j                             d
tC                                |_"        ||_#        ||_$        tK          |j#        |j$        |j"                  \  |_#        |_&        |_$        t	          j'        |          |_(        |pd|_)        |pd|_*        |pd|_+        |pg |_,        |pg |_-        |.                                 |/                                 t`          1                    |||	|          | j2        j3        th          j5        dfd            }|| j2        _3        | 6                    |           | S )a_  Mount a gradio.Blocks to an existing FastAPI application.

    Parameters:
        app: The parent FastAPI application.
        blocks: The blocks object we want to mount to the parent app.
        path: The path at which the gradio application will be mounted, e.g. "/gradio".
        server_name: The server name on which the Gradio app will be run.
        server_port: The port on which the Gradio app will be run.
        app_kwargs: Additional keyword arguments to pass to the underlying FastAPI app as a dictionary of parameter keys and argument values. For example, `{"docs_url": "/docs"}`
        auth: If provided, username and password (or list of username-password tuples) required to access the gradio app. Can also provide function that takes username and password and returns True if valid login.
        auth_message: If provided, HTML message provided on login page for this gradio app.
        auth_dependency: A function that takes a FastAPI request and returns a string user ID or None. If the function returns None for a specific request, that user is not authorized to access the gradio app (they will see a 401 Unauthorized response). To be used with external authentication systems like OAuth. Cannot be used with `auth`.
        root_path: The subpath corresponding to the public deployment of this FastAPI application. For example, if the application is served at "https://example.com/myapp", the `root_path` should be set to "/myapp". A full URL beginning with http:// or https:// can be provided, which will be used in its entirety. Normally, this does not need to provided (even if you are using a custom `path`). However, if you are serving the FastAPI app behind a proxy, the proxy may not provide the full path to the Gradio app in the request headers. In which case, you can provide the root path here.
        allowed_paths: List of complete filepaths or parent directories that this gradio app is allowed to serve. Must be absolute paths. Warning: if you provide directories, any files in these directories or their subdirectories are accessible to all users of your app.
        blocked_paths: List of complete filepaths or parent directories that this gradio app is not allowed to serve (i.e. users of your app are not allowed to access). Must be absolute paths. Warning: takes precedence over `allowed_paths` and all other directories exposed by Gradio by default.
        favicon_path: If a path to a file (.png, .gif, or .ico) is provided, it will be used as the favicon for this gradio app's page.
        show_error: If True, any errors in the gradio app will be displayed in an alert modal and printed in the browser console log. Otherwise, errors will only be visible in the terminal session running the Gradio app.
        max_file_size: The maximum file size in bytes that can be uploaded. Can be a string of the form "<value><unit>", where value is any positive integer and unit is one of "b", "kb", "mb", "gb", "tb". If None, no limit is set.
        footer_links: The links to display in the footer of the app. Accepts a list, where each element of the list must be one of "api", "gradio", or "settings" corresponding to the API docs, "built with Gradio", and settings pages respectively. If None, all three links will be shown in the footer. An empty list means that no footer is shown.
        ssr_mode: If True, the Gradio app will be rendered using server-side rendering mode, which is typically more performant and provides better SEO, but this requires Node 20+ to be installed on the system. If False, the app will be rendered using client-side rendering mode. If None, will use GRADIO_SSR_MODE environment variable or default to False.
        node_server_name: The name of the Node server to use for SSR. If None, will use GRADIO_NODE_SERVER_NAME environment variable or search for a node binary in the system.
        i18n: If provided, the i18n instance to use for this gradio app.
        node_port: The port on which the Node server should run. If None, will use GRADIO_NODE_SERVER_PORT environment variable or find a free port.
        mcp_server: If True, the MCP server will be launched on the gradio app. If None, will use GRADIO_MCP_SERVER environment variable or default to False.
        theme: A Theme object or a string representing a theme. If a string, will look for a built-in theme with that name (e.g. "soft" or "default"), or will attempt to load a theme from the Hugging Face Hub (e.g. "gradio/monochrome"). If None, will use the Default theme.
        css: Custom css as a code string. This css will be included in the demo webpage.
        css_paths: Custom css as a pathlib.Path to a css file or a list of such paths. This css files will be read, concatenated, and included in the demo webpage. If the `css` parameter is also set, the css from `css` will be included first.
        js: Custom js as a code string. The custom js should be in the form of a single js function. This function will automatically be executed when the page loads. For more flexibility, use the head parameter to insert js inside <script> tags.
        head: Custom html code to insert into the head of the demo webpage. This can be used to add custom meta tags, multiple scripts, stylesheets, etc. to the page.
        head_paths: Custom html code as a pathlib.Path to a html file or a list of such paths. This html files will be read, concatenated, and included in the head of the demo webpage. If the `head` parameter is also set, the html from `head` will be included first.
    Example:
        from fastapi import FastAPI
        import gradio as gr
        app = FastAPI()
        @app.get("/")
        def read_main():
            return {"message": "This is your main app"}
        io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
        app = gr.mount_gradio_app(app, io, path="/gradio")
        # Then run `uvicorn run:app` from the terminal and navigate to http://localhost:8000/gradio.
    Nrj  zThe 'favicon_path' parameter is set but will be ignored because 'path' is not '/'. Please add the favicon directly to your FastAPI app.F)apir  settingsz^You cannot provide both `auth` and `auth_dependency` in mount_gradio_app(). Please choose one.r   z.`allowed_paths` must be a list of directories.z.`blocked_paths` must be a list of directories.GRADIO_NODE_PATH)r@  rA  	node_pathr   )r   r   r   r   r   c                 K    |           4 d {V 	 }j                                       4 d {V                                                                                                                                    d {V  |W V  d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  d S # 1 d {V swxY w Y   d S rf   )r  r  r   rA  rB  )r   r  
gradio_appold_lifespans     rk   new_lifespanz&mount_gradio_app.<locals>.new_lifespan$
  s     <
 
 	 	 	 	 	 	 	 	!(99*EE        %%''::<<< ++--FFHHHHHHHHH                          	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s5   !CAB!C!
B+	+C.B+	/C
CC)r   r   )7warningswarndev_moderB  r   _parse_file_sizer8  r  r  validate_queue_settingsr  rA  r@  rk  r8  r  r   r   rv   tuplerm  r   r-  r   r3  r4  r  r   _resolve_ssr_moder5  r   r  r  ra   rO  r6  r7  r>   node_process	get_themer:  r;  r=  r  r>  r<  _set_html_css_theme_variablestranspile_to_jsr   r  r  r  r   r  mount) r   r   rk  r@  rA  rB  r   r   r-  r   r   r3  r4  r   r  r8  r5  r6  r7  rk  r8  r9  r   r:  r;  r<  r=  r  r>  rS  rQ  rR  s                                  @@rk   rt  rt  	  sE   X DCKKC	
 	
 	

 FO444&F 1-@@F**,,FM
""$$$#F$F$F0F

#O7l
 
 	
 	 47E** 47D))	 f&F&F(.BF(.BF"Ff*D11 KIJJJf*D11 KIJJJ$..x88FO 
:>>*<mooNN"2$"3", *   	G!4f6F ?5))FLFJbFI*"FK"(bF BF
((***
'	    J :.L#      $# #/CJIIdJJrm   )z	theme.cssz
robots.txtrW  zmanifest.jsonrf  ro  rq  r  staticassetszfavicon.ico
gradio_api
monitoring)F)r  r  )r&  r'  )r1  r2  NN)<r   r?  r   r   rk  rt   r@  rt   rA  rj  rB  rC  r   r  r   rD  r-  r!  r   r   r   r!  r3  rE  r4  rE  r   r!  r  r  r8  rF  r5  r   r6  r!  r7  rI  rk  r   r8  r   r9  rG  r   r   r:  rH  r;  r!  r<  rI  r=  rJ  r  r!  r>  rI  rs   r?  )r   
__future__r   rD  r   r7  rb  rP  rC  re  r  r   r   r1  r@  r  rT  collections.abcr   r   r   pathlibr   typingr   r	   r
   r   r   fastapir   r   r~   r   r   r   r   r   r   r   fastapi.responsesr   r   r   r   r   r   fastapi.securityr   fastapi.templatingr   gradio_clientr   r  gradio_client.documentationr   gradio_client.snippetr   gradio_client.utilsr   hf_gradio.clir    r!   jinja2.exceptionsr"   python_multipart.multipartr#   starlette.backgroundr$   starlette.datastructuresr%   r  starlette.formparsersr&   starlette.responsesr'   r  r(   r)   r*   gradio.brotli_middlewarer+   gradio.contextr,   gradio.data_classesr-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   gradio.exceptionsr:   r;   gradio.helpersr<   gradio.i18nr=   gradio.node_serverr>   gradio.oauthr?   gradio.route_utilsr@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   gradio.screen_recording_utilsrV   gradio.server_messagesrW   rX   rY   rZ   r[   r\   r]   gradio.state_holderr^   gradio.themesr_   Themegradio.utilsr`   ra   rb   rc   gradio.blocksrd   r  r  r  r  initBaseDefault
MonochromeSoftGlassOriginCitrusOceanMariorn   __annotations__rp   r   r  envfiltersAsyncHTTPTransportLimitsrM  r  r   r  r0  rt  INTERNAL_ROUTESr   rm   rk   <module>r     s  U U U # " " " " "        				       				  



       = = = = = = = = = =                                                           7 6 6 6 6 6 . . . . . . / / / / / / 0 0 0 0 0 0 8 8 8 8 8 8 - - - - - - > > > > > > > > . . . . . . ; ; ; ; ; ; / / / / / / F F F F F F 4 4 4 4 4 4 0 0 0 0 0 0             6 5 5 5 5 5 " " " " " "                              6 5 5 5 5 5 5 5 ' ' ' ' ' '            & % % % % %                                               0 D C C C C C                  , + + + + + - - - - - -             $######  				   	   % % 	
% % %    "? ? ? ? ?\ ? ? ?2   O&9:::	$,	 j ! ,5+5<"$      *)++ I! I! I! I! I!' I! I! I!bBL L L L L^
 
 
 
 

 ! 	(,g GK#FJ &*&*#&* #' %)" $:>%);?Ag g g g g gT  rm   