diff --git a/src/unitxt/ui/load_catalog_data.py b/src/unitxt/ui/load_catalog_data.py index 4990bfc59..7e4f570f1 100644 --- a/src/unitxt/ui/load_catalog_data.py +++ b/src/unitxt/ui/load_catalog_data.py @@ -41,7 +41,8 @@ def get_from_str(template_str): else: templates = set() for item in template_data: - templates.update(get_from_str(item)) + if isinstance(item, str): + templates.update(get_from_str(item)) # templates.add("templates.key_val_with_new_lines") templates_jsons = { template: safe_load_json(get_file_from_item_name(template)) @@ -86,9 +87,9 @@ def is_valid_data(data): ) formats, formats_jsons = get_catalog_items("formats") json_data.update(formats_jsons) - instructions, instructiosn_jsons = get_catalog_items("instructions") - json_data.update(instructiosn_jsons) - return cards_data, json_data, formats, instructions + system_prompts, system_prompts_jsons = get_catalog_items("system_prompts") + json_data.update(system_prompts_jsons) + return cards_data, json_data, formats, system_prompts def check_augmentable(task_name): @@ -140,12 +141,12 @@ def get_catalog_items(items_type): if __name__ == "__main__": - data, jsons, formats, instructions = load_cards_data() + data, jsons, formats, system_prompts = load_cards_data() stuff = { "cards_data": data, "jsons": jsons, "formats": formats, - "instructions": instructions, + "system_prompts": system_prompts, } for bla in stuff: with open(f"{bla}.txt", "w") as file: diff --git a/src/unitxt/ui/run.py b/src/unitxt/ui/run.py index d866c1ae2..4ace0edd3 100644 --- a/src/unitxt/ui/run.py +++ b/src/unitxt/ui/run.py @@ -31,8 +31,8 @@ get_templates, hash_dict, increase_num, - instructions_items, jsons, + system_prompts_items, update_choices_per_task, ) @@ -43,7 +43,7 @@ def run_unitxt_entry( task, dataset, template, - instruction=None, + system_prompt=None, format=None, num_demos=0, augmentor=None, @@ -60,8 +60,8 @@ def run_unitxt_entry( return msg, "", "", config.EMPTY_SCORES_FRAME, config.EMPTY_SCORES_FRAME, "" - if not isinstance(instruction, str): - instruction = None + if not isinstance(system_prompt, str): + system_prompt = None if not isinstance(format, str): format = None if not isinstance(num_demos, int): @@ -75,7 +75,7 @@ def run_unitxt_entry( return run_unitxt( dataset, template, - instruction, + system_prompt, format, num_demos, augmentor, @@ -89,7 +89,7 @@ def run_unitxt_entry( def run_unitxt( dataset, template, - instruction=None, + system_prompt=None, format=None, num_demos=0, augmentor=None, @@ -100,7 +100,7 @@ def run_unitxt( index = index - 1 try: prompts_list, prompt_args = get_prompts( - dataset, template, num_demos, instruction, format, augmentor + dataset, template, num_demos, system_prompt, format, augmentor ) selected_prompt = prompts_list[index] prompt_text = selected_prompt[config.PROMPT_SOURCE_STR] @@ -204,12 +204,12 @@ def display_json_button(element: str): variant="secondary", ) - instructions = gr.Dropdown( - choices=[None, *instructions_items], - label="Instruction", + system_prompts = gr.Dropdown( + choices=[None, *system_prompts_items], + label="System Prompt", scale=5, ) - instructions_js_button = gr.Button( + system_prompts_js_button = gr.Button( config.JSON_BUTTON_TXT, scale=1, size="sm", @@ -321,11 +321,13 @@ def display_json_button(element: str): templates_js_button.click( display_json_button, templates, [tabs, json_intro, element_name, json_viewer] ) - instructions.select(activate_button, outputs=instructions_js_button).then( + system_prompts.select(activate_button, outputs=system_prompts_js_button).then( activate_button, outputs=generate_prompts_button ).then(deactivate_button, outputs=infer_button) - instructions_js_button.click( - display_json_button, instructions, [tabs, json_intro, element_name, json_viewer] + system_prompts_js_button.click( + display_json_button, + system_prompts, + [tabs, json_intro, element_name, json_viewer], ) formats.select(activate_button, outputs=formats_js_button).then( activate_button, outputs=generate_prompts_button @@ -344,7 +346,7 @@ def display_json_button(element: str): tasks, cards, templates, - instructions, + system_prompts, formats, num_shots, augmentors, @@ -374,7 +376,7 @@ def display_json_button(element: str): deactivate_button, outputs=cards_js_button ).then(deactivate_button, outputs=templates_js_button).then( deactivate_button, outputs=formats_js_button - ).then(deactivate_button, outputs=instructions_js_button) + ).then(deactivate_button, outputs=system_prompts_js_button) # GENERATE PROMPT BUTTON LOGIC generate_prompts_button.click( diff --git a/src/unitxt/ui/ui_utils.py b/src/unitxt/ui/ui_utils.py index 04c3c31a0..e13105713 100644 --- a/src/unitxt/ui/ui_utils.py +++ b/src/unitxt/ui/ui_utils.py @@ -12,7 +12,7 @@ from .load_catalog_data import get_catalog_items, load_cards_data logger = get_logger() -data, jsons, formats_items, instructions_items = load_cards_data() +data, jsons, formats_items, system_prompts_items = load_cards_data() def conditionally_activate_button(conditional_element, button): @@ -39,13 +39,13 @@ def safe_add(parameter, key, args): @lru_cache -def get_prompts(dataset, template, num_demos, instruction, format, augmentor): +def get_prompts(dataset, template, num_demos, system_prompt, format, augmentor): prompt_args = {"card": dataset, "template": template, config.LOADER_LIMIT_STR: 300} if num_demos != 0: prompt_args.update( {"num_demos": num_demos, "demos_pool_size": config.DEMOS_POOL_SIZE} ) - safe_add(instruction, "instruction", prompt_args) + safe_add(system_prompt, "system_prompt", prompt_args) safe_add(format, "format", prompt_args) safe_add(augmentor, "augmentor", prompt_args)