
    D_i	                    b    S r SSKJr  SSKrSSKJr  SS jr S	         S
S jjrS	SS jjrg)z$Utilities for environment variables.    )annotationsN)Anyc                b    U [         R                  ;   =(       a    [         R                  U    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    R/home/james-whalen/.local/lib/python3.13/site-packages/langchain_core/utils/env.pyenv_var_is_setr   	   s0     bjj  RZZ%8 A &     c                L   [        U[        [        45      (       a.  U H(  nU R                  U5      =n(       d  M  [	        U5      s  $    [        U[        5      (       a  X;   a  X   (       a  [	        X   5      $ [        U[        [        45      (       a  US   OUn[        XbUS9$ )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	49~&sT5M::#a&Kg>>r   c                x    [         R                  " U5      =n(       a  U$ Ub  U$ SU  SU SU  S3n[        U5      e)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   