
    OjC                        S SK r S SKrS SKJrJrJr  S SKrS SKrSSK	J
r
  SSKJr  SSKJr  SSKJrJr  SSKJrJr  SS	KJrJr  SS
KJrJ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$J%r%  SSK&J'r'J(r(  SSK)J*r*J+r+  SSK,J-r-J.r.J/r/  S SK0r0SSK1J2r2  SSK3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;  SSK<J=r>  SSK<J?r@  SqA " S S5      rB " S S\R                  5      rD " S S5      rEg)    N)AnyOptionalUnion   )BaseApiClient)get_base_url)ReplayApiClient)AsyncBatchesBatches)AsyncCachesCaches)
AsyncChatsChats)AsyncFileSearchStoresFileSearchStores)
AsyncFilesFiles)	AsyncLive)AsyncModelsModels)AsyncOperations
Operations)AsyncTokensTokens)AsyncTuningsTunings)HttpOptionsHttpOptionsDictHttpRetryOptions)_common)AsyncGeminiNextGenAgentsAsyncGeminiNextGenInteractionsAsyncGeminiNextGenWebhooksGeminiNextGenAgentsGeminiNextGenInteractionsGeminiNextGenWebhooksbuild_google_genai_async_clientbuild_google_genai_client)
AsyncGenAI)GenAIFc                      \ rS rSrSrS\4S jr\S\4S j5       r	\S\
4S j5       r\S\4S j5       r\S\4S	 j5       r\S\4S
 j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\ 4S j5       r!\S\"4S j5       r#SS jr$SS jr%S\&S\&SS4S jr'SS jr(Sr)g)AsyncClient:   z7Client for making asynchronous (non-blocking) requests.
api_clientc                    Xl         [        U R                   5      U l        [        U R                   5      U l        [        U R                   5      U l        [        U R                   5      U l        [        U R                   5      U l
        [        U R                   5      U l        [        U R                   5      U l        [        U R                   5      U l        [#        U R                   5      U l        S U l        S U l        S U l        S U l        g N)_api_clientr   _modelsr   _tuningsr   _cachesr
   _batchesr   _filesr   _file_search_storesr   _liver   _tokensr   _operations_nextgen_client_instance_agents_interactions	_webhooks)selfr.   s     U/var/www/html/leaf-doctor-v1/venv/lib/python3.13/site-packages/google/genai/client.py__init__AsyncClient.__init__=   s    !t//0DL !1!12DMt//0DL !1!12DMT--.DK4T5E5EFD4++,DJt//0DL&t'7'78DEID!7;DLCGD;?DN    returnc                 h    U R                   c  [        U R                  5      U l         U R                   $ r0   )r;   r'   r1   r?   s    r@   _nextgen_clientAsyncClient._nextgen_clientN   s2    $$,&E


'd# (((rC   c                 h    U R                   c  [        U R                  5      U l         U R                   $ r0   )r=   r"   r1   rF   s    r@   interactionsAsyncClient.interactionsV   s-    !9$:J:JKdrC   c                 h    U R                   c  [        U R                  5      U l         U R                   $ r0   )r>   r#   r1   rF   s    r@   webhooksAsyncClient.webhooks\   s(    ~~1$2B2BCdn>>rC   c                     [         (       d  Sq [        R                  " S[        SS9  U R                  c  [        U R                  5      U l        U R                  $ )NT?Agents usage is experimental and may change in future versions.r   category
stacklevel)_agent_experimental_warnedwarningswarnUserWarningr<   r!   r1   rF   s    r@   agentsAsyncClient.agentsb   sM     &%#' mm
K
 ||-d.>.>?dl<<rC   c                     U R                   $ r0   r2   rF   s    r@   modelsAsyncClient.modelsp       <<rC   c                     U R                   $ r0   r3   rF   s    r@   tuningsAsyncClient.tuningst       ==rC   c                     U R                   $ r0   r4   rF   s    r@   cachesAsyncClient.cachesx   r^   rC   c                     U R                   $ r0   r7   rF   s    r@   file_search_storesAsyncClient.file_search_stores|       ###rC   c                     U R                   $ r0   r5   rF   s    r@   batchesAsyncClient.batches   rc   rC   c                 (    [        U R                  S9$ N)modules)r   r\   rF   s    r@   chatsAsyncClient.chats   s    dkk**rC   c                     U R                   $ r0   r6   rF   s    r@   filesAsyncClient.files       ;;rC   c                     U R                   $ r0   )r8   rF   s    r@   liveAsyncClient.live   s    ::rC   c                     U R                   $ r0   r9   rF   s    r@   auth_tokensAsyncClient.auth_tokens   r^   rC   c                     U R                   $ r0   r:   rF   s    r@   
operationsAsyncClient.operations       rC   Nc                 T   #    U R                   R                  5       I Sh  vN   g N7f)a  Closes the async client explicitly.

However, it doesn't close the sync client, which can be closed using the
Client.close() method or using the context manager.

Usage:
.. code-block:: python

  from google.genai import Client

  async_client = Client(
      vertexai=True, project='my-project-id', location='us-central1'
  ).aio
  response_1 = await async_client.models.generate_content(
      model='gemini-2.0-flash',
      contents='Hello World',
  )
  response_2 = await async_client.models.generate_content(
      model='gemini-2.0-flash',
      contents='Hello World',
  )
  # Close the client to release resources.
  await async_client.aclose()
N)r1   acloserF   s    r@   r   AsyncClient.aclose   s     2 


!
!
###s   (&(c                    #    U $ 7fr0    rF   s    r@   
__aenter__AsyncClient.__aenter__   s
     Ks   argskwargsc                 D   #    AAU R                  5       I S h  vN   g  N7fr0   )r   r?   r   r   s      r@   	__aexit__AsyncClient.__aexit__   s     f
++-s     c                      [         R                  " 5       R                  U R                  5       5        g ! [         a     g f = fr0   )asyncioget_running_loopcreate_taskr   	ExceptionrF   s    r@   __del__AsyncClient.__del__   s6     ,,T[[]; 
s   25 
AA)r<   r1   r5   r4   r7   r6   r=   r8   r2   r;   r:   r9   r3   r>   rD   N)rD   r,   )*__name__
__module____qualname____firstlineno____doc__r   rA   propertyAsyncGeminiNextGenAPIrG   r"   rJ   r#   rM   r!   rX   r   r\   r   ra   r   rf   r   rj   r
   ro   r   rt   r   rx   r   r|   r   r   r   r   r   r   r   r   r   __static_attributes__r   rC   r@   r,   r,   :   s   ?@ @" )4 ) ) :  
 2  
 .   k   |   k   $"7 $ $ |   +Z + + Z   I   ;   /  $63 # $ rC   r,   c                       \ rS rSr% Sr\R                  " S S9r\\	   \
S'   \R                  " S S9r\\	   \
S'   \R                  " S S9r\\	   \
S	'   S
rg)DebugConfig   zGConfiguration options that change client network behavior when testing.c                  0    [         R                  " SS 5      $ )NGOOGLE_GENAI_CLIENT_MODEosgetenvr   rC   r@   <lambda>DebugConfig.<lambda>   s    bii(BDIrC   )default_factoryclient_modec                  0    [         R                  " SS 5      $ )NGOOGLE_GENAI_REPLAYS_DIRECTORYr   r   rC   r@   r   r      s    bii(H$OrC   replays_directoryc                  0    [         R                  " SS 5      $ )NGOOGLE_GENAI_REPLAY_IDr   r   rC   r@   r   r      s    bii(@$GrC   	replay_idr   N)r   r   r   r   r   pydanticFieldr   r   str__annotations__r   r   r   r   rC   r@   r   r      s^    O'~~I +x}  &.^^O&Xc]  &^^G)Xc] rC   r   c                      \ rS rSrSrSSSSSSSSS.S\\   S\\   S\\   S\\R                  R                  R                     S	\\   S
\\   S\\   S\\\\4      4S jjr\       S&S\\   S\\   S\\R                  R                  R                     S	\\   S
\\   S\\   S\\   S\4S jj5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r \S\!4S j5       r"\S\#4S j5       r$\S\%4S j5       r&\S\'4S j5       r(\S\)4S j5       r*\S\+4S j5       r,\S\-4S j5       r.\S\/4S j5       r0\S\4S j5       r1S'S jr2S(S  jr3S!\4S"\4SS4S# jr5S'S$ jr6S%r7g))Client   a  Client for making synchronous requests.

Use this client to make a request to the Gemini Developer API or Gemini
Enterprise Agent Platform (previously Vertex AI API) and then wait for the
response.

To initialize the client, provide the required arguments either directly
or by using environment variables. Gemini API users and Vertex AI users in
`api_key="your-api-key"` or by defining `GOOGLE_API_KEY="your-api-key"` as an
environment variable

Gemini Enterprise Agent Platform API users can provide inputs argument as
`enterprise=True,
project="your-project-id", location="us-central1"` or by defining
`GOOGLE_GENAI_USE_ENTERPRISE=true`, `GOOGLE_CLOUD_PROJECT` and
`GOOGLE_CLOUD_LOCATION` environment variables.

Attributes:
  api_key: The `API key <https://ai.google.dev/gemini-api/docs/api-key>`_ to
    use for authentication. Applies to the Gemini Developer API only.
  enterprise (bool): Indicates whether the client should use the Gemini
    Enterprise Agent Platform endpoints (previously Vertex AI API).
    Defaults to False (uses Gemini Developer API endpoints). When
    `enterprise` and `vertexai` are both set, and they have conflicting
    values, a `ValueError` will be raised.
  vertexai (bool): Legacy flag for `enterprise`.
  credentials: The credentials to use for authentication when calling the
    Gemini Enterprise Agent Platform APIs. Credentials can be obtained from
    environment variables and default credentials. For more information, see
    `Set up Application Default Credentials
    <https://cloud.google.com/docs/authentication/provide-credentials-adc>`_.
    Applies to the Vertex AI API only.
  project: The `Google Cloud project ID
    <https://cloud.google.com/vertex-ai/docs/start/cloud-environment>`_ to use
    for quota. Can be obtained from environment variables (for example,
    ``GOOGLE_CLOUD_PROJECT``). Applies to the Vertex AI API only.
    Find your `Google Cloud project ID
    <https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects>`_.
  location: The `location
    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations>`_
    to send API requests to (for example, ``us-central1``). Can be obtained
    from environment variables. Applies to the Vertex AI API only.
  debug_config: Config settings that control network behavior of the client.
    This is typically used when running test code.
  http_options: Http options to use for the client. These options will be
    applied to all requests made by the client. Example usage: `client =
    genai.Client(http_options=types.HttpOptions(api_version='v1'))`.

Usage for the Gemini Developer API:

.. code-block:: python

  from google import genai

  client = genai.Client(api_key='my-api-key')

Usage for the Gemini Enterprise Agent Platform API:

.. code-block:: python

  from google import genai

  client = genai.Client(
      enterprise=True, project='my-project-id', location='us-central1'
  )
N)
enterprisevertexaiapi_keycredentialsprojectlocationdebug_confighttp_optionsr   r   r   r   r   r   r   r   c          
      h   U=(       d
    [        5       U l        Ub  Ub  X:w  a  [        S5      eUb  UOUn	[        U[        5      (       a  [        S0 UD6n[        U	=(       d    SU5      n
U
(       a  U(       a  Xl        O	[        U
S9nU R                  U	UUUUU R                  US9U l	        [        U R                  5      U l        [        U R                  5      U l        [        U R                  5      U l        [!        U R                  5      U l        [%        U R                  5      U l        [)        U R                  5      U l        [-        U R                  5      U l        [1        U R                  5      U l        [5        U R                  5      U l        SU l        SU l        SU l        SU l        g)a  Initializes the client.

Args:
   enterprise (bool): Indicates whether the client should use the Gemini
     Enterprise Agent Platform endpoints (previously Vertex AI API).
     Defaults to False (uses Gemini Developer API endpoints). When
     `enterprise` and `vertexai` are both set, and they have conflicting
     values, a `ValueError` will be raised.
   vertexai (bool): Legacy flag for `enterprise`.
   api_key (str): The `API key
     <https://ai.google.dev/gemini-api/docs/api-key>`_ to use for
     authentication. Applies to the Gemini Developer API only.
   credentials (google.auth.credentials.Credentials): The credentials to use
     for authentication when calling the Vertex AI APIs. Credentials can be
     obtained from environment variables and default credentials. For more
     information, see `Set up Application Default Credentials
     <https://cloud.google.com/docs/authentication/provide-credentials-adc>`_.
     Applies to the Vertex AI API only.
   project (str): The `Google Cloud project ID
     <https://cloud.google.com/vertex-ai/docs/start/cloud-environment>`_ to
     use for quota. Can be obtained from environment variables (for example,
     ``GOOGLE_CLOUD_PROJECT``). Applies to the Vertex AI API only.
   location (str): The `location
     <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations>`_
     to send API requests to (for example, ``us-central1``). Can be obtained
     from environment variables. Applies to the Vertex AI API only.
   debug_config (DebugConfig): Config settings that control network behavior
     of the client. This is typically used when running test code.
   http_options (Union[HttpOptions, HttpOptionsDict]): Http options to use
     for the client.
NzXenterprise and vertexai flags have conflicting values, please set enterprise value only.F)base_urlr   r   r   r   r   r   r   r   ) r   _debug_config
ValueError
isinstancedictr   r   r   _get_api_clientr1   r,   _aior   r2   r   r3   r   r4   r   r7   r   r5   r   r6   r   r9   r   r:   r;   r<   r=   r>   )r?   r   r   r   r   r   r   r   r   resolved_vertexair   s              r@   rA   Client.__init__  s~   X &6D("6:;Q$ 
 '1&<
(,%% 0<0l-6EH	 ("H5++"''! , D D,,-DI$**+DLD,,-DM$**+DL/0@0@ADD,,-DM(()DK$**+DL!$"2"23D@DD!26DL>BD6:DNrC   rD   c                     U(       a?  UR                   S;   a/  [        UR                   UR                  UR                  U UUUUUS9	$ [	        U UUUUUS9$ )N)recordreplayauto)	moder   r   r   r   r   r   r   r   )r   r   r   r   r   r   )r   r	   r   r   r   r   s          r@   r   Client._get_api_clientm  sv     00 5 
 '' **(::!#
 
 ! rC   c                 h    U R                   c  [        U R                  5      U l         U R                   $ r0   )r;   r(   r1   rF   s    r@   rG   Client._nextgen_client  s2    $$,&?


'd# (((rC   c                 h    U R                   c  [        U R                  5      U l         U R                   $ r0   )r=   r%   r1   rF   s    r@   rJ   Client.interactions  s-    !4T5E5EFdrC   c                 h    U R                   c  [        U R                  5      U l         U R                   $ r0   )r>   r&   r1   rF   s    r@   rM   Client.webhooks  s(    ~~,T-=-=>dn>>rC   c                     [         (       d  Sq [        R                  " S[        SS9  U R                  c  [        U R                  5      U l        U R                  $ )NTrP      rQ   )rT   rU   rV   rW   r<   r$   r1   rF   s    r@   rX   Client.agents  sM     &%#' mmI
 ||()9)9:dl<<rC   c                 (    [        U R                  S9$ rr   )r   r\   rF   s    r@   rt   Client.chats  s    %%rC   c                     U R                   $ r0   )r   rF   s    r@   aio
Client.aio  s    99rC   c                     U R                   $ r0   r[   rF   s    r@   r\   Client.models  r^   rC   c                     U R                   $ r0   r`   rF   s    r@   ra   Client.tunings  rc   rC   c                     U R                   $ r0   re   rF   s    r@   rf   Client.caches  r^   rC   c                     U R                   $ r0   ri   rF   s    r@   rj   Client.file_search_stores  rl   rC   c                     U R                   $ r0   rn   rF   s    r@   ro   Client.batches  rc   rC   c                     U R                   $ r0   rw   rF   s    r@   rx   Client.files  rz   rC   c                     U R                   $ r0   r   rF   s    r@   r   Client.auth_tokens  r^   rC   c                     U R                   $ r0   r   rF   s    r@   r   Client.operations  r   rC   c                 @    U R                   R                  =(       d    S$ )z6Returns whether the client is using the Vertex AI API.F)r1   r   rF   s    r@   r   Client.vertexai  s     $$--rC   c                 8    U R                   R                  5         g)aq  Closes the synchronous client explicitly.

However, it doesn't close the async client, which can be closed using the
Client.aio.aclose() method or using the async context manager.

Usage:
.. code-block:: python

  from google.genai import Client

  client = Client(
      vertexai=True, project='my-project-id', location='us-central1'
  )
  response_1 = client.models.generate_content(
      model='gemini-2.0-flash',
      contents='Hello World',
  )
  response_2 = client.models.generate_content(
      model='gemini-2.0-flash',
      contents='Hello World',
  )
  # Close the client to release resources.
  client.close()
N)r1   closerF   s    r@   r   Client.close  s    2 	rC   c                     U $ r0   r   rF   s    r@   	__enter__Client.__enter__  s    KrC   r   r   c                 (    AAU R                  5         g r0   )r   r   s      r@   __exit__Client.__exit__  s    fJJLrC   c                 F     U R                  5         g ! [         a     g f = fr0   )r   r   rF   s    r@   r   Client.__del__  s"    
jjl 
s    
  )r<   r   r1   r5   r4   r   r7   r6   r=   r2   r;   r:   r9   r3   r>   )NNNNNNNr   )rD   r   )8r   r   r   r   r   r   boolr   googleauthr   Credentialsr   r   r   r   rA   staticmethodr   r   r   GeminiNextGenAPIrG   r%   rJ   r&   rM   r$   rX   r   rt   r,   r   r   r\   r   ra   r   rf   r   rj   r   ro   r   rx   r   r   r   r   r   r   r   r   r   r   r   r   rC   r@   r   r      s'   AL $(!%#CG# $,0DHV; 4.V; 	V;
 }V; FKK33??@V; }V; V; [)V; U;#?@AV;p !%#CG# $,0,0!!}! FKK33??@! }	!
 ! [)! [)! ! !F )/ ) ) 5  
 -  
 )   &U & & ;   f   w   f   $"2 $ $ w   U   6   *   . . .6C 3 4 rC   r   )Fr   r   typingr   r   r   google.authr  r   r1   r   	_base_urlr   _replay_api_clientr	   ro   r
   r   rf   r   r   rt   r   r   rj   r   r   rx   r   r   r|   r   r\   r   r   r   r   r   tokensr   r   ra   r   r   typesr   r   r   rU    r    _gaos.google_genair!   r"   r#   r$   r%   r&   r'   r(   	_gaos.sdkr)   r   r*   r  rT   r,   	BaseModelr   r   r   rC   r@   <module>r     s      	 ' '   & # / * ' $ G $  ' 3 ' * A A  	 	 	 ; 0" D DN($$  u urC   