o
    6ti                     @   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   X/home/ubuntu/.local/lib/python3.10/site-packages/lm_eval/tasks/afrobench/afriqa/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ddd}||  S )NzYour task is to answer a question given a context.Make sure you respond with the shortest span containing the answer in the context.
Question: {{question_lang}}
Context: {{context}}
Answer:zFYour task is to answer a question given a context. The question is in z, while the context is in English or French.Make sure you respond with the shortest span in the context that contains the answer.
Question: {{question_lang}}
Context: {{context}}
Answer:zGiven the context, provide the answer to the following question.Ensure your response is concise and directly from the context.
Question: {{question_lang}}
Context: {{context}}
Answer:zYou are an AI assistant and your task is to answer the question based on the provided context.Your answer should be the shortest span that contains the answer within the context.
Question: {{question_lang}}
Context: {{context}}
Answer:zUsing the context, find the answer to the question.Respond with the briefest span that includes the answer from the context.
Question: {{question_lang}}
Context: {{context}}
Answer:prompt_1prompt_2prompt_3prompt_4prompt_5r   )modelang
prompt_mapr   r   r   prompt_func   s   
r   
output_dir	overwriter   returnc                 C   s$  g }ddddddddd	d
d
}|  D ]l}z\d| d}d| d| }d}|||t||| d}	tj| |}
tj|
dd t|  d| d| |rNdnddd}|d tj	|	|dd W d   n1 skw   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.
    BembaFonHausaIgboKinyarwandaSwahiliTwiWolofYorubaZulu)
bemfonhauibokinswatwiwolyorzulafriqa_z.yaml_afriqa)includetaskdataset_namedoc_to_textT)exist_ok/wxutf8)encodingz# Generated by utils.py
)allow_unicodeNr   zJFiles were not created because they already exist (use --overwrite flag): z, )keysr   ospathjoinmakedirsopenwriteyamldumpFileExistsErrorappendlen)r   r   r   err	languagesr   	file_name	task_nameyaml_templateyaml_details	file_pathfr   r   r   gen_lang_yamls+   s`   

rN   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./z Directory to write yaml files to)rP   rR   z--moder   r   zPrompt number)rP   choicesrR   )r   r   r   N)argparseArgumentParseradd_argument
parse_argsrN   r   r   r   )parserargsr   r   r   mainc   s(   rZ   __main__)r   N)
rT   r;   rA   r   r   strboolrN   rZ   r   r   r   r   r   <module>   s    
8
