
    hI
                     ~    d dl Z d dlmZmZmZmZmZmZ d dlm	Z	 d dl
mZ d dlmZ er	d dlmZ eZneZ G d d      Zy)	    N)TYPE_CHECKINGAnyDictListOptionalcast)Response)AllMessageValues)ModelResponse)Loggingc                   b    e Zd Z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)AnthropicBatchesConfigc                 (    ddl m}  |       | _        y )N   )AnthropicConfig)chat.transformationr   anthropic_chat_config)selfr   s     i/var/www/Befach/backend/env/lib/python3.12/site-packages/litellm/llms/anthropic/batches/transformation.py__init__zAnthropicBatchesConfig.__init__   s    9%4%6"    Nmodelraw_responsemodel_responselogging_objrequest_datamessagesoptional_paramslitellm_paramsencodingapi_key	json_modereturnc                    ddl m} ddlm} |j                  j                         }g }	 |j                  d      }|D ]{  }|j                         }|s	 t        j                  |      }|d   d   }| j                  j                  |||      }t        |dd       }|r|j                  t        ||             } |j                  |      }t!        |d|       |S # t        j                  $ r Y w xY w# t"        $ r}|d }~ww xY w)	Nr   )BaseTokenUsageProcessor)Usage
resultmessage)completion_responser   r   usage)litellm.cost_calculatorr%   litellm.types.utilsr&   textstripsplitjsonloadsr   transform_parsed_responsegetattrappendr   JSONDecodeErrorcombine_usage_objectssetattr	Exception)r   r   r   r   r   r   r   r   r   r    r!   r"   r%   r&   response_text	all_usagelineslineresponse_jsonr*   transformed_responsetransformed_response_usagecombined_usagees                           r   transform_responsez)AnthropicBatchesConfig.transform_response   s#    	D-$))//1!#	!	!''-Ezz|$(JJt$4M*7*A)*L'22LL0C)5+9 M  ) 29,gt2. 2!((e5O)PQ) 2 5JJ9UNNG^<!! ++   	G	s<   )C4 A%C9!C4 C1.C4 0C11C4 4	D=C??D)NN)__name__
__module____qualname__r   strr	   r   LoggingClassr   r   r
   dictr   r   boolrC    r   r   r   r      s    7  "&$(55 5 &	5
 "5 5 '(5 5 5 5 #5 D>5 
5r   r   )r1   typingr   r   r   r   r   r   httpxr	   litellm.types.llms.openair
   r-   r   *litellm.litellm_core_utils.litellm_loggingr   LiteLLMLoggingObjrH   r   rK   r   r   <module>rQ      s1     A A  6 -W$LL; ;r   