U
    ^	f                     @   s   d dl Z d dlmZmZ d dlmZ d dlmZ d dlm	Z	 e Z
e  e
jedgddgdgd	 e	e jd
dZe
dedddZedkrd dlZeje
ddddd dS )    N)FastAPIHTTPException)CORSMiddleware)load_dotenv)Groq*TPOST)Zallow_originsZallow_credentialsZallow_methodsZallow_headersZGROQ_API_KEY)Zapi_keyz/v1/chat/completions/)payloadc           	   
   C   s   zd|  d}|  d}|  dd}|  dd}|  dd}|  d	d
}tjjj||||||d}|W S  tk
r } ztdt|dW 5 d }~X Y nX d S )Nmessagesmodeltemperatureg      ?
max_tokensi   top_p   streamF)r
   r   r   r   r   r   i  )status_codeZdetail)getclientZchatZcompletionsZcreate	Exceptionr   str)	r	   r
   r   r   r   r   r   resulte r   "/var/www/html/apigroqsegura/app.pychat_completions   s$    


r   __main__z0.0.0.0i  z1/etc/letsencrypt/live/radargps.com.ar/privkey.pemz3/etc/letsencrypt/live/radargps.com.ar/fullchain.pem)hostportssl_keyfilessl_certfile)osZfastapir   r   Zfastapi.middleware.corsr   dotenvr   Zgroqr   appZadd_middlewareenvironr   r   Zpostdictr   __name__uvicornrunr   r   r   r   <module>   s2   	