o
    b"\i                     @  sF   d Z ddlmZ ddlZddlmZmZmZmZ dZ	G dd dZ
dS )zpMinimal OpenAI client using httpx.

We intentionally avoid adding a hard dependency on the official OpenAI SDK.
    )annotationsN)AnyDictListOptionalz*https://api.openai.com/v1/chat/completionsc                   @  s$   e Zd Zdddd	ZddddZdS )OpenAIClientgpt-4o-mini      N@api_keystrmodeltimeoutfloatc                 C  s"   |st d|| _|| _|| _d S )NzOpenAI API key is required)
ValueErrorr
   r   r   )selfr
   r   r    r   T/var/www/www-root/data/www/176.119.141.140/sports-predictor/app/llm/openai_client.py__init__   s
   
zOpenAIClient.__init__ffffff?  messagesList[Dict[str, str]]temperature
max_tokensintreturnc           	      C  s   d| j  dd}| j|||d}tj| jd}|jt||d}|  | }W d    n1 s3w   Y  |d d d	 d
 S )NzBearer zapplication/json)AuthorizationzContent-Type)r   r   r   r   )r   )headersjsonchoicesr   messagecontent)	r
   r   httpxClientr   postOPENAI_CHAT_URLraise_for_statusr   )	r   r   r   r   r   payloadclientrdatar   r   r   chat   s   

zOpenAIClient.chatN)r   r	   )r
   r   r   r   r   r   )r   r   )r   r   r   r   r   r   r   r   )__name__
__module____qualname__r   r+   r   r   r   r   r      s    r   )__doc__
__future__r   r"   typingr   r   r   r   r%   r   r   r   r   r   <module>   s    