o
    6tii                     @   st   d dl Z d dlZd dlZd dlZdedefddZdd Zded	ed
eddfddZdddZ	e
dkr8e	  dS dS )    Ncodereturnc                 C   s&   t jjdi dt|  | i}|jS )Nalpha_ )	pycountry	languagesgetlenname)r   language_tupler   r   `/home/ubuntu/.local/lib/python3.10/site-packages/lm_eval/tasks/afrobench/uhura-arc-easy/utils.pyget_language_from_code   s    r   c                 C   s   dddddd}||  S )NzYou are a virtual assistant that answers multiple-choice questions with the correct option only.

Question: {{question}}

Choices:

{% for i in range(choices['text']|length) %}	{{ 'ABCD'[i] }}: {{ choices['text'][i] }}
{% endfor %}
Answer: zChoose the correct option that answers the question below:

Question: {{question}}

Choices:

{% for i in range(choices['text']|length) %}	{{ 'ABCD'[i] }}: {{ choices['text'][i] }}
{% endfor %}
Answer: zAnswer the following multiple-choice question by picking 'A', 'B', 'C', or 'D'.

Question: {{question}}

Options:

{% for i in range(choices['text']|length) %}	{{ 'ABCD'[i] }}: {{ choices['text'][i] }}
{% endfor %}
Answer: zQuestion: {{question}}

Options:

{% for i in range(choices['text']|length) %}	{{ 'ABCD'[i] }}: {{ choices['text'][i] }}
{% endfor %}
Answer: zWhich of the following options answers this question: {{question}}

{% for i in range(choices['text']|length) %}	{{ 'ABCD'[i] }}: {{ choices['text'][i] }}
{% endfor %}
Answer: prompt_1prompt_2prompt_3prompt_4prompt_5r   )mode
prompt_mapr   r   r   prompt_func   s   "r   
output_dir	overwriter   c              	   C   s.  g }h d}|D ]|}zld| d}d| d| }d}||| d|dkr&dnd	 t |d
}	|dv r7d|	d< tj| |}
tj|
dd t|  d| d| |rSdnddd}|d tj|	|dd W d   n1 spw   Y  W q t	y   |
| Y qw t|dkrt	dd| dS )z
    Generate a yaml file for each language.

    :param output_dir: The directory to output the files to.
    :param overwrite: Whether to overwrite files if they already exist.
    >   amenhaswyozunsozuhura-arc-easy_z.yaml_zuhura-arc-easy_multiple_choicer   
_unmatched )includetaskdataset_namedoc_to_text)r   r   trainfewshot_splitT)exist_ok/wxutf8)encodingz# Generated by utils.py
)allow_unicodeNr   zJFiles were not created because they already exist (use --overwrite flag): z, )r   ospathjoinmakedirsopenwriteyamldumpFileExistsErrorappendr	   )r   r   r   errr   lang	file_name	task_nameyaml_templateyaml_details	file_pathfr   r   r   gen_lang_yamls3   sP   

rC   c                  C   sp   t  } | jddddd | jdddd	 g d
}| jdd||dd |  }|jD ]}t|j|j|d q*dS )z9Parse CLI args and generate language-specific yaml files.z--overwriteT
store_truez%Overwrite files if they already exist)defaultactionhelpz--output-dirz./z Directory to write yaml files to)rE   rG   r   z--mode*zPrompt number(s))nargsrE   choicesrG   )r   r   r   N)argparseArgumentParseradd_argument
parse_argsr   rC   r   r   )parserPROMPT_CHOICESargsr   r   r   r   mainc   s0   
rR   __main__)r   N)rK   r1   r   r7   strr   r   boolrC   rR   __name__r   r   r   r   <module>   s    &
0
