o
    i                  
   @  s   d dl mZ d dlZd dlmZmZ d dlZd dlm	Z	 d dl
mZ d dlmZmZ d dlmZ d dlmZ zd d	lmZ d d
lmZ d dlmZ W n ey[ Z zededZ[ww G dd dee Zed ZdS )    )annotationsN)Literaloverload)ModelProfile)	UserError)cached_async_http_clientget_user_agentgoogle_model_profile)Provider)Credentials)Client)HttpOptionsu   Please install the `google-genai` package to use the Google provider, you can use the `google` optional group — `pip install "pydantic-ai-slim[google]"`c                	   @  s   e Zd ZdZed+ddZed+ddZed,d	d
Zd-ddZe	dddd.ddZ
e	ddddddd/ddZ
e	d0d!dZ
e	d"dddd#d1d&dZ
ddddddddd'd2d*dZ
dS )3GoogleProviderzProvider for Google.returnstrc                 C  s   | j jjrdS dS )Ngoogle-vertex
google-gla)_client_api_clientvertexaiself r   b/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/pydantic_ai/providers/google.pyname   s   zGoogleProvider.namec                 C  s   t | jjjjS N)r   r   r   _http_optionsbase_urlr   r   r   r   r       s   zGoogleProvider.base_urlr   c                 C  s   | j S r   )r   r   r   r   r   client$   s   zGoogleProvider.client
model_nameModelProfile | Nonec                 C  s   t |S r   r	   )r   r    r   r   r   model_profile(   s   zGoogleProvider.model_profileN)http_clientr   api_keyr#   httpx.AsyncClient | Noner   
str | NoneNonec                C     d S r   r   )r   r$   r#   r   r   r   r   __init__+   s   zGoogleProvider.__init__)credentialsprojectlocationr#   r   r*   Credentials | Noner+   r,   1VertexAILocation | Literal['global'] | str | Nonec                C  r(   r   r   )r   r*   r+   r,   r#   r   r   r   r   r)   0   s   	r   c                C  r(   r   r   )r   r   r   r   r   r)   ;   s   F)r   r$   r#   r   r   boolc                C  r(   r   r   )r   r   r$   r#   r   r   r   r   r)   >   s   )r$   r*   r+   r,   r   r   r#   r   bool | NoneClient | Nonec                C  s   |du rl|pt dpt d}t|p|p|}	|du r|	}|p(t|r%dndd}t|dt i|d}
|sG|du r=td	td
||
d| _dS |	rKd}|du r_|pUt d}|p^t dp^d}td|||||
d| _dS || _dS )aI  Create a new Google provider.

        Args:
            api_key: The `API key <https://ai.google.dev/gemini-api/docs/api-key>`_ to
                use for authentication. It can also be set via the `GOOGLE_API_KEY` environment variable.
            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. Applies to the Vertex AI API only.
            project: The Google Cloud project ID 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 to send API requests to (for example, us-central1). Can be obtained from environment variables.
                Applies to the Vertex AI API only.
            vertexai: Force the use of the Vertex AI API. If `False`, the Google Generative Language API will be used.
                Defaults to `False` unless `location`, `project`, or `credentials` are provided.
            client: A pre-initialized client to use.
            http_client: An existing `httpx.AsyncClient` to use for making HTTP requests.
            base_url: The base URL for the Google API.
        NGOOGLE_API_KEYGEMINI_API_KEYr   r   )providerz
User-Agent)r   headershttpx_async_clientzSet the `GOOGLE_API_KEY` environment variable or pass it via `GoogleProvider(api_key=...)`to use the Google Generative Language API.F)r   r$   http_optionsGOOGLE_CLOUD_PROJECTGOOGLE_CLOUD_LOCATIONus-central1T)r   r$   r+   r,   r*   r7   )	osgetenvr/   r   r   r   r   r   r   )r   r$   r*   r+   r,   r   r   r#   r   vertex_ai_args_usedr7   r   r   r   r)   H   sB   

	)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   r&   r   r'   )r$   r&   r*   r-   r+   r&   r,   r.   r   r0   r   r1   r#   r%   r   r&   r   r'   )__name__
__module____qualname____doc__propertyr   r   r   r"   r   r)   r   r   r   r   r      sH    

r   )z
asia-east1z
asia-east2zasia-northeast1zasia-northeast3zasia-south1zasia-southeast1zaustralia-southeast1zeurope-central2zeurope-north1zeurope-southwest1zeurope-west1zeurope-west2zeurope-west3zeurope-west4zeurope-west6zeurope-west8zeurope-west9zme-central1zme-central2zme-west1znorthamerica-northeast1zsouthamerica-east1r:   zus-east1zus-east4zus-east5z	us-south1zus-west1zus-west4)
__future__r   _annotationsr;   typingr   r   httpxpydantic_air   pydantic_ai.exceptionsr   pydantic_ai.modelsr   r   pydantic_ai.profiles.googler
   pydantic_ai.providersr   google.auth.credentialsr   google.genai.clientr   google.genai.typesr   ImportError_import_errorr   VertexAILocationr   r   r   r   <module>   s4    }