
    ^h                         S SK r S SKJrJrJrJrJr  S SKrS SKrS SK	J
r
Jr  S SKJr  S SKJrJr  S SKJr  SSKJr   " S	 S
\5      rg)    N)Any	CoroutineDictOptionalUnion)_get_httpx_clientget_async_httpx_client)	VertexLLM)BatchCreateBatchRequest)VertexAIBatchPredictionJob   )VertexAIBatchTransformationc                      ^  \ rS rSrS\4U 4S jjrS\S\S\\   S\\   S\\   S	\\   S
\	\
\R                  4   S\\   S\	\\\\\4   4   4S jrS\S\S\\\4   S\4S jrS	\S\S\4S jrSrU =r$ )VertexAIBatchPrediction   gcs_bucket_namec                 2   > [         TU ]  " U0 UD6  Xl        g )N)super__init__r   )selfr   argskwargs	__class__s       `/home/james-whalen/.local/lib/python3.13/site-packages/litellm/llms/vertex_ai/batches/handler.pyr    VertexAIBatchPrediction.__init__   s    $)&).    	_is_asynccreate_batch_dataapi_basevertex_credentialsvertex_projectvertex_locationtimeoutmax_retriesreturnc	           
      |   [        5       n	U R                  UUSS9u  pU R                  U=(       d    SU=(       d    US9n[        UR	                  S5      5      S:  a  UR	                  S5      S   nOSnU R                  USS US S US	9u  pS
SU
 3S.n[        R                  " US9nUSL a  U R                  UUUS9$ U	R                  UU[        R                  " U5      S9nUR                  S:w  a%  [        SUR                   SUR                   35      eUR                  5       n[        R                  " US9nU$ )N	vertex_ai)credentials
project_idcustom_llm_providerzus-central1)r#   r"   :r    )r    r+   gemini_api_keyendpointstreamauth_headerurlzapplication/json; charset=utf-8zBearer )zContent-TypeAuthorization)requestT)vertex_batch_requestr    headersr3   r7   data   Error:  response)r   _ensure_access_tokencreate_vertex_urllensplit_check_custom_proxyr   9transform_openai_batch_request_to_vertex_ai_batch_request_async_create_batchpostjsondumpsstatus_code	Exceptiontext;transform_vertex_ai_batch_response_to_openai_batch_response)r   r   r   r    r!   r"   r#   r$   r%   sync_handleraccess_tokenr*   default_api_baser0   _r7   r6   r>   _json_responsevertex_batch_responses                       r   create_batch$VertexAIBatchPrediction.create_batch   s    )*#'#<#<*% + $= $
   11+<})7Z 2 

 %%c*+a/'--c226HH.. +  / 
 >&|n5
 (aa) 	 ++%9! ,    $$01 % 
 3&gh&:&:%;1X]]OLMM! ; w w#!
 %$r   r6   r7   c                 `  #    [        [        R                  R                  S9nUR	                  UU[
        R                  " U5      S9I S h  vN nUR                  S:w  a%  [        SUR                   SUR                   35      eUR                  5       n[        R                  " US9nU$  N_7f)N)llm_providerr8   r:   r;   r<   r=   )r	   litellmLlmProviders	VERTEX_AIrF   rG   rH   rI   rJ   rK   r   rL   )r   r6   r    r7   clientr>   rQ   rR   s           r   rE   +VertexAIBatchPrediction._async_create_batch`   s      ( --77
  01 % 
 

 3&gh&:&:%;1X]]OLMM! ; w w#!
 %$
s   A
B.B,A B.c                     SU SU SU S3$ )z0Return the base url for the vertex garden modelszhttps://z'-aiplatform.googleapis.com/v1/projects/z/locations/z/batchPredictionJobs )r   r#   r"   s      r   r@   )VertexAIBatchPrediction.create_vertex_urlw   s1     /**QR`Qaalm|l}  ~R  S  	Sr   )r   )__name__
__module____qualname____firstlineno__strr   boolr   r   r   floathttpxTimeoutintr   r   r   rS   r   r   rE   r@   __static_attributes____classcell__)r   s   @r   r   r      s   / /G%G% .G% 3-	G%
 %SMG% !G% "#G% uemm+,G% c]G% 
uiS%00	1G%R%8% % c3h	%
 
%.SS S 
	S Sr   r   )rG   typingr   r   r   r   r   rf   rW   &litellm.llms.custom_httpx.http_handlerr   r	   @litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_geminir
   litellm.types.llms.openair   r   litellm.types.llms.vertex_air   transformationr   r   r]   r   r   <module>rq      s8     8 8   W ? C 7lSi lSr   