§
    }Štj>	  ã                   óZ   — d Z ddlZddlZddlmZ ddlmZ erddlmZ ddd	e	d
e	de
fd„ZdS )zz
Helpful utility functions and classes in relation to exploring API endpoints
with the aim for a user-friendly interface.
é    N)ÚTYPE_CHECKINGé   )ÚModelCardData)Ú	ModelInfoÚ
model_infor   Úminimum_thresholdÚmaximum_thresholdÚreturnc                 óÌ  — |€|€t          d¦  «        ‚|€d}|€t          j        }t          | dd¦  «        }|�t	          |t
          t          f¦  «        sdS |                     dd¦  «        }t	          |t
          ¦  «        r|d         }|sdS t          j	        dt          |¦  «        ¦  «        }|€dS t          |                     d	¦  «        ¦  «        }||cxk    o|k    nc S )
aÝ  Checks if a model's emission is within a given threshold.

    Args:
        model_info (`ModelInfo`):
            A model info object containing the model's emission information.
        minimum_threshold (`float`):
            A minimum carbon threshold to filter by, such as 1.
        maximum_threshold (`float`):
            A maximum carbon threshold to filter by, such as 10.

    Returns:
        `bool`: Whether the model's emission is within the given threshold.
    NzFBoth `minimum_threshold` and `maximum_threshold` cannot both be `None`éÿÿÿÿÚ	card_dataFÚco2_eq_emissionsÚ	emissionsz\d+\.\d+|\d+r   )Ú
ValueErrorÚmathÚinfÚgetattrÚ
isinstanceÚdictr   ÚgetÚreÚsearchÚstrÚfloatÚgroup)r   r   r	   r   ÚemissionÚmatchedÚemission_values          úd/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/huggingface_hub/utils/endpoint_helpers.pyÚ_is_emission_within_thresholdr       s  € ð Ð Ð%6Ð%>ÝÐaÑbÔbÐbØÐ ØÐØÐ Ý œHÐå˜
 K°Ñ6Ô6€IØÐ¥
¨9µt½]Ð6KÑ LÔ LÐØˆuð �}Š}Ð/°Ñ6Ô6€HÝ�(�DÑ!Ô!ð )Ø˜KÔ(ˆØð Øˆuõ Œi˜­¨X©¬Ñ7Ô7€GØ€Øˆuå˜7Ÿ=š=¨Ñ+Ô+Ñ,Ô,€NØ ÐCÐCÒCÐCÐ2CÒCÐCÐCÐCÐCó    )Ú__doc__r   r   Útypingr   Úrepocard_datar   Úhf_apir   r   Úboolr    © r!   r   ú<module>r(      s©   ððð ð
 €€€Ø 	€	€	€	Ø  Ð  Ð  Ð  Ð  Ð  à )Ð )Ð )Ð )Ð )Ð )ð ð #Ø"Ð"Ð"Ð"Ð"Ð"ð&D¨kð &DÈeð &DÐhmð &DÐrvð &Dð &Dð &Dð &Dð &Dð &Dr!   