o
    Zh&                     @   s   d dl Z d dlmZmZ 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mZ ddlmZmZ ddlmZmZ dd	lmZmZ dd
lmZ ddlmZmZ ddlmZm Z  ddl!m"Z"m#Z# G dd dZ$G dd dej%Z&G dd dZ'dS )    N)OptionalUnion   )BaseApiClientHttpOptionsHttpOptionsDict)ReplayApiClient)AsyncBatchesBatches)AsyncCachesCaches)
AsyncChatsChats)
AsyncFilesFiles)	AsyncLive)AsyncModelsModels)AsyncOperations
Operations)AsyncTuningsTuningsc                   @   s   e Zd ZdZdefddZedefddZede	fdd	Z
edefd
dZedefddZedefddZedefddZedefddZedefddZdS )AsyncClientz7Client for making asynchronous (non-blocking) requests.
api_clientc                 C   s^   || _ t| j | _t| j | _t| j | _t| j | _t	| j | _
t| j | _t| j | _d S N)_api_clientr   _modelsr   _tuningsr   _cachesr	   _batchesr   _filesr   _liver   _operations)selfr    r$   J/var/www/html/lang_env/lib/python3.10/site-packages/google/genai/client.py__init__%   s   zAsyncClient.__init__returnc                 C      | j S r   r   r#   r$   r$   r%   models0      zAsyncClient.modelsc                 C   r(   r   r   r*   r$   r$   r%   tunings4   r,   zAsyncClient.tuningsc                 C   r(   r   r   r*   r$   r$   r%   caches8   r,   zAsyncClient.cachesc                 C   r(   r   r   r*   r$   r$   r%   batches<   r,   zAsyncClient.batchesc                 C      t | jdS N)modules)r   r+   r*   r$   r$   r%   chats@      zAsyncClient.chatsc                 C   r(   r   r    r*   r$   r$   r%   filesD   r,   zAsyncClient.filesc                 C   r(   r   )r!   r*   r$   r$   r%   liveH   r,   zAsyncClient.livec                 C   r(   r   r"   r*   r$   r$   r%   
operationsL   r,   zAsyncClient.operationsN)__name__
__module____qualname____doc__r   r&   propertyr   r+   r   r.   r   r0   r	   r2   r   r6   r   r9   r   r:   r   r<   r$   r$   r$   r%   r   "   s&    r   c                   @   sf   e Zd ZU dZejdd dZee e	d< ejdd dZ
ee e	d< ejdd dZee e	d	< d
S )DebugConfigzGConfiguration options that change client network behavior when testing.c                   C      t dd S )NZGOOGLE_GENAI_CLIENT_MODEosgetenvr$   r$   r$   r%   <lambda>T       zDebugConfig.<lambda>)default_factoryclient_modec                   C   rC   )NZGOOGLE_GENAI_REPLAYS_DIRECTORYrD   r$   r$   r$   r%   rG   X   rH   replays_directoryc                   C   rC   )NZGOOGLE_GENAI_REPLAY_IDrD   r$   r$   r$   r%   rG   \   rH   	replay_idN)r=   r>   r?   r@   pydanticFieldrJ   r   str__annotations__rK   rL   r$   r$   r$   r%   rB   P   s   
 rB   c                   @   sp  e Zd ZdZdddddddddee dee deejj	j
 dee dee d	ee d
eeeef  fddZe							d"dee dee deejj	j
 dee dee d	ee d
ee fddZedefddZedefddZedefddZedefddZedefddZedefddZedefddZ ede!fddZ"edefd d!Z#dS )#Clienta`
  Client for making synchronous requests.

  Use this client to make a request to the Gemini Developer API or 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
  express mode can provide API key by providing input argument
  `api_key="your-api-key"` or by defining `GOOGLE_API_KEY="your-api-key"` as an
  environment variable

  Vertex AI API users can provide inputs argument as `vertexai=True,
  project="your-project-id", location="us-central1"` or by defining
  `GOOGLE_GENAI_USE_VERTEXAI=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.
    vertexai: Indicates whether the client should use the Vertex AI
      API endpoints. Defaults to False (uses Gemini Developer API endpoints).
      Applies to the Vertex AI API only.
    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: 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: 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 Vertex AI API:

  .. code-block:: python

    from google import genai

    client = genai.Client(
        vertexai=True, project='my-project-id', location='us-central1'
    )
  Nvertexaiapi_keycredentialsprojectlocationdebug_confighttp_optionsrS   rT   rU   rV   rW   rX   rY   c             	   C   s   |pt  | _| j|||||| j|d| _t| j| _t| j| _t| j| _	t
| j| _t| j| _t| j| _t| j| _dS )a{  Initializes the client.

    Args:
       vertexai (bool): Indicates whether the client should use the Vertex AI
         API endpoints. Defaults to False (uses Gemini Developer API endpoints).
         Applies to the Vertex AI API only.
       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.
    rR   N)rB   Z_debug_config_get_api_clientr   r   _aior   r   r   r   r   r   r
   r   r   r    r   r"   )r#   rS   rT   rU   rV   rW   rX   rY   r$   r$   r%   r&      s"   (
zClient.__init__c                 C   sB   |r|j dv rt|j |j|j| |||||d	S t| |||||dS )N)recordZreplayauto)	moderL   rK   rS   rT   rU   rV   rW   rY   )rS   rT   rU   rV   rW   rY   )rJ   r   rL   rK   r   rR   r$   r$   r%   rZ      s(   
zClient._get_api_clientr'   c                 C   r3   r4   )r   r+   r*   r$   r$   r%   r6      r7   zClient.chatsc                 C   r(   r   )r[   r*   r$   r$   r%   aio   r,   z
Client.aioc                 C   r(   r   r)   r*   r$   r$   r%   r+     r,   zClient.modelsc                 C   r(   r   r-   r*   r$   r$   r%   r.     r,   zClient.tuningsc                 C   r(   r   r/   r*   r$   r$   r%   r0     r,   zClient.cachesc                 C   r(   r   r1   r*   r$   r$   r%   r2     r,   zClient.batchesc                 C   r(   r   r8   r*   r$   r$   r%   r9     r,   zClient.filesc                 C   r(   r   r;   r*   r$   r$   r%   r<     r,   zClient.operationsc                 C   s   | j jpdS )z6Returns whether the client is using the Vertex AI API.F)r   rS   r*   r$   r$   r%   rS     s   zClient.vertexai)NNNNNNN)$r=   r>   r?   r@   r   boolrO   googleauthrU   CredentialsrB   r   r   r   r&   staticmethodrZ   rA   r   r6   r   r_   r   r+   r   r.   r   r0   r
   r2   r   r9   r   r<   rS   r$   r$   r$   r%   rQ   `   s    >	
<#rQ   )(rE   typingr   r   Zgoogle.authra   rM   r   r   r   r   Z_replay_api_clientr   r2   r	   r
   r0   r   r   r6   r   r   r9   r   r   r:   r   r+   r   r   r<   r   r   r.   r   r   r   Z	BaseModelrB   rQ   r$   r$   r$   r%   <module>   s"   .