
    jd	                        d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	m
Z
mZmZmZmZmZmZ d dlmZ d dlmZmZmZ d dlmZ  e              ee          Z edd	
          Ze                    d           e                    e            eed           e                    eej        ddgdg           e                    e           dede fd            Z!e                    e"          dede"fd            Z#e                    e$          dede$fd            Z%e&                    ej'        ddg           e&                    e
j'        ddg           e&                    ej'        ddg           e&                    ej'        ddg           e&                    ej'        ddg           e&                    e	j'        d d!g           e&                    ej'        d"d#g           e&                    ej'        d$d%g           e&                    ej'        d&g'           e(                    d(          d)             Z)e(                    d*          d+             Z*d,S )-    )FastAPIRequest)CORSMiddleware)JSONResponse)	datasets	dpo_tasksexperts	sft_taskstasks	templatestoolstraining_platforms	websocket)settings)LoggingMiddleware
get_loggersetup_logging)setup_metricsExpert Training Service1.0.0)titleversionz'Starting Expert Training Service v1.0.0ztraining-centerT*)allow_originsallow_credentialsallow_methodsallow_headersrequestexcc                    K   t                               d|            t          ddt          |          i          S )NzValidation error: i  detailstatus_codecontent)loggerwarningr   strr   r   s     :/lsinfo/ai/hellotax_ai/training_center/backend/app/main.pyvalue_error_handlerr*      s?      
NN---...C(CHH1EFFFF    c                 F   K   t          ddt          |          i          S )Ni  r!   r"   )r   r'   r(   s     r)   permission_error_handlerr-   !   s$      C(CHH1EFFFFr+   c                 f   K   t                               d|            t          dddi          S )NzUnhandled error: i  r!   zInternal server errorr"   )r%   	exceptionr   r(   s     r)   general_exception_handlerr0   %   s<      
...///C(<S1TUUUUr+   z/api/v1/tasksr   )prefixtagsz/api/v1/expertsr	   z/api/v1/datasetsr   z/api/v1/toolsr   z/api/v1/sft-tasksr
   z/api/v1/dpo-tasksr   z/api/v1/templatesr   z/api/v1/training-platformsr   r   )r2   /c                     K   ddddS )Nr   r   running)servicer   status r8   r+   r)   rootr9   3   s      0WyYYYr+   z/healthc                     K   ddiS )Nr7   healthyr8   r8   r+   r)   health_checkr<   7   s      i  r+   N)+fastapir   r   fastapi.middleware.corsr   fastapi.responsesr   
app.api.v1r   r   r	   r
   r   r   r   r   r   app.core.configr   common_loggingr   r   r   common_metricsr   __name__r%   appinfoadd_middlewareCORS_ORIGINSexception_handler
ValueErrorr*   PermissionErrorr-   	Exceptionr0   include_routerroutergetr9   r<   r8   r+   r)   <module>rP      s   $ $ $ $ $ $ $ $ 2 2 2 2 2 2 * * * * * *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 % $ $ $ $ $ G G G G G G G G G G ( ( ( ( ( ( 	H		g-w??? 5 6 6 6   $ % % % c$ % % %   >1FZ^orns  EH  DI   J  J  Jz""Gw GZ G G G #"G ''GG G/ G G G ('G y!!VW V9 V V V "!V   5<wi  H H H   7>*;9+  N N N   8?+=ZL  Q Q Q   5<wi  H H H   9#,?{m  T T T   9#,?{m  T T T   9#,?{m  T T T   %,5QYmXn  o o o   9#;-  8 8 8Z Z Z ! ! ! ! !r+   