
    g3fi	                    X    d Z ddlmZ ddlZddlmZ ddZ	 d		 	 	 	 	 	 	 	 	 d
dZd	ddZy)z$Utilities for environment variables.    )annotationsN)Anyc                T    | t         j                  v xr t         j                  |    dvS )zCheck if an environment variable is set.

    Args:
        env_var: The name of the environment variable.

    Returns:
        `True` if the environment variable is set, `False` otherwise.
    >    0Falsefalse)osenviron)env_vars    V/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_core/utils/env.pyenv_var_is_setr   	   s0     bjj  RZZ%8 A &     c                    t        |t        t        f      r'|D ]"  }| j                  |      x}st	        |      c S  t        |t              r|| v r| |   rt	        | |         S t        |t        t        f      r|d   n|}t        |||      S )a  Get a value from a dictionary or an environment variable.

    Args:
        data: The dictionary to look up the key in.
        key: The key to look up in the dictionary. This can be a list of keys to try
            in order.
        env_key: The environment variable to look up if the key is not
            in the dictionary.
        default: The default value to return if the key is not in the dictionary
            or the environment.

    Returns:
        The dict value or the environment variable value.
    r   )default)
isinstancelisttuplegetstrget_from_env)datakeyenv_keyr   kvaluekey_for_errs          r   get_from_dict_or_envr      s    ( #e}% 	"A#u#5z!	" #stS	49~&sT5M:#a&KWg>>r   c                j    t        j                  |      x}r|S ||S d|  d| d|  d}t        |      )a  Get a value from a dictionary or an environment variable.

    Args:
        key: The key to look up in the dictionary.
        env_key: The environment variable to look up if the key is not
            in the dictionary.
        default: The default value to return if the key is not in the dictionary
            or the environment.

    Returns:
        The value of the key.

    Raises:
        ValueError: If the key is not in the dictionary and no default value is
            provided or if the environment variable is not set.
    zDid not find z&, please add an environment variable `z` which contains it, or pass `z` as a named parameter.)r
   getenv
ValueError)r   r   r   	env_valuemsgs        r   r   r   ;   s]    " IIg&&y&
u I E(	* 
 S/r   )r   r   returnbool)N)
r   zdict[str, Any]r   zstr | list[str]r   r   r   
str | Noner$   r   )r   r   r   r   r   r&   r$   r   )	__doc__
__future__r   r
   typingr   r   r   r    r   r   <module>r+      sT    * " 	 * 	?
?	? ? 	?
 	?Br   