o
    Zh7                     @   s   d dl mZ d dlmZmZmZmZmZ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mZmZ G dd deZG d	d
 d
eZddee deeef fddZddee ddfddZG dd deZdS )    )metadata)AnyDictListOptionalTuple	TypedDict)
ClientInfo)secret_from_env)	BaseModelField	SecretStr)HarmBlockThresholdHarmCategoryModalityc                   @   s   e Zd ZdZdS )GoogleGenerativeAIErrorzS
    Custom exception class for errors associated with the `Google GenAI` API.
    N)__name__
__module____qualname____doc__ r   r   U/var/www/html/lang_env/lib/python3.10/site-packages/langchain_google_genai/_common.pyr      s    r   c                   @   s  e Zd ZU dZedddZeed< 	 ededdd	d
Z	e
e ed< 	 dZeed< 	 	 	 dZeed< 	 dZe
e ed< 	 dZe
e ed< 	 edddZe
e ed< 	 dZeed< 	 dZeed< 	 dZe
e ed< 	 edddZe
e ed< edddZe
e ed< edddZe
eeef  ed< edd dZe
ee  ed!< dZe
eee f  ed"< 	 e!d#eeef fd$d%Z"e!d#eeef fd&d'Z#dS )(_BaseGoogleGenerativeAIz(Base class for Google Generative AI LLMs.z^The name of the model to use.
Supported examples:
    - gemini-pro
    - models/text-bison-001)descriptionmodelZapi_keyGOOGLE_API_KEYN)default)aliasdefault_factorygoogle_api_keycredentialsgffffff?temperaturetop_ptop_kZ
max_tokens)r   r   max_output_tokens   n   max_retriestimeoutzXA dictionary of client options to pass to the Google API client, such as `api_endpoint`.)r   r   client_optionsz3A string, one of: [`rest`, `grpc`, `grpc_asyncio`].	transportzIA key-value dictionary representing additional headers for the model calladditional_headersz$A list of modalities of the responseresponse_modalitiessafety_settingsreturnc                 C   s   ddiS )Nr   r   r   selfr   r   r   
lc_secrets^   s   z"_BaseGoogleGenerativeAI.lc_secretsc                 C   s   | j | j| j| j| j| jdS )zGet the identifying parameters.)r   r!   r"   r#   r$   Zcandidate_count)r   r!   r"   r#   r$   r&   r0   r   r   r   _identifying_paramsb   s   z+_BaseGoogleGenerativeAI._identifying_params)$r   r   r   r   r   r   str__annotations__r
   r   r   r   r    r   r!   floatr"   r#   intr$   r&   r(   r)   r*   r   r+   r,   r-   r   r   r.   r   r   propertyr2   r3   r   r   r   r   r      sd   
 r   Nmoduler/   c                 C   sL   zt d}W n t jy   d}Y nw | r| d|  n|}|d| fS )zReturns a custom user agent header.

    Args:
        module (Optional[str]):
            Optional. The module for a custom user agent header.
    Returns:
        Tuple[str, str]
    zlangchain-google-genaiz0.0.0-zlangchain-google-genai/)r   versionZPackageNotFoundError)r9   Zlangchain_versionclient_library_versionr   r   r   get_user_agento   s   	r=   r	   c                 C   s   t | \}}t||dS )zReturns a client info object with a custom user agent header.

    Args:
        module (Optional[str]):
            Optional. The module for a custom user agent header.
    Returns:
        google.api_core.gapic_v1.client_info.ClientInfo
    )r<   
user_agent)r=   r	   )r9   r<   r>   r   r   r   get_client_info   s
   	r?   c                   @   s   e Zd ZU eed< eed< dS )SafetySettingDictcategory	thresholdN)r   r   r   r   r5   r   r   r   r   r   r@      s   
 r@   )N)	importlibr   typingr   r   r   r   r   r   Z$google.api_core.gapic_v1.client_infor	   Zlangchain_core.utilsr
   Zpydanticr   r   r   Zlangchain_google_genai._enumsr   r   r   	Exceptionr   r   r4   r=   r?   r@   r   r   r   r   <module>   s      ^