o
    pkjr                    @   s  d dl Z d dlZd dl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 ddlmZ dd	lmZ dd
l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dZ	ddeeeef ef deeeef  deeef fddZ	ddeeeef ef deeeef  deeef fddZ 	ddeeeef ef deeeef  deeef fddZ!	ddeeeef ef deeeef  deeef fddZ"	ddeeeef ef deeeef  deeef fddZ#	ddedeeeef ef deeeef  deeef fddZ$	ddeeeef ef deeeef  deeef fd d!Z%	ddeeeef ef deeeef  deeef fd"d#Z&	ddeeeef ef deeeef  deeef fd$d%Z'	ddeeeef ef deeeef  deeef fd&d'Z(	ddedeeeef ef deeeef  deeef fd(d)Z)	ddedeeeef ef deeeef  deeef fd*d+Z*	ddeeeef ef deeeef  deeef fd,d-Z+	ddeeeef ef deeeef  deeef fd.d/Z,	ddeeeef ef deeeef  deeef fd0d1Z-	ddeeeef ef deeeef  deeef fd2d3Z.	ddeeeef ef deeeef  deeef fd4d5Z/	ddedeeeef ef deeeef  deeef fd6d7Z0	ddedeeeef ef deeeef  deeef fd8d9Z1	ddeeeef ef deeeef  deeef fd:d;Z2	ddedeeeef ef deeeef  deeef fd<d=Z3	ddedeeeef ef deeeef  deeef fd>d?Z4	ddedeeeef ef deeeef  deeef fd@dAZ5	ddeeeef ef deeeef  deeef fdBdCZ6	ddeeeef ef deeeef  deeef fdDdEZ7	ddedeeeef ef deeeef  deeef fdFdGZ8	ddeeeef ef deeeef  deeef fdHdIZ9	ddedeeeef ef deeeef  deeef fdJdKZ:	ddeeeef ef deeeef  deeef fdLdMZ;	ddeeeef ef deeeef  deeef fdNdOZ<	ddeeeef ef deeeef  deeef fdPdQZ=	ddedeeeef ef deeeef  deeef fdRdSZ>	ddeeeef ef deeeef  deeef fdTdUZ?	ddedeeeef ef deeeef  deeef fdVdWZ@	ddedeeeef ef deeeef  deeef fdXdYZA	ddeeeef ef deeeef  deeef fdZd[ZB	ddeeeef ef deeeef  deeef fd\d]ZC	ddeeeef ef deeeef  deeef fd^d_ZD	ddedeeeef ef deeeef  deeef fd`daZE	ddeeeef ef deeeef  deeef fdbdcZF	ddeeeef ef deeeef  deeef fdddeZG	ddeeeef ef deeeef  deeef fdfdgZH	ddeeeef ef deeeef  deeef fdhdiZI	ddeeeef ef deeeef  deeef fdjdkZJ	ddeeeef ef deeeef  deeef fdldmZK	ddeeeef ef deeeef  deeef fdndoZL	ddeeeef ef deeeef  deeef fdpdqZM	ddeeeef ef deeeef  deeef fdrdsZN	ddeeeef ef deeeef  deeef fdtduZO	ddeeeef ef deeeef  deeef fdvdwZP	ddeeeef ef deeeef  deeef fdxdyZQ	ddeeeef ef deeeef  deeef fdzd{ZRG d|d} d}e	jSZTG d~d de	jSZUdS )    N)AnyOptionalUnion)	urlencode   )_api_module)_common)_extra_utils)_transformers)types)BaseApiClient)get_value_by_path)move_value_by_path)set_value_by_path)
AsyncPagerPagerzgoogle_genai.batchesfrom_objectparent_objectreturnc                 C   s   i }t | dgd urt|dgt | dg t | dgd ur!tdt | dgd ur-tdt | dgd ur9tdt | d	gd urEtd
t | dgd urQtdt | dgd ur]td|S )Napi_keyapiKeyapi_key_configzvapi_key_config parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.	auth_typezqauth_type parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.google_service_account_configzgoogle_service_account_config parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.http_basic_auth_configz~http_basic_auth_config parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.oauth_configztoauth_config parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.oidc_configzsoidc_config parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.getvsetv
ValueErrorr   r   	to_object r#   R/home/djax/ivt_ai_plugin/venv/lib/python3.10/site-packages/google/genai/batches.py_AuthConfig_to_mldev%   s8   r%   c                    s   i  t | dgd urt dgt | dg t | ddgd ur1t dg fddt | ddgD  t | ddgd urKt dgd	d t | ddgD   S )
NresponsesFile	file_nameinlinedResponsesinlined_responsesc                       g | ]}t | qS r#   )_InlinedResponse_from_mldev.0itemr"   r#   r$   
<listcomp>a       z3_BatchJobDestination_from_mldev.<locals>.<listcomp>inlinedEmbedContentResponsesinlined_embed_content_responsesc                 S      g | ]}|qS r#   r#   r,   r#   r#   r$   r0   p       r   r   r   r   r#   r/   r$   _BatchJobDestination_from_mldevT   s6   
r8   c                 C   s   i }t | dgd urt|dgt | dg t | ddgd ur*t|dgt | ddg t | ddgd ur?t|dgt | ddg t | d	gd urUt|d
gtt | d	g| |S )NpredictionsFormatformatgcsDestinationoutputUriPrefixgcs_uribigqueryDestination	outputUribigquery_uri"vertexMultimodalDatasetDestinationvertex_dataset)r   r   /_VertexMultimodalDatasetDestination_from_vertexr!   r#   r#   r$    _BatchJobDestination_from_vertex|   s0   rD   c                 C   s   i }t | dgd urt|dgt | dg t | dgd ur)t|ddgt | dg t | dgd ur=t|ddgt | dg t | d	gd urItd
t | dgd urUtdt | dgd uratdt | dgd urwt|dgtt | dg| |S )Nr:   r9   r=   r;   r<   r@   r>   r?   r'   qfile_name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.r)   zyinlined_responses parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.r3   zinlined_embed_content_responses parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.rB   rA   )r   r   r    -_VertexMultimodalDatasetDestination_to_vertexr!   r#   r#   r$   _BatchJobDestination_to_vertex   sH   

rG   c                 C   s   i }t | dgd urt|dgt | dg t | ddgd ur*t|dgt | ddg t | ddgd ur?t|dgt | ddg t | d	d
gd urTt|dgt | d	d
g |S )NinstancesFormatr:   	gcsSourceurisr=   bigquerySourceinputUrir@   vertexMultimodalDatasetSourcedatasetNamevertex_dataset_namer6   r!   r#   r#   r$   _BatchJobSource_from_vertex   s(   rP   
api_clientc                    s   i t |dgd urtdt |dgd urtdt |dgd ur&tdt |dgd ur9tdgt |dg t |d	gd urUtd
d
g fddt |d	gD  t |dgd uratdS )Nr:   znformat parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.r=   zogcs_uri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.r@   ztbigquery_uri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.r'   fileNameinlined_requestsrequestsc                    s   g | ]}t  |qS r#   )_InlinedRequest_to_mldevr,   rQ   r"   r#   r$   r0     s    
z,_BatchJobSource_to_mldev.<locals>.<listcomp>rO   z{vertex_dataset_name parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.r   r    r   rQ   r   r   r#   rV   r$   _BatchJobSource_to_mldev   s8   
	rY   c                 C   s   i }t | dgd urt|dgt | dg t | dgd ur)t|ddgt | dg t | dgd ur=t|ddgt | dg t | d	gd urItd
t | dgd urUtdt | dgd urit|ddgt | dg |S )Nr:   rH   r=   rI   rJ   r@   rK   rL   r'   rE   rS   zxinlined_requests parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.rO   rM   rN   r   r!   r#   r#   r$   _BatchJobSource_to_vertex  s4   

rZ   c              
   C   sf  i }t | dgd urt|dgt | dg t | ddgd ur*t|dgt | ddg t | ddgd urBt|dgtt | ddg t | ddgd urWt|dgt | ddg t | ddgd urlt|d	gt | ddg t | dd
gd urt|dgt | dd
g t | ddgd urt|dgt | ddg t | ddgd urt|dgttt | ddg| |S )NnamemetadatadisplayNamedisplay_namestate
createTimecreate_timeendTimeend_time
updateTimeupdate_timemodeloutputdest)r   r   tt_job_stater8   t_recv_batch_job_destinationr!   r#   r#   r$   _BatchJob_from_mldevG  sV   rl   c              	   C   s  i }t | dgd urt|dgt | dg t | dgd ur(t|dgt | dg t | dgd ur>t|dgtt | dg t | dgd urQt|dgt | dg t | dgd urdt|dgt | dg t | dgd urwt|d	gt | dg t | d
gd urt|dgt | d
g t | dgd urt|dgt | dg t | dgd urt|dgt | dg t | dgd urt|dgtt | dg| t | dgd urt|dgttt | dg| t | dgd urt|dgt | dg t | dgd urt|dgt | dg |S )Nr[   r]   r^   r_   errorr`   ra   	startTime
start_timerb   rc   rd   re   rf   inputConfigsrcoutputConfigrh   completionStatscompletion_stats
outputInfooutput_info)r   r   ri   rj   rP   rD   rk   r!   r#   r#   r$   _BatchJob_from_vertex  sV   	rw   c                 C   sl   i }t | dgd urt|dgt | dg t | dgd ur!tdt | dgd ur4t|dgt | dg |S )Ndatar^   tdisplay_name parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.	mime_typemimeTyper   r!   r#   r#   r$   _Blob_to_mldev     r|   c              	   C   8   i }t |dgd urt|ddgt| t |dg |S Nr[   _urlr   r   ri   t_batch_job_namerQ   r   r   r"   r#   r#   r$   "_CancelBatchJobParameters_to_mldev     r   c              	   C   r~   r   r   r   r#   r#   r$   #_CancelBatchJobParameters_to_vertex  r   r   c                 C   s  i }t | dgd urt|dgt | dg t | dgd ur+t|dgtt | dg| t | dgd ur>t|dgt | dg t | dgd urQt|dgt | dg t | dgd urdt|d	gt | dg t | d
gd urwt|dgt | d
g t | dgd urt|dgt | dg t | dgd urt|dgt | dg t | dgd urt|dgdd t | dgD  t | dgd urt|dgt | dg |S )NcontentcitationMetadatacitation_metadata
tokenCounttoken_countfinishReasonfinish_reasongroundingMetadatagrounding_metadataavgLogprobsavg_logprobsindexlogprobsResultlogprobs_resultsafetyRatingssafety_ratingsc                 S   r4   r#   r#   r,   r#   r#   r$   r0         z)_Candidate_from_mldev.<locals>.<listcomp>urlContextMetadataurl_context_metadata)r   r   _CitationMetadata_from_mldevr!   r#   r#   r$   _Candidate_from_mldev  sP   

r   c                 C   s8   i }t | dgd urt|dgdd t | dgD  |S )NcitationSources	citationsc                 S   r4   r#   r#   r,   r#   r#   r$   r0   3  r   z0_CitationMetadata_from_mldev.<locals>.<listcomp>r6   r!   r#   r#   r$   r   *  s   r   c                    sb   i  t | dgd urt dg fddt | dgD  t | dgd ur/t dgt | dg  S )Npartsc                    r*   r#   )_Part_to_mldevr,   r/   r#   r$   r0   B  r1   z%_Content_to_mldev.<locals>.<listcomp>roler6   r7   r#   r/   r$   _Content_to_mldev9  s   

	r   c                 C   sp   i }t | dgd urt|ddgt | dg t | dgd ur"tdt | dgd ur6t|ddgt | dg |S )Nr^   batchr]   rh   zldest parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.webhook_configwebhookConfigr   r!   r#   r#   r$   _CreateBatchJobConfig_to_mldevN  s$   

r   c              	   C   sx   i }t | dgd urt|dgt | dg t | dgd ur.t|dgttt | dg| t | dgd ur:td|S )Nr^   r]   rh   rr   r   zvwebhook_config parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.)r   r   rG   ri   t_batch_job_destinationr    r!   r#   r#   r$   _CreateBatchJobConfig_to_vertexk  s    r   c                 C   s   i }t |dgd urt|ddgt| t |dg t |dgd ur6t|ddgt| t| t |dg| t |dgd urGtt |dg| |S Nrf   r   rq   r   rp   config)r   r   ri   t_modelrY   t_batch_job_sourcer   r   r#   r#   r$   "_CreateBatchJobParameters_to_mldev  s(   
r   c              
   C   s   i }t |dgd urt|dgt| t |dg t |dgd ur3t|dgtt| t |dg| t |dgd urDtt |dg| |S )Nrf   rq   rp   r   )r   r   ri   r   rZ   r   r   r   r#   r#   r$   #_CreateBatchJobParameters_to_vertex  s&   	r   c                 C   s0   i }t | dgd urt|ddgt | dg |S )Nr^   r   r]   r6   r!   r#   r#   r$   (_CreateEmbeddingsBatchJobConfig_to_mldev  s   
r   c              	   C   s   i }t |dgd urt|ddgt| t |dg t |dgd ur2t|ddgt| t |dg| t |dgd urCtt |dg| |S r   )r   r   ri   r   "_EmbeddingsBatchJobSource_to_mldevr   r   r#   r#   r$   ,_CreateEmbeddingsBatchJobParameters_to_mldev  s(   r   c              	   C   r~   r   r   r   r#   r#   r$   "_DeleteBatchJobParameters_to_mldev  r   r   c              	   C   r~   r   r   r   r#   r#   r$   #_DeleteBatchJobParameters_to_vertex  r   r   c                 C      i }t | dgd urt|dgt | dg t | dgd ur(t|dgt | dg t | dgd ur;t|dgt | dg t | dgd urNt|dgt | dg |S NsdkHttpResponsesdk_http_responser[   donerm   r6   r!   r#   r#   r$   _DeleteResourceJob_from_mldev     r   c                 C   r   r   r6   r!   r#   r#   r$   _DeleteResourceJob_from_vertex%  r   r   c              
   C   s|   i }t |dgd urt|g ddd t| t |dgD  t |dgd ur<t|dgtt |dg| t|ddi |S )	Ncontents)
requests[]requestr   c                 S   r4   r#   r#   r,   r#   r#   r$   r0   E  r5   z/_EmbedContentBatch_to_mldev.<locals>.<listcomp>r   _selfzrequests[].*zrequests[].request.*)r   r   ri   t_contents_for_embed_EmbedContentConfig_to_mldevmovevr   r#   r#   r$   _EmbedContentBatch_to_mldev;  s&   r   c                 C   s   i }t | dgd urt|ddgt | dg t | dgd ur*t|ddgt | dg t | dgd ur>t|ddgt | dg t | dgd urJtdt | d	gd urVtd
t | dgd urbtdt | dgd urntd|S )N	task_typer   taskTypetitleoutput_dimensionalityoutputDimensionalityrz   zqmime_type parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.auto_truncatezuauto_truncate parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.document_ocrztdocument_ocr parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.audio_track_extractionz~audio_track_extraction parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.r   r!   r#   r#   r$   r   W  s@   

r   c                 C   s\   i }t |dgd urt|dgt |dg t |dgd ur,t|dgt| t |dg| |S )Nr'   rS   rT   )r   r   r   r   r#   r#   r$   r     s   r   c                 C   sl   i }t | dgd urtdt | dgd ur!t|dgt | dg t | dgd ur4t|dgt | dg |S )Nr^   ry   file_urifileUrirz   r{   rW   r!   r#   r#   r$   _FileData_to_mldev  s   r   c                 C   s   i }t | dgd urt|dgt | dg t | dgd ur(t|dgt | dg t | dgd ur;t|dgt | dg t | dgd urGtdt | dgd urStd|S )Nidargsr[   partial_argsztpartial_args parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.will_continuezuwill_continue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.r   r!   r#   r#   r$   _FunctionCall_to_mldev  s    r   c                 C   sl   i }t | dgd urt|dgt | dg t | dgd ur(t|dgt | dg t | dgd ur4td|S )Nallowed_function_namesallowedFunctionNamesmodestream_function_call_argumentszstream_function_call_arguments parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.r   r!   r#   r#   r$   _FunctionCallingConfig_to_mldev  s   
r   c              
      s  i t |dgd urt|dgttt |dg t |dgd ur.tdgt |dg t |dgd urAtdgt |dg t |dgd urTtdgt |dg t |dgd urgtd	gt |dg t |d
gd urztdgt |d
g t |dgd urtdgt |dg t |dgd urtdgt |dg t |dgd urtdgt |dg t |dgd urtdgt |dg t |dgd urtdgt |dg t |dgd urtdgt |dg t |dgd urtdgt |dg t |dgd urtdgt t |dg t |dgd ur.tdgtt |dg t |dgd ur;tdt |dgd urHtdt |d gd urct|d!gfd"d#t |d gD  t |d$gd urt|d$g fd%d#t t |d$gD  t |d&gd urt|d'gt	t |d&g t |d(gd urtd)t |d*gd urt|d+gt
 t |d*g t |d,gd urtd-gt |d,g t |d.gd urtd/gt |d.g t |d0gd urtd1gtt |d0g t |d2gd urtd3t |d4gd urtd5gt |d4g t |d6gd ur6td7gtt |d6g t |d8gd urJtd9gt |d8g t |d:gd urWtd;t |d<gd urkt|d=gt |d<g t |d>gd urtd?gt |d>g S )@Nsystem_instructionsystemInstructiontemperaturetop_ptopPtop_ktopKcandidate_countcandidateCountmax_output_tokensmaxOutputTokensstop_sequencesstopSequencesresponse_logprobsresponseLogprobslogprobspresence_penaltypresencePenaltyfrequency_penaltyfrequencyPenaltyseedresponse_mime_typeresponseMimeTyperesponse_schemaresponseSchemaresponse_json_schemaresponseJsonSchemarouting_configzvrouting_config parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.model_selection_configz~model_selection_config parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.safety_settingssafetySettingsc                    r*   r#   )_SafetySetting_to_mldevr,   r/   r#   r$   r0   H  r1   z3_GenerateContentConfig_to_mldev.<locals>.<listcomp>toolsc                    s   g | ]}t t |qS r#   )_Tool_to_mldevri   t_toolr,   rV   r#   r$   r0   R  s    tool_config
toolConfiglabelsznlabels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.cached_contentcachedContentresponse_modalitiesresponseModalitiesmedia_resolutionmediaResolutionspeech_configspeechConfigaudio_timestampzwaudio_timestamp parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.thinking_configthinkingConfigimage_configimageConfigenable_enhanced_civic_answersenableEnhancedCivicAnswersmodel_armor_configzzmodel_armor_config parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.service_tierserviceTieraudio_transcription_configaudioTranscriptionConfig)r   r   r   ri   	t_contentt_schemat_json_schemar    t_tools_ToolConfig_to_mldevt_cached_content_namet_speech_config_ImageConfig_to_mldevrX   r#   rV   r$   _GenerateContentConfig_to_mldev  s,  




		


r  c                    s   i  t | dgd urt dgt | dg t | dgd ur/t dg fddt | dgD  t | dgd urBt dgt | dg t | dgd urUt d	gt | dg t | d
gd urht dgt | d
g t | dgd ur{t dgt | dg t | dgd urt dgt | dg  S )Nr   r   
candidatesc                    r*   r#   )r   r,   r/   r#   r$   r0     r1   z7_GenerateContentResponse_from_mldev.<locals>.<listcomp>modelVersionmodel_versionpromptFeedbackprompt_feedback
responseIdresponse_idusageMetadatausage_metadatamodelStatusmodel_statusr6   r7   r#   r/   r$   #_GenerateContentResponse_from_mldev  s0   

	r&  c              	   C   r~   r   r   r   r#   r#   r$   _GetBatchJobParameters_to_mldev  r   r'  c              	   C   r~   r   r   r   r#   r#   r$    _GetBatchJobParameters_to_vertex  r   r(  c                 C   sr   i }t | dgd urt|dgtt | dg| t | dgd ur+t|dgt | dg t | dgd ur7td|S )Nauth_config
authConfigenable_widgetenableWidgetgrounding_typeszwgrounding_types parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.)r   r   r%   r    r!   r#   r#   r$   _GoogleMaps_to_mldev  s   r.  c                 C   s   i }t | dgd urt|dgt | dg t | dgd ur!tdt | dgd ur-tdt | dgd ur@t|dgt | dg |S )	Nsearch_typessearchTypesblocking_confidencez{blocking_confidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.exclude_domainszwexclude_domains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.time_range_filtertimeRangeFilterr   r!   r#   r#   r$   _GoogleSearch_to_mldev	  s    r5  c                 C   s   i }t | dgd urt|dgt | dg t | dgd ur(t|dgt | dg t | dgd ur4tdt | dgd ur@tdt | d	gd urLtd
t | dgd urXtdt | dgd urdtd|S )Naspect_ratioaspectRatio
image_size	imageSizeperson_generationzyperson_generation parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.prominent_peoplezxprominent_people parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.output_mime_typezxoutput_mime_type parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.output_compression_qualityzoutput_compression_quality parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.image_output_optionsz|image_output_options parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.r   r!   r#   r#   r$   r  %  s4   r  c                    s   i  t |dgd urt ddgt| t |dg t |dgd ur8t ddg fddtt |dgD  t |dgd urKt dgt |dg t |dgd urit ddgt| t |dgt  dgi d	  S )
Nrf   r   r   c                    r*   r#   )r   r,   r/   r#   r$   r0   b  r1   z,_InlinedRequest_to_mldev.<locals>.<listcomp>r\   r   generationConfig)default_value)r   r   ri   r   
t_contentsr  rX   r#   r/   r$   rU   Q  s8   
	

rU   c                 C   s   i }t | dgd urt|dgtt | dg| t | dgd ur+t|dgt | dg t | dgd ur>t|dgt | dg |S )Nresponser\   rm   )r   r   r&  r!   r#   r#   r$   r+   y  s   r+   c                 C   sp   i }t | dgd urt|ddgt | dg t | dgd ur*t|ddgt | dg t | dgd ur6td|S )N	page_size_querypageSize
page_token	pageTokenfilterznfilter parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.r   r!   r#   r#   r$   _ListBatchJobsConfig_to_mldev  s    
rI  c                 C   s   i }t | dgd urt|ddgt | dg t | dgd ur*t|ddgt | dg t | dgd ur>t|ddgt | dg |S )NrC  rD  rE  rF  rG  rH  r6   r!   r#   r#   r$   _ListBatchJobsConfig_to_vertex  s   
rJ  c                 C   *   i }t | dgd urtt | dg| |S Nr   )r   rI  r!   r#   r#   r$   !_ListBatchJobsParameters_to_mldev     rM  c                 C   rK  rL  )r   rJ  r!   r#   r#   r$   "_ListBatchJobsParameters_to_vertex  rN  rO  c                       i  t | dgd urt dgt | dg t | dgd ur(t dgt | dg t | dgd urBt dg fddt | dgD   S )	Nr   r   nextPageTokennext_page_token
operations
batch_jobsc                    r*   r#   )rl   r,   r/   r#   r$   r0     r1   z5_ListBatchJobsResponse_from_mldev.<locals>.<listcomp>r6   r7   r#   r/   r$   !_ListBatchJobsResponse_from_mldev      

	rU  c                    rP  )	Nr   r   rQ  rR  batchPredictionJobsrT  c                    r*   r#   )rw   r,   r/   r#   r$   r0     r1   z6_ListBatchJobsResponse_from_vertex.<locals>.<listcomp>r6   r7   r#   r/   r$   "_ListBatchJobsResponse_from_vertex  rV  rX  c                 C   s  i }t | dgd urt|dgt | dg t | dgd ur(t|dgt | dg t | dgd ur;t|dgt | dg t | dgd urQt|dgtt | dg| t | d	gd urgt|d
gtt | d	g| t | dgd urzt|dgt | dg t | dgd urt|dgtt | dg| t | dgd urt|dgt | dg t | dgd urt|dgt | dg t | dgd urt|dgt | dg t | dgd urt|dgt | dg t | dgd urt|dgt | dg t | dgd urt|dgt | dg t | dgd urt|dgt | dg t | dgd ur+t|dgt | dg t | dgd ur?t|dgt | dg |S )Nr  r  code_execution_resultcodeExecutionResultexecutable_codeexecutableCode	file_datafileDatafunction_callfunctionCallfunction_responsefunctionResponseinline_data
inlineDatatextthoughtthought_signaturethoughtSignaturevideo_metadatavideoMetadata	tool_calltoolCalltool_responsetoolResponsepart_metadatapartMetadataaudio_transcriptionaudioTranscriptionmedia_processingmediaProcessing)r   r   r   r   r|   r!   r#   r#   r$   r     s   



r   c                 C   sl   i }t | dgd urt|dgt | dg t | dgd ur!tdt | dgd ur4t|dgt | dg |S )Ncategorymethodznmethod parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.	thresholdr   r!   r#   r#   r$   r   e  r}   r   c                 C   s   i }t | dgd urt|dgt | dg t | dgd ur+t|dgtt | dg| t | dgd ur>t|dgt | dg |S )Nretrieval_configretrievalConfigfunction_calling_configfunctionCallingConfig$include_server_side_tool_invocations includeServerSideToolInvocations)r   r   r   r!   r#   r#   r$   r  y  s(   
r  c                 C   s  i }t | dgd urtdt | dgd ur!t|dgt | dg t | dgd ur4t|dgt | dg t | dgd urJt|dgtt | dg| t | d	gd ur`t|d
gtt | d	g| t | dgd urst|dgt | dg t | dgd urtdt | dgd urt|dgdd t | dgD  t | dgd urt|dgt | dg t | dgd urtdt | dgd urt|dgt | dg t | dgd urt|dgdd t | dgD  t | dgd urtd|S )N	retrievalzqretrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.computer_usecomputerUsefile_search
fileSearchgoogle_searchgoogleSearchgoogle_maps
googleMapscode_executioncodeExecutionenterprise_web_searchz}enterprise_web_search parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.function_declarationsfunctionDeclarationsc                 S   r4   r#   r#   r,   r#   r#   r$   r0     r   z"_Tool_to_mldev.<locals>.<listcomp>google_search_retrievalgoogleSearchRetrievalparallel_ai_searchzzparallel_ai_search parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.url_context
urlContextmcp_servers
mcpServersc                 S   r4   r#   r#   r,   r#   r#   r$   r0     r   exa_ai_searchzuexa_ai_search parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.)r   r    r   r5  r.  r!   r#   r#   r$   r     sp   
r   c                 C   sX   i }t | ddgd urt|dgt | ddg t | dgd ur*t|dgt | dg |S )Nr>   r?   bigquery_destinationr]   r^   r6   r!   r#   r#   r$   rC     s   rC   c                 C   sV   i }t | dgd urt|ddgt | dg t | dgd ur)t|dgt | dg |S )Nr  r>   r?   r^   r]   r6   r!   r#   r#   r$   rF     s   
rF   c                	   @   x  e Zd Zddddee deejejf deej	 dej
fddZddddee dejdeej dej
fd	d
Zdddedeej dej
fddZdddedeej ddfddZdddeej dejfddZdddedeej dejfddZdddedejdeej	 dej
fddZdddedejdeej dej
fddZdddeej deej
 fddZdS )BatchesNrf   r   rf   rq   r   r   c             	   C   sr  t j|||d}| jjr"t| j|}|d}|rd|}nd}nt| j|}|d}|r5d|}nd}|d}|rG| dt| }|	dd  d }	|j
d ur^|j
jd ur^|j
j}	t|}t|}| jd|||	}
|
jsvi nt|
j}| jjrt|}| jjst|}t jj|t|dd rdt|j
d	d t|j
d
d t|j
dd dini d}| j| |S Nrf   rq   r   r   rW  z{model}:batchGenerateContentrD  ?r   postr   r   include_all_fieldsr   r   r  rB  kwargs)r   _CreateBatchJobParameters_api_clientvertexair   get
format_mapr   r   popr   http_optionsr   convert_to_dictencode_unserializable_typesr   bodyjsonloadsrw   rl   BatchJob_from_responsegetattr_verify_responseselfrf   rq   r   parameter_modelrequest_dictrequest_url_dictpathquery_paramsr  rB  response_dictreturn_valuer#   r#   r$   _create  st   






zBatches._createc             	   C   s>  t j|||d}| jjrtdt| j|}|d}|r#d|}nd}|d}|r5| dt| }|	dd  d }	|j
d urL|j
jd urL|j
j}	t|}t|}| jd|||	}
|
jsdi nt|
j}| jjsrt|}t jj|t|dd rdt|j
d	d t|j
d
d t|j
dd dini d}| j| |S Nr  ziThis method is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.r   z{model}:asyncBatchEmbedContentrD  r  r   r  r   r   r  r  r  )r   #_CreateEmbeddingsBatchJobParametersr  r  r    r   r  r  r   r  r   r  r   r  r  r   r  r  r  rl   r  r  r  r  r  r#   r#   r$   _create_embeddings^  sh   





zBatches._create_embeddingsr   r[   c             	   C   sp  t j||d}| jjr!t| j|}|d}|rd|}nd}nt| j|}|d}|r4d|}nd}|d}|rF| dt| }|	dd d}|j
dur]|j
jdur]|j
j}t|}t|}| jd	|||}	|	jsui nt|	j}
| jjrt|
}
| jjst|
}
t jj|
t|ddrdt|j
d
dt|j
ddt|j
dddini d}| j| |S )aW  Gets a batch job.

    Args:
      name (str): A fully-qualified BatchJob resource name or ID.
        Example: "projects/.../locations/.../batchPredictionJobs/456" or "456"
          when project and location are initialized in the Gemini Enterprise
          Agent Platform client. Or "batches/abc" using the Gemini Developer AI
          client.

    Returns:
      A BatchJob object that contains details about the batch job.

    Usage:

    .. code-block:: python

      batch_job = client.batches.get(name='123456789')
      print(f"Batch job: {batch_job.name}, state {batch_job.state}")
    r[   r   r   batchPredictionJobs/{name}batches/{name}rD  r  r   Nr  r   r   r  r  r  )r   _GetBatchJobParametersr  r  r(  r  r  r'  r   r  r   r  r   r  r  r   r  r  r  rw   rl   r  r  r  r  r  r[   r   r  r  r  r  r  r  rB  r  r  r#   r#   r$   r    sn   






zBatches.getc          	      C   s   t j||d}| jjr!t| j|}|d}|rd|}nd}nt| j|}|d}|r4d|}nd}|d}|rF| dt| }|	dd d}|j
dur]|j
jdur]|j
j}t|}t|}| jd	||| dS )
a  Cancels a batch job.

    Only available for batch jobs that are running or pending.

    Args:
      name (str): A fully-qualified BatchJob resource name or ID.
        Example: "projects/.../locations/.../batchPredictionJobs/456" or "456"
          when project and location are initialized in the Vertex AI client. Or
          "batches/abc" using the Gemini Developer AI client.

    Usage:

    .. code-block:: python

      client.batches.cancel(name='123456789')
    r  r   !batchPredictionJobs/{name}:cancelbatches/{name}:cancelrD  r  r   Nr  )r   _CancelBatchJobParametersr  r  r   r  r  r   r   r  r   r  r   r  r  r   	r  r[   r   r  r  r  r  r  r  r#   r#   r$   cancel
  s<   





zBatches.cancelc             	   C   sv  t j|d}| jjrt|}|d}|rd|}nd}nt|}|d}|r/d|}nd}|d}|rA| dt| }|	dd  d }|j
d urX|j
jd urX|j
j}t|}t|}| jd|||}|jspi nt|j}	| jjr~t|	}	| jjst|	}	t jj|	t|dd rdt|j
d	d t|j
d
d t|j
dd dini d}
t j|jd|
_| j|
 |
S Nr  r   rW  batchesrD  r  r   r  r   r   r  r  r  headers)r   _ListBatchJobsParametersr  r  rO  r  r  rM  r   r  r   r  r   r  r  r   r  r  r  rX  rU  ListBatchJobsResponser  r  HttpResponser  r   r  r  r   r  r  r  r  r  r  rB  r  r  r#   r#   r$   _listL  sj   






zBatches._listc             	   C   s  t j||d}| jjr!t| j|}|d}|rd|}nd}nt| j|}|d}|r4d|}nd}|d}|rF| dt| }|	dd d}|j
dur]|j
jdur]|j
j}t|}t|}| jd	|||}	|	jsui nt|	j}
| jjrt|
}
| jjst|
}
t jj|
t|ddrdt|j
d
dt|j
ddt|j
dddini d}t j|	jd|_| j| |S )a  Deletes a batch job.

    Args:
      name (str): A fully-qualified BatchJob resource name or ID.
        Example: "projects/.../locations/.../batchPredictionJobs/456" or "456"
          when project and location are initialized in the client.

    Returns:
      A DeleteResourceJob object that shows the status of the deletion.

    Usage:

    .. code-block:: python

      client.batches.delete(name='123456789')
    r  r   r  r  rD  r  r   Ndeleter   r   r  r  r  r  )r   _DeleteBatchJobParametersr  r  r   r  r  r   r   r  r   r  r   r  r  r   r  r  r  r   r   DeleteResourceJobr  r  r  r  r   r  r  r#   r#   r$   r    sx   






zBatches.deletec                C   sT   t | j|}tj|||d}| jjr"t||j}| j	|||dS | j	|||dS )a  Creates a batch job.

    Args:
      model (str): The model to use for the batch job.
      src: The source of the batch job. Currently Gemini Enterprise Agent
        Platform supports GCS URI(-s) or BigQuery URI. Example:
        "gs://path/to/input/data" or "bq://projectId.bqDatasetId.bqTableId".
        Gemini Developer API supports List of inlined_request, or file name.
        Example: "files/file_name".
      config (CreateBatchJobConfig): Optional configuration for the batch job.

    Returns:
      A BatchJob object that contains details about the batch job.

    Usage:

    .. code-block:: python

      batch_job = client.batches.create(
          model="gemini-2.0-flash-001",
          src="gs://path/to/input/data",
      )
      print(batch_job.state)
    r  
ri   r   r  r   r  r  r	   format_destinationr   r  r  rf   rq   r   r  r#   r#   r$   create  s   zBatches.createc                C   sX   ddl }|jdtjdd t| j|}tj|||d}| jj	r$t
d| j|||dS )a]  **Experimental** Creates an embedding batch job.

    Args:
      model (str): The model to use for the batch job.
      src: Gemini Developer API supports List of inlined_request, or file name.
        Example: "files/file_name".
      config (CreateBatchJobConfig): Optional configuration for the batch job.

    Returns:
      A BatchJob object that contains details about the batch job.

    Usage:

    .. code-block:: python

      batch_job = client.batches.create_embeddings(
          model="text-embedding-004",
          src="files/my_embedding_input",
      )
      print(batch_job.state)
    r   NJbatches.create_embeddings() is experimental and may change without notice.   ru  
stacklevelr  lGemini Enterprise Agent Platform (previously known as Vertex AI) does not support batches.create_embeddings.)warningswarnr   ExperimentalWarningri   t_embedding_batch_job_sourcer  r   r  r  r    r  )r  rf   rq   r   r  r  r#   r#   r$   create_embeddings'	  s"   zBatches.create_embeddingsc                C   s   | j }td|| j |d|S )a  Lists batch jobs.

    Args:
      config (ListBatchJobsConfig): Optional configuration for the list request.

    Returns:
      A Pager object that contains one page of batch jobs. When iterating over
      the pager, it automatically fetches the next page if there are more.

    Usage:

    .. code-block:: python
      config = {'page_size': 10}
      for batch_job in client.batches.list(config):
        print(batch_job.name)
    rT  r  )r  r   r  r   list_requestr#   r#   r$   list\	  s   
zBatches.list)__name__
__module____qualname__r   strr   r   BatchJobSourceUnionBatchJobSourceUnionDictCreateBatchJobConfigOrDictr  r  EmbeddingsBatchJobSourceOrDict$CreateEmbeddingsBatchJobConfigOrDictr  GetBatchJobConfigOrDictr  CancelBatchJobConfigOrDictr  ListBatchJobsConfigOrDictr  r  DeleteBatchJobConfigOrDictr  r  r  r  r   r  r#   r#   r#   r$   r  	  s    
V
M
d
C
M
i
3
6r  c                	   @   r  )AsyncBatchesNr  rf   rq   r   r   c             	      sz  t j|||d}| jjr#t| j|}|d}|r d|}nd}nt| j|}|d}|r6d|}nd}|d}|rH| dt| }|	dd  d }	|j
d ur_|j
jd ur_|j
j}	t|}t|}| jd|||	I d H }
|
jszi nt|
j}| jjrt|}| jjst|}t jj|t|dd rdt|j
d	d t|j
d
d t|j
dd dini d}| j| |S r  )r   r  r  r  r   r  r  r   r   r  r   r  r   r  r  async_requestr  r  r  rw   rl   r  r  r  r  r  r#   r#   r$   r  {	  sv   







zAsyncBatches._createc             	      sF  t j|||d}| jjrtdt| j|}|d}|r$d|}nd}|d}|r6| dt| }|	dd  d }	|j
d urM|j
jd urM|j
j}	t|}t|}| jd|||	I d H }
|
jshi nt|
j}| jjsvt|}t jj|t|dd rdt|j
d	d t|j
d
d t|j
dd dini d}| j| |S r  )r   r  r  r  r    r   r  r  r   r  r   r  r   r  r  r  r  r  r  rl   r  r  r  r  r  r#   r#   r$   r  	  sj   






zAsyncBatches._create_embeddingsr  r[   c             	      sx  t j||d}| jjr"t| j|}|d}|rd|}nd}nt| j|}|d}|r5d|}nd}|d}|rG| dt| }|	dd d}|j
dur^|j
jdur^|j
j}t|}t|}| jd	|||I dH }	|	jsyi nt|	j}
| jjrt|
}
| jjst|
}
t jj|
t|ddrdt|j
d
dt|j
ddt|j
dddini d}| j| |S )aa  Gets a batch job.

    Args:
      name (str): A fully-qualified BatchJob resource name or ID.
        Example: "projects/.../locations/.../batchPredictionJobs/456" or "456"
          when project and location are initialized in the Gemini Enterprise
          Agent Platform client. Or "batches/abc" using the Gemini Developer AI
          client.

    Returns:
      A BatchJob object that contains details about the batch job.

    Usage:

    .. code-block:: python

      batch_job = await client.aio.batches.get(name='123456789')
      print(f"Batch job: {batch_job.name}, state {batch_job.state}")
    r  r   r  r  rD  r  r   Nr  r   r   r  r  r  )r   r  r  r  r(  r  r  r'  r   r  r   r  r   r  r  r  r  r  r  rw   rl   r  r  r  r  r  r#   r#   r$   r  
  st   







zAsyncBatches.getc          	         s   t j||d}| jjr"t| j|}|d}|rd|}nd}nt| j|}|d}|r5d|}nd}|d}|rG| dt| }|	dd d}|j
dur^|j
jdur^|j
j}t|}t|}| jd	|||I dH  dS )
a  Cancels a batch job.

    Only available for batch jobs that are running or pending.

    Args:
      name (str): A fully-qualified BatchJob resource name or ID.
        Example: "projects/.../locations/.../batchPredictionJobs/456" or "456"
          when project and location are initialized in the Vertex AI client. Or
          "batches/abc" using the Gemini Developer AI client.

    Usage:

    .. code-block:: python

      await client.aio.batches.cancel(name='123456789')
    r  r   r  r  rD  r  r   Nr  )r   r  r  r  r   r  r  r   r   r  r   r  r   r  r  r  r  r#   r#   r$   r  |
  sB   





zAsyncBatches.cancelc             	      s~  t j|d}| jjrt|}|d}|rd|}nd}nt|}|d}|r0d|}nd}|d}|rB| dt| }|	dd  d }|j
d urY|j
jd urY|j
j}t|}t|}| jd|||I d H }|jsti nt|j}	| jjrt|	}	| jjst|	}	t jj|	t|dd rdt|j
d	d t|j
d
d t|j
dd dini d}
t j|jd|
_| j|
 |
S r  )r   r  r  r  rO  r  r  rM  r   r  r   r  r   r  r  r  r  r  r  rX  rU  r  r  r  r  r  r   r  r  r#   r#   r$   r  
  sp   







zAsyncBatches._listc             	      s  t j||d}| jjr"t| j|}|d}|rd|}nd}nt| j|}|d}|r5d|}nd}|d}|rG| dt| }|	dd d}|j
dur^|j
jdur^|j
j}t|}t|}| jd	|||I dH }	|	jsyi nt|	j}
| jjrt|
}
| jjst|
}
t jj|
t|ddrdt|j
d
dt|j
ddt|j
dddini d}t j|	jd|_| j| |S )a  Deletes a batch job.

    Args:
      name (str): A fully-qualified BatchJob resource name or ID.
        Example: "projects/.../locations/.../batchPredictionJobs/456" or "456"
          when project and location are initialized in the client.

    Returns:
      A DeleteResourceJob object that shows the status of the deletion.

    Usage:

    .. code-block:: python

      await client.aio.batches.delete(name='123456789')
    r  r   r  r  rD  r  r   Nr  r   r   r  r  r  r  )r   r  r  r  r   r  r  r   r   r  r   r  r   r  r  r  r  r  r  r   r   r  r  r  r  r  r   r  r  r#   r#   r$   r    sz   







zAsyncBatches.deletec                   sb   t | j|}tj|||d}| jjr&t||j}| j	|||dI dH S | j	|||dI dH S )a  Creates a batch job asynchronously.

    Args:
      model (str): The model to use for the batch job.
      src: The source of the batch job. Currently Gemini Enterprise Agent
        Platform supports GCS URI(-s) or BigQuery URI. Example:
        "gs://path/to/input/data" or "bq://projectId.bqDatasetId.bqTableId".
        Gemini Develop API supports List of inlined_request, or file name.
        Example: "files/file_name".
      config (CreateBatchJobConfig): Optional configuration for the batch job.

    Returns:
      A BatchJob object that contains details about the batch job.

    Usage:

    .. code-block:: python

      batch_job = await client.aio.batches.create(
          model="gemini-2.0-flash-001",
          src="gs://path/to/input/data",
      )
    r  Nr  r  r#   r#   r$   r  o  s   zAsyncBatches.createc                   s   ddl }|jdtjdd t| j|}tj|||d}d}|j	dur.|j	j
dur.|j	j
}| jjr6td| j|||dI dH S )ao  **Experimental** Creates an asynchronously embedding batch job.

    Args:
      model (str): The model to use for the batch job.
      src: Gemini Developer API supports inlined_requests, or file name.
        Example: "files/file_name".
      config (CreateBatchJobConfig): Optional configuration for the batch job.

    Returns:
      A BatchJob object that contains details about the batch job.

    Usage:

    .. code-block:: python

      batch_job = await client.aio.batches.create_embeddings(
          model="text-embedding-004",
          src="files/my_embedding_input",
      )
      print(batch_job.state)
    r   Nr  r  r  r  r  )r  r  r   r  ri   r  r  r   r  r   r  r  r    r  )r  rf   rq   r   r  r  r  r#   r#   r$   r    s,   
zAsyncBatches.create_embeddingsc                   s$   | j }td|| j |dI dH |S )a  Lists batch jobs asynchronously.

    Args:
      config (ListBatchJobsConfig): Optional configuration for the list request.

    Returns:
      A Pager object that contains one page of batch jobs. When iterating over
      the pager, it automatically fetches the next page if there are more.

    Usage:

    .. code-block:: python
      async for batch_job in await client.aio.batches.list():
        print(batch_job.name)
    rT  r  N)r  r   r  r#   r#   r$   r    s   zAsyncBatches.list)r  r  r  r   r  r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r#   r#   r#   r$   r  y	  s    
V
M
f
E
O
i
2
=r  )N)Vr  loggingtypingr   r   r   urllib.parser    r   r   r	   r
   ri   r   r  r   r   r   r   r   r   r   pagersr   r   	getLoggerloggerdictr  objectr%   r8   rD   rG   rP   rY   rZ   rl   rw   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r&  r'  r(  r.  r5  r  rU   r+   rI  rJ  rM  rO  rU  rX  r   r   r  r   rC   rF   
BaseModuler  r  r#   r#   r#   r$   <module>   s  


1

*

$

6

"

0

*

;

@







:









!





!











4









 H

)









/

*















Z





Q



    t