§
    }Štj¾  ã                   ó¼   — d Z ddlmZ ddlmZ e G d„ d¦  «        ¦   «         Zdee         deeeef                  fd„Z	d	eeeef                  dee         fd
„Z
dS )zíEvaluation results utilities for the `.eval_results/*.yaml` format.

See https://huggingface.co/docs/hub/eval-results for more details.
Specifications are available at https://github.com/huggingface/hub-docs/blob/main/eval_results.yaml.
é    )Ú	dataclass)ÚAnyc                   óÚ   — e Zd ZU dZeed<   eed<   eed<   dZedz  ed<   dZedz  ed<   dZ	edz  ed<   dZ
edz  ed	<   dZedz  ed
<   dZedz  ed<   dZedz  ed<   dZedz  ed<   dd„ZdS )ÚEvalResultEntrya
  
    Evaluation result entry for the `.eval_results/*.yaml` format.

    Represents evaluation scores stored in model repos that automatically appear on
    the model page and the benchmark dataset's leaderboard.

    For the legacy `model-index` format in `README.md`, use [`EvalResult`] instead.

    See https://huggingface.co/docs/hub/eval-results for more details.

    Args:
        dataset_id (`str`):
            Benchmark dataset ID from the Hub. Example: "cais/hle", "Idavidrein/gpqa".
        task_id (`str`):
            Task identifier within the benchmark. Example: "gpqa_diamond".
        value (`Any`):
            The metric value. Example: 20.90.
        dataset_revision (`str`, *optional*):
            Git SHA of the benchmark dataset.
        verify_token (`str`, *optional*):
            A signature that can be used to prove that evaluation is provably auditable and reproducible.
        date (`str`, *optional*):
            When the evaluation was run (ISO-8601 datetime). Defaults to git commit time.
        source_url (`str`, *optional*):
            Link to the evaluation source (e.g., https://huggingface.co/spaces/SaylorTwift/smollm3-mmlu-pro). Required if `source_name`, `source_user`, or `source_org` is provided.
        source_name (`str`, *optional*):
            Display name for the source. Example: "Eval Logs".
        source_user (`str`, *optional*):
            HF user name for attribution. Example: "celinah".
        source_org (`str`, *optional*):
            HF org name for attribution. Example: "cais".
        notes (`str`, *optional*):
            Details about the evaluation setup. Example: "tools", "no-tools", "chain-of-thought".

    Example:
        ```python
        >>> from huggingface_hub import EvalResultEntry
        >>> # Minimal example with required fields only
        >>> result = EvalResultEntry(
        ...     dataset_id="Idavidrein/gpqa",
        ...     task_id="gpqa_diamond",
        ...     value=0.412,
        ... )
        >>> # Full example with all fields
        >>> result = EvalResultEntry(
        ...     dataset_id="cais/hle",
        ...     task_id="default",
        ...     value=20.90,
        ...     dataset_revision="5503434ddd753f426f4b38109466949a1217c2bb",
        ...     verify_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
        ...     date="2025-01-15T10:30:00Z",
        ...     source_url="https://huggingface.co/datasets/cais/hle",
        ...     source_name="CAIS HLE",
        ...     source_org="cais",
        ...     notes="no-tools",
        ... )

        ```
    Ú
dataset_idÚtask_idÚvalueNÚdataset_revisionÚverify_tokenÚdateÚ
source_urlÚsource_nameÚsource_userÚ
source_orgÚnotesÚreturnc                 ó`   — | j         €| j        €| j        �| j        €t	          d¦  «        ‚d S d S )NzaIf `source_name`, `source_user`, or `source_org` is provided, `source_url` must also be provided.)r   r   r   r   Ú
ValueError)Úselfs    ú[/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/huggingface_hub/_eval_results.pyÚ__post_init__zEvalResultEntry.__post_init__U   sI   € àÔÐ(¨DÔ,<Ð,HÈDÌOÐLgØŒoÐ%ÝØsñô ð ð &Ð%ð MhÐLgó    )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__r   r
   r   r   r   r   r   r   r   r   © r   r   r   r      só   € € € € € € ð:ð :ðx €O€O�OØ€L€L�LØ€J€J�JØ#'Ð�c˜D‘jÐ'Ð'Ñ'Ø#€L�#˜‘*Ð#Ð#Ñ#Ø€Dˆ#�‰*ÐÐÑØ!€J��d‘
Ð!Ð!Ñ!Ø"€K��t‘Ð"Ð"Ñ"Ø"€K��t‘Ð"Ð"Ñ"Ø!€J��d‘
Ð!Ð!Ñ!Ø€Eˆ3�‰:ÐÐÑðð ð ð ð ð r   r   Úentriesr   c                 óˆ  — g }| D ]¼}|j         |j        dœ}|j        �
|j        |d<   ||j        dœ}|j        �
|j        |d<   |j        �
|j        |d<   |j        �Ad|j        i}|j        �
|j        |d<   |j        �
|j        |d	<   |j	        �
|j	        |d
<   ||d<   |j
        �
|j
        |d<   |                     |¦  «         Œ½|S )aÑ  Convert a list of [`EvalResultEntry`] objects to a YAML-serializable list of dicts.

    This produces the format expected in `.eval_results/*.yaml` files.

    Args:
        entries (`list[EvalResultEntry]`):
            List of evaluation result entries to serialize.

    Returns:
        `list[dict[str, Any]]`: A list of dictionaries ready to be dumped to YAML.

    Example:
        ```python
        >>> from huggingface_hub import EvalResultEntry, eval_result_entries_to_yaml
        >>> entries = [
        ...     EvalResultEntry(dataset_id="cais/hle", task_id="default", value=20.90),
        ...     EvalResultEntry(dataset_id="Idavidrein/gpqa", task_id="gpqa_diamond", value=0.412),
        ... ]
        >>> yaml_data = eval_result_entries_to_yaml(entries)
        >>> yaml_data[0]
        {'dataset': {'id': 'cais/hle', 'task_id': 'default'}, 'value': 20.9}

        ```

        To upload eval results to the Hub:
        ```python
        >>> import yaml
        >>> from huggingface_hub import upload_file, EvalResultEntry, eval_result_entries_to_yaml
        >>> entries = [
        ...     EvalResultEntry(dataset_id="cais/hle", task_id="default", value=20.90),
        ... ]
        >>> yaml_content = yaml.dump(eval_result_entries_to_yaml(entries))
        >>> upload_file(
        ...     path_or_fileobj=yaml_content.encode(),
        ...     path_in_repo=".eval_results/hle.yaml",
        ...     repo_id="your-username/your-model",
        ... )

        ```
    )Úidr   NÚrevision)Údatasetr	   ÚverifyTokenr   ÚurlÚnameÚuserÚorgÚsourcer   )r   r   r
   r	   r   r   r   r   r   r   r   Úappend)r    ÚresultÚentryr$   Údatar*   s         r   Úeval_result_entries_to_yamlr/   ^   s  € ðR €FØð ð ˆà).Ô)9ÀeÄmÐ"TÐ"TˆØÔ!Ð-Ø"'Ô"8ˆG�JÑà+2¸U¼[ÐIÐIˆØÔÐ)Ø"'Ô"4ˆD�ÑØŒ:Ð!Ø œ:ˆD�‰LàÔÐ'Ø&+¨UÔ-=Ð%>ˆFØÔ Ð,Ø!&Ô!2��v‘ØÔ Ð,Ø!&Ô!2��v‘ØÔÐ+Ø %Ô 0��u‘Ø#ˆD�‰NØŒ;Ð"Ø!œKˆD�‰Mà�Š�dÑÔÐÐØ€Mr   r.   c                 ón  — g }| D �].}|                      d|¦  «        }|                      di ¦  «        }|                      di ¦  «        }t          |d         |d         |d         |                      d¦  «        |                      d¦  «        |                      d	¦  «        |r|                      d
¦  «        nd|r|                      d¦  «        nd|r|                      d¦  «        nd|r|                      d¦  «        nd|                      d¦  «        ¬¦  «        }|                     |¦  «         �Œ0|S )a€  Parse a list of dicts into [`EvalResultEntry`] objects.

    This parses the `.eval_results/*.yaml` format. For the legacy `model-index` format,
    use [`model_index_to_eval_results`] instead.

    Args:
        data (`list[dict[str, Any]]`):
            A list of dictionaries (e.g., parsed from YAML or API response).

    Returns:
        `list[EvalResultEntry]`: A list of evaluation result entry objects.

    Example:
        ```python
        >>> from huggingface_hub import parse_eval_result_entries
        >>> data = [
        ...     {"dataset": {"id": "cais/hle", "task_id": "default"}, "value": 20.90},
        ...     {"dataset": {"id": "Idavidrein/gpqa", "task_id": "gpqa_diamond"}, "value": 0.412},
        ... ]
        >>> entries = parse_eval_result_entries(data)
        >>> entries[0].dataset_id
        'cais/hle'
        >>> entries[0].value
        20.9

        ```
    r.   r$   r*   r"   r	   r   r#   r%   r   r&   Nr'   r(   r)   r   )r   r	   r   r
   r   r   r   r   r   r   r   )Úgetr   r+   )r.   r    ÚitemÚ
entry_datar$   r*   r-   s          r   Úparse_eval_result_entriesr4   ¤   s8  € ð8 €GØð ñ ˆØ—X’X˜f dÑ+Ô+ˆ
Ø—.’. ¨BÑ/Ô/ˆØ—’ ¨"Ñ-Ô-ˆÝØ˜t”}Ø˜WÔ%Ø˜IÔ&Ø$Ÿ[š[¨Ñ4Ô4Ø#Ÿš¨Ñ6Ô6Ø—’ Ñ'Ô'Ø,2Ð<�v—z’z %Ñ(Ô(Ð(¸Ø.4Ð>˜Ÿ
š
 6Ñ*Ô*Ð*¸$Ø.4Ð>˜Ÿ
š
 6Ñ*Ô*Ð*¸$Ø,2Ð<�v—z’z %Ñ(Ô(Ð(¸Ø—.’. Ñ)Ô)ð
ñ 
ô 
ˆð 	�Š�uÑÔÐÑØ€Nr   N)r   Údataclassesr   Útypingr   r   ÚlistÚdictr   r/   r4   r   r   r   ú<module>r9      sì   ððð ð "Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð ð ðOð Oð Oð Oð Oñ Oô Oñ „ðOðdC¨¨oÔ)>ð CÀ4ÈÈSÐRUÈXÌÔCWð Cð Cð Cð CðL/ D¨¨c°3¨h¬Ô$8ð /¸TÀ/Ô=Rð /ð /ð /ð /ð /ð /r   