o
    :Hh                     @   s  d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z	 d dlmZ d dlmZmZ d dlZd dlZd d	lmZ d d
lmZ edefddZeedZdgZejeeddgdgd ejddddd Zee	 dd Zee_edkrd dlZej edddd dS dS )    )FastAPIHTTPException)CORSMiddleware)asynccontextmanager)database)router)get_openapi)logger	client_idN)	TokenData)datetimeappc                 C  s8   t  I d H  td d V  t  I d H  td d S )Nstartend)r   connectprint
disconnect)r    r   )/home/air/sanwanet/gpt-api-backup/main.pylifespan   s   r   )r   *T)allow_originsallow_credentialsallow_methodsallow_headers/F)include_in_schemac                      s   dS )NTr   r   r   r   r   index*   s   r   c                  C   s*   t jrt jS tdddt jd} | t _t jS )NzAIR API with chatgptz1.0.0zy
        Speech To Text Websocket Endpoint : /ws?token=
        Send to voice stream data
        Receive a text
        )titleversiondescriptionroutes)r   openapi_schemar   r!   )r"   r   r   r   custom_openapi0   s   
r#   __main__z0.0.0.0i  debug)hostport	log_level)!fastapir   r   fastapi.middleware.corsr   
contextlibr   dbr   chatbot_router4r   fastapi.openapi.utilsr   configr	   r
   requests	db_moduleschemasr   r   r   r   originsadd_middlewaregetr   include_routerr#   openapi__name__uvicornrunr   r   r   r   <module>   s>    


