o
    pkj˧                     @  s6  d Z ddlmZ ddlmZmZmZmZmZm	Z	m
Z
 ddlZddl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mZmZmZmZm Z m!Z! ddl"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+m,Z, ddl-m.Z/ ddl-m0Z1 ddl2m3Z4 ddl2m5Z6 ddl&m7Z8 ddl&m9Z: ddl;m<Z= ddl;m>Z? eZe@ddhZAedZBd{d d!ZCd{d"d#ZDd|d%d&ZEd}d(d)ZFG d*d+ d+ZGd~d-d.ZHd/ZId0ZJd1ZKd/ZLd2ZMdd5d6ZN	ddd9d:ZO	ddd<d=ZPG d>d? d?eZQG d@dA dAeZRG dBdC dCe6ZSG dDdE dEe4ZTG dFdG dGeZUG dHdI dIeZVG dJdK dKe1ZWG dLdM dMe/ZXG dNdO dOe?ZYG dPdQ dQe=ZZG dRdS dSe:Z[G dTdU dUe8Z\ddWdXZ]ddYdZZ^dd^d_Z_ddadbZ`e@dcdd ejaejbfD ZcdeZdddgdhZeddidjZfddldmZgddndoZhddpdqZidddtduZjddvdwZkddydzZldS )zKHelpers for embedding the generated NextGen SDK in the Google GenAI client.    )annotations)TYPE_CHECKINGAnyMappingOptionalTypeVarUnioncastN   )GOOGLE_GENAI_API_REVISIONGoogleGenAISecurityProvider)AsyncAgents)Agents)AsyncInteractions)Interactions)_AsyncRawResponseAccessorProxy_RawResponseAccessorProxyasync_wrap_sdk_call	is_streamwrap_async_stream_errorswrap_sdk_callwrap_stream_errors)
AsyncGenAIGenAI)environments)interactions)Security)BackoffStrategyRetryConfigeventstreaming)AsyncTriggers)Triggers)AsyncWebhooks)Webhooks)AsyncEnvironments)Environments)
AsyncFiles)Fileszlyria-3-pro-previewzlyria-3-clip-previewModelT
api_clientr   returnstrc                 C  s"   | j j}|s
tdt|dS )z?Returns the server URL from the parent Google GenAI API client.zBase URL must be set./)_http_optionsbase_url
ValueErrorr+   rstrip)r)   
server_url r2   ]/home/djax/ivt_ai_plugin/venv/lib/python3.10/site-packages/google/genai/_gaos/google_genai.pyget_google_genai_server_urlC   s   r4   c                 C  s:   | j jpd}| jr| jr| jr| d| j d| j S |S )z@Returns the generated path parameter for the parent client mode. z
/projects/z/locations/)r-   api_versionvertexaiprojectlocation)r)   r6   r2   r2   r3   get_google_genai_api_versionK   s   r:   Optional[dict[str, str]]c                 C  s   | j j}|r
t|S d S N)r-   headersdict)r)   r=   r2   r2   r3   !_get_google_genai_default_headersV   s   r?   Optional[str]c                 C  s   t | dd }t |dd S )N_credentialsquota_project_id)getattr)r)   credentialsr2   r2   r3   _get_google_genai_user_project]   s   rE   c                   @  s    e Zd ZdddZddd	Zd
S )_GoogleGenAIAccessTokenProviderr)   r   r*   Nonec                 C  s
   || _ d S r<   )_api_client)selfr)   r2   r2   r3   __init__c      
z(_GoogleGenAIAccessTokenProvider.__init__r+   c                 C  s
   | j  S r<   )rH   _access_tokenrI   r2   r2   r3   __call__f   rK   z(_GoogleGenAIAccessTokenProvider.__call__N)r)   r   r*   rG   )r*   r+   )__name__
__module____qualname__rJ   rN   r2   r2   r2   r3   rF   b   s    
rF   Optional[Any]c                 C  sP   t | }| jrt| j|dS | jr| js| jrtt| |dS |r&t|dS d S )N)api_keydefault_headers)access_tokenrT   )rT   )r?   rS   r   r7   r8   r9   r   rF   )r)   rT   r2   r2   r3   _get_google_genai_securityj   s   
rV      i  i@  i0u  http_optionsr   c           	   	   C  s   t | dd}|durt |ddnd}|dur|ntd }t}t}t}d}d}|dura|jdur6t|jd }|jdurBt|jd }|jdurJ|j}|j	durVt|j	d }|j
radd |j
D }tdt|||t|d	d
||dS )al  Maps parent `HttpOptions.retry_options` onto a `RetryConfig`.

    `attempts` becomes the retry count (an unset `attempts` falls back to the
    default retry count). The delay-shaping options (`initial_delay`,
    `max_delay`, `exp_base`, `jitter`) and `http_status_codes` are honored when
    provided, each defaulting to the built-in behavior when omitted.
    retry_optionsNattemptsr
   i  c                 S     g | ]}t |qS r2   )r+   ).0coder2   r2   r3   
<listcomp>       z+_translate_retry_config.<locals>.<listcomp>zattempt-count-backoff)	jitter_msT)max_retriesstatus_codes_override)rC   _DEFAULT_MAX_RETRIES_DEFAULT_INITIAL_INTERVAL_MS_DEFAULT_MAX_INTERVAL_MS_DEFAULT_EXPONENTinitial_delayint	max_delayexp_basejitterhttp_status_codesr   r   _MAX_ELAPSED_TIME_MS)	rX   optionsrZ   ra   initial_intervalmax_intervalexponentr`   rb   r2   r2   r3   _translate_retry_config   s@   



rr   r6   r   c              	   C  B   | j }tt| |pt| t| t| t| dd|jt|d}|S )?Builds a generated NextGen client from the parent GenAI client._httpx_clientN)securityr6   user_projectr1   client
timeout_msretry_config)	r-   r   rV   r:   rE   r4   rC   timeoutrr   r)   r6   rX   sdkr2   r2   r3   build_google_genai_client      

	r~   r   c              	   C  rs   )rt   _async_httpx_clientN)rv   r6   rw   r1   async_clientry   rz   )	r-   r   rV   r:   rE   r4   rC   r{   rr   r|   r2   r2   r3   build_google_genai_async_client   r   r   c                         e Zd ZdZd* fddZese fddZe fdd	Zes0d
d
d
d
d
d
dd+ fddZ	esBd
d
d
dd
d
d
dd, fd"d#Z
esQd
d
d
d
d$d- fd&d'Zesdd
d
d
d
d$d. fd(d)Z  ZS   ZS )/GeminiNextGenInteractionsa  Public interactions resource backed by the NextGen client.

    Subclasses the generated resource so newly generated methods (and the
    raw/streaming response wrappers) are exposed automatically. Only the
    methods that need legacy input/output normalization are overridden.

    Each override sits inside `if not TYPE_CHECKING:` so static type checkers
    see the inherited generated signature (full overload sets) rather than the
    runtime stub here.
    r)   r   c                      t |}t j|j|d d S N)
parent_refr~   superrJ   sdk_configurationrI   r)   r}   	__class__r2   r3   rJ         z"GeminiNextGenInteractions.__init__c                      t t jS r<   r   r   with_raw_responserM   r   r2   r3   r         z+GeminiNextGenInteractions.with_raw_responsec                   r   r<   r   r   with_streaming_responserM   r   r2   r3   r      r   z1GeminiNextGenInteractions.with_streaming_responseNrequestr6   extra_headersextra_query
extra_bodyr{   r   r6   r@   r   Optional[Mapping[str, str]]r   Optional[Mapping[str, Any]]r   r{   %Optional[Union[float, httpx.Timeout]]bodyr*   XUnion[interactions.Interaction, eventstreaming.Stream[interactions.InteractionSSEEvent]]c          
   	     s   |d ur+|r
t tt|}tt j||||||d}	|r't|	r%t|	S |	S t|	S t	|
ddd}t|}tt jfd|itt|||||d}	|rZt|	rXt|	S |	S t|	S Nr   streamFdefaultr6   )r   r   r   r{   )	TypeError_REQUEST_AND_BODY_ERROR_request_streamr   r   creater   r   %_add_output_properties_if_interaction_optional_boolget_normalize_create_bodyr	   r   
rI   r   r6   r   r   r   r{   r   r   responser   r2   r3   r      sJ   	
	z GeminiNextGenInteractions.createFr6   include_inputlast_event_idr   r   r   r{   idr+   r   r   r   c                  sl   t t|dd}	tt j||t|t||	|||d	}
|	r.t|
s#|
S ttj	t
j t|
S tt
jt|
S NFr   )r   r6   r   r   r   r   r   r{   )boolr   r   r   r   _optional_strr   r	   r   Streamr   InteractionSSEEventr   Interactionr   rI   r   r6   r   r   r   r   r   r{   stream_boolr   r   r2   r3   r   '  s,   

zGeminiNextGenInteractions.getr6   r   r   r{   interactions.Interactionc                  s$   t tjttt j|||||dS N)r   r6   r   r   r{   )r	   r   r   r   r   r   cancelrI   r   r6   r   r   r{   r   r2   r3   r   N  s   	z GeminiNextGenInteractions.cancelc                  s   t t j|||||dS r   r   r   deleter   r   r2   r3   r   f  s   	z GeminiNextGenInteractions.deleter)   r   )r   r   r6   r@   r   r   r   r   r   r   r{   r   r   r   r*   r   )r   r+   r6   r@   r   r   r   r   r   r   r   r   r   r   r{   r   r*   r   r   r+   r6   r@   r   r   r   r   r{   r   r*   r   r   r+   r6   r@   r   r   r   r   r{   r   r*   r   rO   rP   rQ   __doc__rJ   r   propertyr   r   r   r   r   r   __classcell__r2   r2   r   r3   r      sL    3&r   c                      r   )/AsyncGeminiNextGenInteractionsz@Async public interactions resource backed by the NextGen client.r)   r   c                   r   r   r   r   rJ   r   r   r   r2   r3   rJ   |  r   z'AsyncGeminiNextGenInteractions.__init__c                   r   r<   r   r   r   rM   r   r2   r3   r     r   z0AsyncGeminiNextGenInteractions.with_raw_responsec                   r   r<   r   r   r   rM   r   r2   r3   r     r   z6AsyncGeminiNextGenInteractions.with_streaming_responseNr   r   r6   r@   r   r   r   r   r   r{   r   r   r*   ]Union[interactions.Interaction, eventstreaming.AsyncStream[interactions.InteractionSSEEvent]]c          
   	     s   |d ur/|rt tt|}tt j||||||dI d H }	|r+t|	r)t|	S |	S t|	S t	|
ddd}t|}tt jfd|itt|||||dI d H }	|rat|	r_t|	S |	S t|	S r   )r   r   r   r   r   r   r   r   r   r   r   r   r	   r   r   r   r2   r3   r     sL   		z%AsyncGeminiNextGenInteractions.createFr   r   r+   r   r   r   c                  st   t t|dd}	tt j||t|t||	|||d	I d H }
|	r2t|
s'|
S ttj	t
j t|
S tt
jt|
S r   )r   r   r   r   r   r   r   r	   r   AsyncStreamr   r   r   r   r   r   r   r2   r3   r     s.   

z"AsyncGeminiNextGenInteractions.getr   r   c                  s,   t tjttt j|||||dI d H S r   )r	   r   r   r   r   r   r   r   r   r2   r3   r     s   	
z%AsyncGeminiNextGenInteractions.cancelc                  s    t t j|||||dI d H S r   r   r   r   r   r   r2   r3   r     s   	z%AsyncGeminiNextGenInteractions.deleter   )r   r   r6   r@   r   r   r   r   r   r   r{   r   r   r   r*   r   )r   r+   r6   r@   r   r   r   r   r   r   r   r   r   r   r{   r   r*   r   r   r   r   r2   r2   r   r3   r   y  sL    3&r   c                         e Zd ZdZd fddZesTe fddZe fdd	Zd fddZ	d fddZ
d fddZd fddZd fddZd fddZd fddZ  ZS   ZS )GeminiNextGenWebhooksa8  Public webhooks resource backed by the NextGen client.

    Subclasses the generated resource so every public method is wrapped in
    `wrap_sdk_call`, translating per-operation `GenAiError` raises into the
    status-code `APIError` hierarchy exposed at the
    `google.genai._interactions` import surface.
    r)   r   c                   r   r   r   r   r   r2   r3   rJ     r   zGeminiNextGenWebhooks.__init__c                   r   r<   r   rM   r   r2   r3   r     r   z'GeminiNextGenWebhooks.with_raw_responsec                   r   r<   r   rM   r   r2   r3   r   #  r   z-GeminiNextGenWebhooks.with_streaming_responseargskwargsr*   c                      t t jg|R i |S r<   r   r   r   rI   r   r   r   r2   r3   r   '     zGeminiNextGenWebhooks.createc                   r   r<   r   r   listr   r   r2   r3   r   *  r   zGeminiNextGenWebhooks.listc                   r   r<   r   r   r   r   r   r2   r3   r   -  r   zGeminiNextGenWebhooks.getc                   r   r<   r   r   updater   r   r2   r3   r   0  r   zGeminiNextGenWebhooks.updatec                   r   r<   r   r   r   r2   r3   r   3  r   zGeminiNextGenWebhooks.deletec                   r   r<   )r   r   rotate_signing_secretr   r   r2   r3   r   6  r   z+GeminiNextGenWebhooks.rotate_signing_secretc                   r   r<   )r   r   pingr   r   r2   r3   r   9  r   zGeminiNextGenWebhooks.pingr   r   r   r   r   r*   r   rO   rP   rQ   r   rJ   r   r   r   r   r   r   r   r   r   r   r   r   r2   r2   r   r3   r     s     r   c                      r   )AsyncGeminiNextGenWebhooksz<Async public webhooks resource backed by the NextGen client.r)   r   c                   r   r   r   r   r   r2   r3   rJ   @  r   z#AsyncGeminiNextGenWebhooks.__init__c                   r   r<   r   rM   r   r2   r3   r   E  r   z,AsyncGeminiNextGenWebhooks.with_raw_responsec                   r   r<   r   rM   r   r2   r3   r   I  r   z2AsyncGeminiNextGenWebhooks.with_streaming_responser   r   r*   c                   "   t t jg|R i |I d H S r<   r   r   r   r   r   r2   r3   r   M      z!AsyncGeminiNextGenWebhooks.createc                   r   r<   r   r   r   r   r   r2   r3   r   P  r   zAsyncGeminiNextGenWebhooks.listc                   r   r<   r   r   r   r   r   r2   r3   r   S  r   zAsyncGeminiNextGenWebhooks.getc                   r   r<   r   r   r   r   r   r2   r3   r   V  r   z!AsyncGeminiNextGenWebhooks.updatec                   r   r<   r   r   r   r2   r3   r   Y  r   z!AsyncGeminiNextGenWebhooks.deletec                   r   r<   )r   r   r   r   r   r2   r3   r   \  s   z0AsyncGeminiNextGenWebhooks.rotate_signing_secretc                   r   r<   )r   r   r   r   r   r2   r3   r   a  r   zAsyncGeminiNextGenWebhooks.pingr   r   r   r2   r2   r   r3   r   =  s     r   c                         e Zd ZdZd fddZes?e fddZe fdd	Zd fddZ	d fddZ
d fddZd fddZ  ZS   ZS )GeminiNextGenAgentsa6  Public agents resource backed by the NextGen client.

    Subclasses the generated resource so every public method is wrapped in
    `wrap_sdk_call`, translating per-operation `GenAiError` raises into the
    status-code `APIError` hierarchy exposed at the
    `google.genai._interactions` import surface.
    r)   r   c                   r   r   r   r   r   r2   r3   rJ   n  r   zGeminiNextGenAgents.__init__c                   r   r<   r   rM   r   r2   r3   r   s  r   z%GeminiNextGenAgents.with_raw_responsec                   r   r<   r   rM   r   r2   r3   r   w  r   z+GeminiNextGenAgents.with_streaming_responser   r   r*   c                   r   r<   r   r   r   r2   r3   r   {  r   zGeminiNextGenAgents.createc                   r   r<   r   r   r   r2   r3   r   ~  r   zGeminiNextGenAgents.listc                   r   r<   r   r   r   r2   r3   r     r   zGeminiNextGenAgents.getc                   r   r<   r   r   r   r2   r3   r     r   zGeminiNextGenAgents.deleter   r   rO   rP   rQ   r   rJ   r   r   r   r   r   r   r   r   r   r2   r2   r   r3   r   e  s    r   c                      r   )AsyncGeminiNextGenAgentsz:Async public agents resource backed by the NextGen client.r)   r   c                   r   r   r   r   r   r2   r3   rJ     r   z!AsyncGeminiNextGenAgents.__init__c                   r   r<   r   rM   r   r2   r3   r     r   z*AsyncGeminiNextGenAgents.with_raw_responsec                   r   r<   r   rM   r   r2   r3   r     r   z0AsyncGeminiNextGenAgents.with_streaming_responser   r   r*   c                   r   r<   r   r   r   r2   r3   r     r   zAsyncGeminiNextGenAgents.createc                   r   r<   r   r   r   r2   r3   r     r   zAsyncGeminiNextGenAgents.listc                   r   r<   r   r   r   r2   r3   r     r   zAsyncGeminiNextGenAgents.getc                   r   r<   r   r   r   r2   r3   r     r   zAsyncGeminiNextGenAgents.deleter   r   r   r2   r2   r   r3   r     s    r   c                      r   )GeminiNextGenTriggersa8  Public triggers resource backed by the NextGen client.

    Subclasses the generated resource so every public method is wrapped in
    `wrap_sdk_call`, translating per-operation `GenAiError` raises into the
    status-code `APIError` hierarchy exposed at the
    `google.genai._interactions` import surface.
    r)   r   c                   r   r   r   r   r   r2   r3   rJ     r   zGeminiNextGenTriggers.__init__c                   r   r<   r   rM   r   r2   r3   r     r   z'GeminiNextGenTriggers.with_raw_responsec                   r   r<   r   rM   r   r2   r3   r     r   z-GeminiNextGenTriggers.with_streaming_responser   r   r*   c                   s@   d|v r|d }t |trt||d< tt jg|R i |S Ninteraction)
isinstancer>   r   r   r   r   rI   r   r   r   r   r2   r3   r     s
   
zGeminiNextGenTriggers.createc                   r   r<   r   r   r   r2   r3   r     r   zGeminiNextGenTriggers.listc                   r   r<   r   r   r   r2   r3   r     r   zGeminiNextGenTriggers.getc                   r   r<   r   r   r   r2   r3   r     r   zGeminiNextGenTriggers.updatec                   r   r<   r   r   r   r2   r3   r     r   zGeminiNextGenTriggers.deletec                   r   r<   )r   r   runr   r   r2   r3   r     r   zGeminiNextGenTriggers.runc                   r   r<   )r   r   list_executionsr   r   r2   r3   r     r   z%GeminiNextGenTriggers.list_executionsr   r   rO   rP   rQ   r   rJ   r   r   r   r   r   r   r   r   r   r   r   r   r2   r2   r   r3   r     s     r   c                      r   )AsyncGeminiNextGenTriggersz<Async public triggers resource backed by the NextGen client.r)   r   c                   r   r   r   r   r   r2   r3   rJ     r   z#AsyncGeminiNextGenTriggers.__init__c                   r   r<   r   rM   r   r2   r3   r     r   z,AsyncGeminiNextGenTriggers.with_raw_responsec                   r   r<   r   rM   r   r2   r3   r     r   z2AsyncGeminiNextGenTriggers.with_streaming_responser   r   r*   c                   sH   d|v r|d }t |trt||d< tt jg|R i |I d H S r   )r   r>   r   r   r   r   r   r   r2   r3   r     s   
 z!AsyncGeminiNextGenTriggers.createc                   r   r<   r   r   r   r2   r3   r     r   zAsyncGeminiNextGenTriggers.listc                   r   r<   r   r   r   r2   r3   r     r   zAsyncGeminiNextGenTriggers.getc                   r   r<   r   r   r   r2   r3   r     r   z!AsyncGeminiNextGenTriggers.updatec                   r   r<   r   r   r   r2   r3   r     r   z!AsyncGeminiNextGenTriggers.deletec                   r   r<   )r   r   r   r   r   r2   r3   r     r   zAsyncGeminiNextGenTriggers.runc                   r   r<   )r   r   r   r   r   r2   r3   r     r   z*AsyncGeminiNextGenTriggers.list_executionsr   r   r   r2   r2   r   r3   r     s     r   c                      j   e Zd ZdZ		dd fdd	Zes)e fd
dZe fddZd fddZ	dddddZ
  ZS ) GeminiNextGenEnvironmentFilesz8Environment files resource backed by the NextGen client.N
sdk_configr   r   Optional[object]r)   c                      t  j||d || _d S r   r   rJ   rH   rI   r   r   r)   r   r2   r3   rJ        
z&GeminiNextGenEnvironmentFiles.__init__c                   r   r<   r   rM   r   r2   r3   r     r   z/GeminiNextGenEnvironmentFiles.with_raw_responsec                   r   r<   r   rM   r   r2   r3   r     r   z5GeminiNextGenEnvironmentFiles.with_streaming_responser   r   r*   c                   r   )BLists directory contents or files inside an environment workspace.r   r   r   r2   r3   r     s   z"GeminiNextGenEnvironmentFiles.listrX   environmentr+   pathrX   rR   bytesc                C  sP   | j std|dr|nd| }|d}| d| d}| j j||dS )<Downloads binary file content from an environment workspace.)api_client is required to download files.environments/r,   /files/
?alt=mediar   )rH   AttributeError
startswithlstripdownload_filerI   r   r   rX   env_name
clean_pathdownload_pathr2   r2   r3   download  s   
z&GeminiNextGenEnvironmentFiles.downloadNNr   r   r   r   r)   r   r   r   r+   r   r+   rX   rR   r*   r   rO   rP   rQ   r   rJ   r   r   r   r   r   r  r   r2   r2   r   r3   r         		r   c                      r   ) "AsyncGeminiNextGenEnvironmentFilesz>Async environment files resource backed by the NextGen client.Nr   r   r   r   r)   c                   r   r   r   r   r   r2   r3   rJ   2  r   z+AsyncGeminiNextGenEnvironmentFiles.__init__c                   r   r<   r   rM   r   r2   r3   r   <  r   z4AsyncGeminiNextGenEnvironmentFiles.with_raw_responsec                   r   r<   r   rM   r   r2   r3   r   @  r   z:AsyncGeminiNextGenEnvironmentFiles.with_streaming_responser   r   r*   c                   s"   t t jg|R i |I dH S )r   Nr   r   r   r2   r3   r   D  s    z'AsyncGeminiNextGenEnvironmentFiles.listr   r   r+   r   rX   rR   r   c                  sX   | j std|dr|nd| }|d}| d| d}| j j||dI dH S )r   r  r  r,   r  r  r   N)rH   r  r  r  async_download_filer	  r2   r2   r3   r  H  s   
z+AsyncGeminiNextGenEnvironmentFiles.downloadr  r  r   r  r  r2   r2   r   r3   r  /  r  r  c                         e Zd ZU dZded< d" fddZd#d
dZes]e fddZ	e fddZ
d$ fddZd$ddZd$ fddZd$ddZd$ fddZd$ddZd$ fddZd$d d!Z  ZS   ZS )%GeminiNextGenEnvironmentsz:Public environments resource backed by the NextGen client.r   filesr)   r   c                   $   || _ t|}t j|j|d d S r   )rH   r~   r   rJ   r   r   r   r2   r3   rJ   d     z"GeminiNextGenEnvironments.__init__r*   rG   c                 C     t | j| j| jd| _d S N)r   r)   )r   r   r   rH   r  rM   r2   r2   r3   
_init_sdksi  
   z$GeminiNextGenEnvironments._init_sdksc                   r   r<   r   rM   r   r2   r3   r   q  r   z+GeminiNextGenEnvironments.with_raw_responsec                   r   r<   r   rM   r   r2   r3   r   u  r   z1GeminiNextGenEnvironments.with_streaming_responser   r   c                   r   r<   )r   r   create_environmentr   r   r2   r3   r  y  r   z,GeminiNextGenEnvironments.create_environmentc                 O     | j |i |S r<   r  r   r2   r2   r3   r   |     z GeminiNextGenEnvironments.createc                   r   r<   )r   r   list_environmentsr   r   r2   r3   r"    r   z+GeminiNextGenEnvironments.list_environmentsc                 O  r  r<   r"  r   r2   r2   r3   r     r!  zGeminiNextGenEnvironments.listc                   r   r<   )r   r   get_environmentr   r   r2   r3   r$    r   z)GeminiNextGenEnvironments.get_environmentc                 O  r  r<   r$  r   r2   r2   r3   r     r!  zGeminiNextGenEnvironments.getc                   r   r<   )r   r   delete_environmentr   r   r2   r3   r&    r   z,GeminiNextGenEnvironments.delete_environmentc                 O  r  r<   r&  r   r2   r2   r3   r     r!  z GeminiNextGenEnvironments.deleter   r*   rG   r   rO   rP   rQ   r   __annotations__rJ   r  r   r   r   r   r  r   r"  r   r$  r   r&  r   r   r2   r2   r   r3   r  _  &   
 



r  c                      r  )%AsyncGeminiNextGenEnvironmentsz@Async public environments resource backed by the NextGen client.r  r  r)   r   c                   r  r   )rH   r   r   rJ   r   r   r   r2   r3   rJ     r  z'AsyncGeminiNextGenEnvironments.__init__r*   rG   c                 C  r  r  )r  r   r   rH   r  rM   r2   r2   r3   r    r  z)AsyncGeminiNextGenEnvironments._init_sdksc                   r   r<   r   rM   r   r2   r3   r     r   z0AsyncGeminiNextGenEnvironments.with_raw_responsec                   r   r<   r   rM   r   r2   r3   r     r   z6AsyncGeminiNextGenEnvironments.with_streaming_responser   r   c                   r   r<   )r   r   r  r   r   r2   r3   r    r   z1AsyncGeminiNextGenEnvironments.create_environmentc                      | j |i |I d H S r<   r   r   r2   r2   r3   r        z%AsyncGeminiNextGenEnvironments.createc                   r   r<   )r   r   r"  r   r   r2   r3   r"    r   z0AsyncGeminiNextGenEnvironments.list_environmentsc                   r-  r<   r#  r   r2   r2   r3   r     r.  z#AsyncGeminiNextGenEnvironments.listc                   r   r<   )r   r   r$  r   r   r2   r3   r$    r   z.AsyncGeminiNextGenEnvironments.get_environmentc                   r-  r<   r%  r   r2   r2   r3   r     r.  z"AsyncGeminiNextGenEnvironments.getc                   r   r<   )r   r   r&  r   r   r2   r3   r&    r   z1AsyncGeminiNextGenEnvironments.delete_environmentc                   r-  r<   r'  r   r2   r2   r3   r     r.  z%AsyncGeminiNextGenEnvironments.deleter   r(  r   r)  r2   r2   r   r3   r,    r+  r,  valuec                 C  s|   t | }|d u r
| S t|d}t|}|s| S t|dr"|j|dS t|tr-i ||S | D ]
\}}t||| q1|S )Nsteps
model_copyr   )	_normalize_interaction_shape
_get_value_output_properties_from_stepshasattrr1  r   r>   itemssetattr)r/  
normalizedr0  updatesnameoutput_valuer2   r2   r3   r     s   


r   c                 C  s   t | d}t|tr| S t | d}t|tr|tvrd S t | d}t|ts(g }|r0d|dgng }t| dr@| j|d ddS t| trUi | d|i}|dd  |S t	| d| t| drft	| dd  | S )	Nr0  modeloutputsmodel_outputtypecontentr1  )r0  r>  r2  )
r4  r   r   r+   _LEGACY_LYRIA_MODELSr6  r1  r>   popr8  )r/  r0  r=  r>  r9  r2   r2   r3   r3    s(   







r3  r0  	list[Any]dict[str, Any]c                 C  s  g }d}t | D ]T}t|ddkr nJt|ddkr|r n?qt|d}t|ts.|r- n0qd}t |D ]#}t|ddkrQd}t|d}|t|trM|nd q4|rWd} nq4|r\ nqi }dt |}	|	rl|	|d	< d }
d }d }t | D ]H}t|ddkr n>t|ddkrqvt|d}t|tsqvt |D ]%}t|d}|d
kr|
d u r|}
|dkr|d u r|}|dkr|d u r|}qqv|
d ur|
|d< |d ur||d< |d ur||d< |S )NFrA  
user_inputr?  rB  textTr5   output_textimageaudiovideooutput_imageoutput_audiooutput_video)reversedr4  r   r   appendr+   join)r0  
text_parts
collectingsteprB  should_stopitemrH  r:  rI  rM  rN  rO  content_typer2   r2   r3   r5    sv   





	r5  r;  c                 C  s    t | tr
| |S t| |d S r<   )r   r>   r   rC   )r/  r;  r2   r2   r3   r4  8  s   

r4  c                 c  s.    | ]}|j  D ]
\}}|jp|V  q	qd S r<   )model_fieldsr7  alias)r\   r=  r;  fieldr2   r2   r3   	<genexpr>@  s    r\  zScreate() accepts either request=... or individual body keyword arguments, not both.r   c                 C  sf   t | t }|rtddt| d | d}t|s | S dd |D }i | dd|dgiS )	Nz-create() got unexpected keyword argument(s): z, z<. Use extra_body=... to send additional request body fields.inputc                 S  r[   r2   )_normalize_content_blockr\   rW  r2   r2   r3   r^   ]  r_   z*_normalize_create_body.<locals>.<listcomp>rG  r@  )set_CREATE_BODY_KEYSr   rR  sortedr   _is_content_list)r   unknowninput_valuenormalized_contentr2   r2   r3   r   P  s   
r   c                 C  s$   d| v rd| vri | ddiS | S )NrH  rA  r2   r/  r2   r2   r3   r^  a  s   r^  r   c                 C  s$   t | tot| otdd | D S )Nc                 s  s    | ]}t |V  qd S r<   )_is_content_blockr_  r2   r2   r3   r\  l  s    z#_is_content_list.<locals>.<genexpr>)r   r   r   allrg  r2   r2   r3   rc  h  s
   
rc  c                 C  s2   t | tsdS t| rdS d| v sd| v rdS dS )NFrolerB  T)r   r>   _is_step_blockrg  r2   r2   r3   rh  p  s   
rh  c                 C  s   |  ddv S )NrA  >   thoughtrG  r?  function_callfunction_resultfile_search_callgoogle_maps_callurl_context_callfile_search_resultgoogle_maps_resultgoogle_search_callurl_context_resultcode_execution_callgoogle_search_resultmcp_server_tool_callcode_execution_resultmcp_server_tool_result)r   rg  r2   r2   r3   rk  z  s   rk  r   Optional[bool]c                 C  s   t | tr| S |S r<   )r   r   )r/  r   r2   r2   r3   r        
r   c                 C  s   t | tr| S d S r<   )r   r+   rg  r2   r2   r3   r     r|  r   r   c                 C  sP   t | tr
| dnt| dd }t |tr|dnt|dd }tt|ddS )Nr   r   Fr   )r   r   r   rC   r   r   )r   r   r   r2   r2   r3   r     s   

r   )r)   r   r*   r+   )r)   r   r*   r;   )r)   r   r*   r@   )r)   r   r*   rR   )rX   r   r*   r   r<   )r)   r   r6   r@   r*   r   )r)   r   r6   r@   r*   r   )r/  r   r*   r   )r/  r   r*   rR   )r0  rE  r*   rF  )r/  r   r;  r+   r*   r   )r   rF  r*   rF  )r/  rF  r*   rF  )r/  r   r*   r   )r/  rF  r*   r   )r/  r   r   r{  r*   r{  )r/  r   r*   r@   )r   r   r*   r   )mr   
__future__r   typingr   r   r   r   r   r   r	   httpx_hooks.google_genai_authr   _GOOGLE_GENAI_API_REVISIONr   agentsr   GeneratedAsyncAgentsr   GeneratedAgentsr   r   GeneratedAsyncInteractionsr   GeneratedInteractionslib.compat_errorsr   r   r   r   r   r   r   r}   r   r   typesr   types.securityr   utilsr   r   r   triggersr    GeneratedAsyncTriggersr!   GeneratedTriggerswebhooksr"   GeneratedAsyncWebhooksr#   GeneratedWebhooksr$   GeneratedAsyncEnvironmentsr%   GeneratedEnvironmentsr  r&   GeneratedAsyncFilesr'   GeneratedFiles	frozensetrC  r(   r4   r:   r?   rE   rF   rV   rc   rd   re   rf   rm   rr   r~   r   r   r   r   r   r   r   r   r   r   r  r  r,  r   r3  r5  r4  CreateModelInteractionCreateAgentInteractionra  r   r   r^  rc  rh  rk  r   r   r   r2   r2   r2   r3   <module>   s   $$	





/ " ,(#0*003
3


D






