
    g                         d dl Z d dlmZmZmZmZmZ d dl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mZ er	d d	lmZ eZneZ G d
 de      Zy)    N)TYPE_CHECKINGAnyListOptionalUnion)BaseLLMException)OpenAIGPTConfig)AllMessageValues)ModelResponseUsage   OobaboogaError)Loggingc                       e Zd Z	 ddededeeeej                  f      de
fdZ	 	 ddedej                  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	 	 ddededee   dedee   dee   defdZy)OobaboogaConfigNerror_messagestatus_codeheadersreturnc                     t        |||      S )N)r   messager   r   )selfr   r   r   s       _/var/www/openai/venv/lib/python3.12/site-packages/litellm/llms/oobabooga/chat/transformation.pyget_error_classzOobaboogaConfig.get_error_class   s     #]G
 	
    modelraw_responsemodel_responselogging_objrequest_datamessagesoptional_paramslitellm_paramsencodingapi_key	json_modec                 f   |j                  ||
|j                  d|i       	 |j                         }d|v rt	        |d   |j
                        	 |d   d   d   d   |j                  d   j                  _        t        t        j                               |_        ||_        t        |d	   d
   |d	   d   |d	   d         }t        |d	|       |S # t        $ r" t	        |j                  |j
                        w xY w# t        $ r%}t	        t        |      |j
                        d }~ww xY w)Ncomplete_input_dict)inputr&   original_responseadditional_args)r   r   errorchoicesr   r   contentusageprompt_tokenscompletion_tokenstotal_tokens)r1   r2   r3   )	post_calltextjson	Exceptionr   r   r.   r   r/   strinttimecreatedr   r   setattr)r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   completion_responseer0   s                  r   transform_responsez"OobaboogaConfig.transform_response    sa    	*//2LA	 	 	
	"."3"3"5
 )) +G4(44 
<OPY<Z[\<]^g<hir<s&&q)119 "%TYY[!1$-g6G1':;NO,W5nE

 	/5  	 $))|7O7O 	  $F , 8 8 s#   C *D +C?	D0 D++D0api_basec                 $    ddd}|d| |d<   |S )Nzapplication/json)acceptzcontent-typezToken Authorization )r   r   r   r"   r#   r&   r@   s          r   validate_environmentz$OobaboogaConfig.validate_environmentU   s/     ).
 )/y'9GO$r   )N)NN)__name__
__module____qualname__r8   r9   r   r   dicthttpxHeadersr   r   Responser   LoggingClassr   r
   r   boolr?   rE   rD   r   r   r   r      s:   
 9=	

 
 %emm 345	

 

* "&$(33 nn3 &	3
 "3 3 '(3 3 3 3 #3 D>3 
3v "&"&  '(	
  # 3- 
r   r   )r:   typingr   r   r   r   r   rJ   )litellm.llms.base_llm.chat.transformationr   +litellm.llms.openai.chat.gpt_transformationr	   litellm.types.llms.openair
   litellm.types.utilsr   r   common_utilsr   *litellm.litellm_core_utils.litellm_loggingr   LiteLLMLoggingObjrM   r   rD   r   r   <module>rW      s>     < <  F G 6 4 )W$LLOo Or   