o
    5ti                     @   sh   d dl Z d dlZd dlZG d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r2e  dS dS )    Nc                   @   s   e Zd Zdd ZdS )FunctionTagc                 C   s
   || _ d S )N)value)selfr    r   T/home/ubuntu/.local/lib/python3.10/site-packages/lm_eval/tasks/afrimgsm/gen_utils.py__init__   s   
zFunctionTag.__init__N)__name__
__module____qualname__r   r   r   r   r   r      s    r   c                 C   s   dd| dd}||  S )NzAnswer the given question with the step by step solution appropriate numerical value, ensuring that the response is clear and without any supplementary information. 

Question: {{question}} 
Step by step answer: z'For mathematical questions provided in z| language. Supply the accurate step by step answer to the provided question. 

Question: {{question}} 
Step by step answer: )prompt_4prompt_5r   )modelang
prompt_mapr   r   r   prompt_func   s   
r   
output_dir	overwriter   returnc              	   C   s  g }i ddddddddd	d
dddddddddddddddddddddd d!d"d#d$d%}|  D ]}zd&| d'}d&| d(| }d)}d*| d+d, v rld-| d'}d-| d(| }d.}t|d(d, d/kr|||t||| d0}	n|||d1}	tj|  d+| d2d3 t|  d+| d+| |rd4nd5d6d7}
|
d8 tj	|	|
d2d9 W d:   n1 sw   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.
    engEnglishamhAmhariciboIgbofraFrenchsnachiShonawolWolofeweEwelinLingalalugLugandaxhoisiXhosakinKinyarwandatwiTwizulZuluormOromoyorYorubahauHausasotSesothoSwahiliVai)swavaiafrimgsm_cot_z.yaml_afrimgsm_cot_yaml	translate/afrimgsm_cot_translate_afrimgsm_cot_translate_yaml   )includetaskdataset_namedoc_to_text)rC   rD   rE   T)exist_okwxutf8)encodingz# Generated by utils.py
)allow_unicodeNr   zJFiles were not created because they already exist (use --overwrite flag): z, )keyssplitintr   osmakedirsopenwriteyamldumpFileExistsErrorappendlenjoin)r   r   r   err	languagesr   	file_name	task_nameyaml_templateyaml_detailsfr   r   r   gen_lang_yamls   s   	


ra   c                  C   s`   t  } | jddddd | jdddd	 | jd
dg ddd |  }t|j|j|jd 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./translate_cotz Directory to write yaml files to)rc   re   z--moder   )prompt_1prompt_2prompt_3r   r   zPrompt number)rc   choicesre   )r   r   r   N)argparseArgumentParseradd_argument
parse_argsra   r   r   r   )parserargsr   r   r   main`   s(   rp   __main__)r   N)
rj   rP   rT   r   r   strboolra   rp   r   r   r   r   r   <module>   s    

J
