
    g	                         d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZmZ er	ddlmZ eZneZ G d d	e	      Zy
)a  
*New config* for using aiohttp to make the request to the custom OpenAI-like provider

This leads to 10x higher RPS than httpx
https://github.com/BerriAI/litellm/issues/6592

New config to ensure we introduce this without causing breaking changes for users
    )TYPE_CHECKINGAnyListOptional)ClientResponse)OpenAILikeChatConfig)AllMessageValues)ChoicesModelResponse)Loggingc                       e Zd Z	 ddedededee   def
dZ	 	 ddeded	ee	   ded
ee   dee   defdZ
	 	 ddededededed	ee	   dededed
ee   dee   defdZy)AiohttpOpenAIChatConfigNapi_basemodeloptional_paramsstreamreturnc                 2    |j                  d      s|dz  }|S )zI
        Ensure - /v1/chat/completions is at the end of the url

        z/chat/completions)endswith)selfr   r   r   r   s        d/var/www/openai/venv/lib/python3.12/site-packages/litellm/llms/aiohttp_openai/chat/transformation.pyget_complete_urlz(AiohttpOpenAIChatConfig.get_complete_url   s#       !45++H    headersmessagesapi_keyc                     dd| iS )NAuthorizationzBearer  )r   r   r   r   r   r   r   s          r   validate_environmentz,AiohttpOpenAIChatConfig.validate_environment+   s      77)!455r   raw_responsemodel_responselogging_objrequest_datalitellm_paramsencoding	json_modec                   K   |j                          d {   }|j                  d      |_        |j                  d      D cg c]  }t        di | c}|_        |j                  d      |_        |j                  d      |_        |j                  d      |_        |j                  d      |_        |S 7 c c}w w)Nidchoicescreatedr   objectsystem_fingerprintr   )	jsongetr)   r
   r*   r+   r   r,   r-   )r   r   r!   r"   r#   r$   r   r   r%   r&   r   r'   _json_responsechoices                 r   transform_responsez*AiohttpOpenAIChatConfig.transform_response6   s       ,0022*..t4,:,>,>y,I"
,I&Gf,I"
 "0!3!3I!>-11': . 2 28 <,:,>,>?S,T) 3"
s"   B?B8-B?B:A#B?:B?)N)NN)__name__
__module____qualname__strdictr   boolr   r   r	   r    r   r   LiteLLMLoggingObjr   r2   r   r   r   r   r      s0    "&  	
  
, "&"&	6	6 	6 '(		6
 	6 #	6 3-	6 
	6, "&$( % &	
 '  '(    # D> 
r   r   N)__doc__typingr   r   r   r   aiohttpr   ,litellm.llms.openai_like.chat.transformationr   litellm.types.llms.openair	   litellm.types.utilsr
   r   *litellm.litellm_core_utils.litellm_loggingr   _LiteLLMLoggingObjr9   r   r   r   r   <module>rB      s=    6 5 " M 6 6X*32 3r   