o
    hQ                     @   s   d dl Z d dlZd dlmZmZ d dlmZ ddlmZ ddl	m
Z
 dZdZd	Z		
					
		ddedeeeejf  dedee deeeef  deeeef  dee dededee dee fddZdeddfddZdS )    N)OptionalUnion)version   )cached_file)is_peft_availablezadapter_config.jsonzadapter_model.binzadapter_model.safetensorsF model_id	cache_dirforce_downloadresume_downloadproxiestokenrevisionlocal_files_only	subfolder_commit_hashreturnc
                 C   sh   d}
| du rdS t j| r t | }t|v rt j| t}
|
S t| t|||||||||	dddd}
|
S )a  
    Simply checks if the model stored on the Hub or locally is an adapter model or not, return the path of the adapter
    config file if it is, None otherwise.

    Args:
        model_id (`str`):
            The identifier of the model to look for, can be either a local path or an id to the repository on the Hub.
        cache_dir (`str` or `os.PathLike`, *optional*):
            Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
            cache should not be used.
        force_download (`bool`, *optional*, defaults to `False`):
            Whether or not to force to (re-)download the configuration files and override the cached versions if they
            exist.
        resume_download:
            Deprecated and ignored. All downloads are now resumed by default when possible.
            Will be removed in v5 of Transformers.
        proxies (`Dict[str, str]`, *optional*):
            A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
            'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
        token (`str` or *bool*, *optional*):
            The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
            when running `huggingface-cli login` (stored in `~/.huggingface`).
        revision (`str`, *optional*, defaults to `"main"`):
            The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
            git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
            identifier allowed by git.

            <Tip>

            To test a pull request you made on the Hub, you can pass `revision="refs/pr/<pr_number>".

            </Tip>

        local_files_only (`bool`, *optional*, defaults to `False`):
            If `True`, will only try to load the tokenizer configuration from local files.
        subfolder (`str`, *optional*, defaults to `""`):
            In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
            specify the folder name here.
    NF)r
   r   r   r   r   r   r   r   r    _raise_exceptions_for_gated_repo%_raise_exceptions_for_missing_entries'_raise_exceptions_for_connection_errors)ospathisdirlistdirADAPTER_CONFIG_NAMEjoinr   )r	   r
   r   r   r   r   r   r   r   r   adapter_cached_filenamelist_remote_files r   q/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/transformers/utils/peft_utils.pyfind_adapter_config_file   s2   3
r!   min_versionc                 C   s@   t  stdttjdt| k}|std|  dS )z
    Checks if the version of PEFT is compatible.

    Args:
        version (`str`):
            The version of PEFT to check against.
    z@PEFT is not installed. Please install it with `pip install peft`peftz_The version of PEFT you are using is not compatible, please use a version that is greater than N)r   
ValueErrorr   parse	importlibmetadata)r"   is_peft_version_compatibler   r   r    check_peft_versionl   s   r)   )	NFNNNNFr   N)r&   r   typingr   r   	packagingr   hubr   import_utilsr   r   ADAPTER_WEIGHTS_NAMEADAPTER_SAFE_WEIGHTS_NAMEstrPathLikebooldictr!   r)   r   r   r   r    <module>   sT   	

O