diff --git a/extensions/openai/completions.py b/extensions/openai/completions.py index 646da958..3e277710 100644 --- a/extensions/openai/completions.py +++ b/extensions/openai/completions.py @@ -165,7 +165,7 @@ def messages_to_prompt(body: dict, req_params: dict, max_tokens): # Instruct models can be much better if shared.settings['instruction_template']: try: - instruct = yaml.safe_load(open(f"characters/instruction-following/{shared.settings['instruction_template']}.yaml", 'r')) + instruct = yaml.safe_load(open(f"instruction-templates/{shared.settings['instruction_template']}.yaml", 'r')) template = instruct['turn_template'] system_message_template = "{message}" @@ -193,7 +193,7 @@ def messages_to_prompt(body: dict, req_params: dict, max_tokens): except Exception as e: req_params['stopping_strings'].extend(['\nUser:', 'User:']) # XXX User: prompt here also - print(f"Exception: When loading characters/instruction-following/{shared.settings['instruction_template']}.yaml: {repr(e)}") + print(f"Exception: When loading instruction-templates/{shared.settings['instruction_template']}.yaml: {repr(e)}") print("Warning: Loaded default instruction-following template for model.") else: diff --git a/extensions/openai/edits.py b/extensions/openai/edits.py index f10f5779..2b527dc0 100644 --- a/extensions/openai/edits.py +++ b/extensions/openai/edits.py @@ -31,7 +31,7 @@ def edits(instruction: str, input: str, temperature=1.0, top_p=1.0) -> dict: stopping_strings.extend(['\n###']) else: try: - instruct = yaml.safe_load(open(f"characters/instruction-following/{shared.settings['instruction_template']}.yaml", 'r')) + instruct = yaml.safe_load(open(f"instruction-templates/{shared.settings['instruction_template']}.yaml", 'r')) template = instruct['turn_template'] template = template\ @@ -45,7 +45,7 @@ def edits(instruction: str, input: str, temperature=1.0, top_p=1.0) -> dict: except Exception as e: instruction_template = default_template - print(f"Exception: When loading characters/instruction-following/{shared.settings['instruction_template']}.yaml: {repr(e)}") + print(f"Exception: When loading instruction-templates/{shared.settings['instruction_template']}.yaml: {repr(e)}") print("Warning: Loaded default instruction-following template (Alpaca) for model.") else: stopping_strings.extend(['\n###']) diff --git a/characters/instruction-following/Airoboros-v1.2.yaml b/instruction-templates/Airoboros-v1.2.yaml similarity index 100% rename from characters/instruction-following/Airoboros-v1.2.yaml rename to instruction-templates/Airoboros-v1.2.yaml diff --git a/characters/instruction-following/Alpaca.yaml b/instruction-templates/Alpaca.yaml similarity index 100% rename from characters/instruction-following/Alpaca.yaml rename to instruction-templates/Alpaca.yaml diff --git a/characters/instruction-following/Bactrian.yaml b/instruction-templates/Bactrian.yaml similarity index 100% rename from characters/instruction-following/Bactrian.yaml rename to instruction-templates/Bactrian.yaml diff --git a/characters/instruction-following/Baichuan Chat.yaml b/instruction-templates/Baichuan Chat.yaml similarity index 100% rename from characters/instruction-following/Baichuan Chat.yaml rename to instruction-templates/Baichuan Chat.yaml diff --git a/characters/instruction-following/Baize.yaml b/instruction-templates/Baize.yaml similarity index 100% rename from characters/instruction-following/Baize.yaml rename to instruction-templates/Baize.yaml diff --git a/characters/instruction-following/Bluemoon.yaml b/instruction-templates/Bluemoon.yaml similarity index 100% rename from characters/instruction-following/Bluemoon.yaml rename to instruction-templates/Bluemoon.yaml diff --git a/characters/instruction-following/ChatGLM.yaml b/instruction-templates/ChatGLM.yaml similarity index 100% rename from characters/instruction-following/ChatGLM.yaml rename to instruction-templates/ChatGLM.yaml diff --git a/characters/instruction-following/Chinese-Vicuna-Chat.yaml b/instruction-templates/Chinese-Vicuna-Chat.yaml similarity index 100% rename from characters/instruction-following/Chinese-Vicuna-Chat.yaml rename to instruction-templates/Chinese-Vicuna-Chat.yaml diff --git a/characters/instruction-following/Galactica Cite.yaml b/instruction-templates/Galactica Cite.yaml similarity index 100% rename from characters/instruction-following/Galactica Cite.yaml rename to instruction-templates/Galactica Cite.yaml diff --git a/characters/instruction-following/Galactica Finetuned.yaml b/instruction-templates/Galactica Finetuned.yaml similarity index 100% rename from characters/instruction-following/Galactica Finetuned.yaml rename to instruction-templates/Galactica Finetuned.yaml diff --git a/characters/instruction-following/Galactica Q.yaml b/instruction-templates/Galactica Q.yaml similarity index 100% rename from characters/instruction-following/Galactica Q.yaml rename to instruction-templates/Galactica Q.yaml diff --git a/characters/instruction-following/Galactica Summary.yaml b/instruction-templates/Galactica Summary.yaml similarity index 100% rename from characters/instruction-following/Galactica Summary.yaml rename to instruction-templates/Galactica Summary.yaml diff --git a/characters/instruction-following/Galactica Work.yaml b/instruction-templates/Galactica Work.yaml similarity index 100% rename from characters/instruction-following/Galactica Work.yaml rename to instruction-templates/Galactica Work.yaml diff --git a/characters/instruction-following/Galactica v2.yaml b/instruction-templates/Galactica v2.yaml similarity index 100% rename from characters/instruction-following/Galactica v2.yaml rename to instruction-templates/Galactica v2.yaml diff --git a/characters/instruction-following/Galactica.yaml b/instruction-templates/Galactica.yaml similarity index 100% rename from characters/instruction-following/Galactica.yaml rename to instruction-templates/Galactica.yaml diff --git a/characters/instruction-following/Gorilla.yaml b/instruction-templates/Gorilla.yaml similarity index 100% rename from characters/instruction-following/Gorilla.yaml rename to instruction-templates/Gorilla.yaml diff --git a/characters/instruction-following/Guanaco non-chat.yaml b/instruction-templates/Guanaco non-chat.yaml similarity index 100% rename from characters/instruction-following/Guanaco non-chat.yaml rename to instruction-templates/Guanaco non-chat.yaml diff --git a/characters/instruction-following/Guanaco-QLoRA.yaml b/instruction-templates/Guanaco-QLoRA.yaml similarity index 100% rename from characters/instruction-following/Guanaco-QLoRA.yaml rename to instruction-templates/Guanaco-QLoRA.yaml diff --git a/characters/instruction-following/Guanaco.yaml b/instruction-templates/Guanaco.yaml similarity index 100% rename from characters/instruction-following/Guanaco.yaml rename to instruction-templates/Guanaco.yaml diff --git a/characters/instruction-following/H2O-human_bot.yaml b/instruction-templates/H2O-human_bot.yaml similarity index 100% rename from characters/instruction-following/H2O-human_bot.yaml rename to instruction-templates/H2O-human_bot.yaml diff --git a/characters/instruction-following/H2O-prompt_answer.yaml b/instruction-templates/H2O-prompt_answer.yaml similarity index 100% rename from characters/instruction-following/H2O-prompt_answer.yaml rename to instruction-templates/H2O-prompt_answer.yaml diff --git a/characters/instruction-following/Hippogriff.yaml b/instruction-templates/Hippogriff.yaml similarity index 100% rename from characters/instruction-following/Hippogriff.yaml rename to instruction-templates/Hippogriff.yaml diff --git a/characters/instruction-following/INCITE-Chat.yaml b/instruction-templates/INCITE-Chat.yaml similarity index 100% rename from characters/instruction-following/INCITE-Chat.yaml rename to instruction-templates/INCITE-Chat.yaml diff --git a/characters/instruction-following/INCITE-Instruct.yaml b/instruction-templates/INCITE-Instruct.yaml similarity index 100% rename from characters/instruction-following/INCITE-Instruct.yaml rename to instruction-templates/INCITE-Instruct.yaml diff --git a/characters/instruction-following/KoAlpaca.yaml b/instruction-templates/KoAlpaca.yaml similarity index 100% rename from characters/instruction-following/KoAlpaca.yaml rename to instruction-templates/KoAlpaca.yaml diff --git a/characters/instruction-following/Koala.yaml b/instruction-templates/Koala.yaml similarity index 100% rename from characters/instruction-following/Koala.yaml rename to instruction-templates/Koala.yaml diff --git a/characters/instruction-following/LLaVA.yaml b/instruction-templates/LLaVA.yaml similarity index 100% rename from characters/instruction-following/LLaVA.yaml rename to instruction-templates/LLaVA.yaml diff --git a/characters/instruction-following/Llama-v2.yaml b/instruction-templates/Llama-v2.yaml similarity index 100% rename from characters/instruction-following/Llama-v2.yaml rename to instruction-templates/Llama-v2.yaml diff --git a/characters/instruction-following/MOSS.yaml b/instruction-templates/MOSS.yaml similarity index 100% rename from characters/instruction-following/MOSS.yaml rename to instruction-templates/MOSS.yaml diff --git a/characters/instruction-following/MPT-Chat.yaml b/instruction-templates/MPT-Chat.yaml similarity index 100% rename from characters/instruction-following/MPT-Chat.yaml rename to instruction-templates/MPT-Chat.yaml diff --git a/characters/instruction-following/Manticore Chat.yaml b/instruction-templates/Manticore Chat.yaml similarity index 100% rename from characters/instruction-following/Manticore Chat.yaml rename to instruction-templates/Manticore Chat.yaml diff --git a/characters/instruction-following/Metharme.yaml b/instruction-templates/Metharme.yaml similarity index 100% rename from characters/instruction-following/Metharme.yaml rename to instruction-templates/Metharme.yaml diff --git a/characters/instruction-following/Minotaur.yaml b/instruction-templates/Minotaur.yaml similarity index 100% rename from characters/instruction-following/Minotaur.yaml rename to instruction-templates/Minotaur.yaml diff --git a/characters/instruction-following/NewHope.yaml b/instruction-templates/NewHope.yaml similarity index 100% rename from characters/instruction-following/NewHope.yaml rename to instruction-templates/NewHope.yaml diff --git a/characters/instruction-following/Open Assistant.yaml b/instruction-templates/Open Assistant.yaml similarity index 100% rename from characters/instruction-following/Open Assistant.yaml rename to instruction-templates/Open Assistant.yaml diff --git a/characters/instruction-following/OpenBuddy.yaml b/instruction-templates/OpenBuddy.yaml similarity index 100% rename from characters/instruction-following/OpenBuddy.yaml rename to instruction-templates/OpenBuddy.yaml diff --git a/characters/instruction-following/Orca Mini.yaml b/instruction-templates/Orca Mini.yaml similarity index 100% rename from characters/instruction-following/Orca Mini.yaml rename to instruction-templates/Orca Mini.yaml diff --git a/characters/instruction-following/RWKV-Raven.yaml b/instruction-templates/RWKV-Raven.yaml similarity index 100% rename from characters/instruction-following/RWKV-Raven.yaml rename to instruction-templates/RWKV-Raven.yaml diff --git a/characters/instruction-following/Samantha.yaml b/instruction-templates/Samantha.yaml similarity index 100% rename from characters/instruction-following/Samantha.yaml rename to instruction-templates/Samantha.yaml diff --git a/characters/instruction-following/StableBeluga2.yaml b/instruction-templates/StableBeluga2.yaml similarity index 100% rename from characters/instruction-following/StableBeluga2.yaml rename to instruction-templates/StableBeluga2.yaml diff --git a/characters/instruction-following/StableLM.yaml b/instruction-templates/StableLM.yaml similarity index 100% rename from characters/instruction-following/StableLM.yaml rename to instruction-templates/StableLM.yaml diff --git a/characters/instruction-following/StableVicuna.yaml b/instruction-templates/StableVicuna.yaml similarity index 100% rename from characters/instruction-following/StableVicuna.yaml rename to instruction-templates/StableVicuna.yaml diff --git a/characters/instruction-following/Starchat-Beta.yaml b/instruction-templates/Starchat-Beta.yaml similarity index 100% rename from characters/instruction-following/Starchat-Beta.yaml rename to instruction-templates/Starchat-Beta.yaml diff --git a/characters/instruction-following/Tulu.yaml b/instruction-templates/Tulu.yaml similarity index 100% rename from characters/instruction-following/Tulu.yaml rename to instruction-templates/Tulu.yaml diff --git a/characters/instruction-following/Vicuna-v0.yaml b/instruction-templates/Vicuna-v0.yaml similarity index 100% rename from characters/instruction-following/Vicuna-v0.yaml rename to instruction-templates/Vicuna-v0.yaml diff --git a/characters/instruction-following/Vicuna-v1.1.yaml b/instruction-templates/Vicuna-v1.1.yaml similarity index 100% rename from characters/instruction-following/Vicuna-v1.1.yaml rename to instruction-templates/Vicuna-v1.1.yaml diff --git a/characters/instruction-following/Vigogne-Chat.yaml b/instruction-templates/Vigogne-Chat.yaml similarity index 100% rename from characters/instruction-following/Vigogne-Chat.yaml rename to instruction-templates/Vigogne-Chat.yaml diff --git a/characters/instruction-following/Vigogne-Instruct.yaml b/instruction-templates/Vigogne-Instruct.yaml similarity index 100% rename from characters/instruction-following/Vigogne-Instruct.yaml rename to instruction-templates/Vigogne-Instruct.yaml diff --git a/characters/instruction-following/Wizard-Mega ShareGPT.yaml b/instruction-templates/Wizard-Mega ShareGPT.yaml similarity index 100% rename from characters/instruction-following/Wizard-Mega ShareGPT.yaml rename to instruction-templates/Wizard-Mega ShareGPT.yaml diff --git a/characters/instruction-following/Wizard-Mega WizardLM.yaml b/instruction-templates/Wizard-Mega WizardLM.yaml similarity index 100% rename from characters/instruction-following/Wizard-Mega WizardLM.yaml rename to instruction-templates/Wizard-Mega WizardLM.yaml diff --git a/characters/instruction-following/Wizard-Mega.yaml b/instruction-templates/Wizard-Mega.yaml similarity index 100% rename from characters/instruction-following/Wizard-Mega.yaml rename to instruction-templates/Wizard-Mega.yaml diff --git a/characters/instruction-following/WizardLM.yaml b/instruction-templates/WizardLM.yaml similarity index 100% rename from characters/instruction-following/WizardLM.yaml rename to instruction-templates/WizardLM.yaml diff --git a/characters/instruction-following/Ziya.yaml b/instruction-templates/Ziya.yaml similarity index 100% rename from characters/instruction-following/Ziya.yaml rename to instruction-templates/Ziya.yaml diff --git a/modules/chat.py b/modules/chat.py index 8a86523c..a445c6a8 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -475,7 +475,7 @@ def load_character(character, name1, name2, instruct=False): Path("cache/pfp_character.png").unlink() if character not in ['None', '', None]: - folder = 'characters' if not instruct else 'characters/instruction-following' + folder = 'characters' if not instruct else 'instruction-templates' picture = generate_pfp_cache(character) filepath = None for extension in ["yml", "yaml", "json"]: diff --git a/modules/prompts.py b/modules/prompts.py index f68c83c4..8a3cf3e3 100644 --- a/modules/prompts.py +++ b/modules/prompts.py @@ -12,7 +12,7 @@ def load_prompt(fname): return '' elif fname.startswith('Instruct-'): fname = re.sub('^Instruct-', '', fname) - file_path = Path(f'characters/instruction-following/{fname}.yaml') + file_path = Path(f'instruction-templates/{fname}.yaml') if not file_path.exists(): return '' diff --git a/modules/ui_chat.py b/modules/ui_chat.py index 8a0c103b..a858acaf 100644 --- a/modules/ui_chat.py +++ b/modules/ui_chat.py @@ -232,13 +232,13 @@ def create_event_handlers(): shared.gradio['save_template'].click( lambda: 'My Template.yaml', None, gradio('save_filename')).then( - lambda: 'characters/instruction-following/', None, gradio('save_root')).then( + lambda: 'instruction-templates/', None, gradio('save_root')).then( chat.generate_instruction_template_yaml, gradio('name1_instruct', 'name2_instruct', 'context_instruct', 'turn_template'), gradio('save_contents')).then( lambda: gr.update(visible=True), None, gradio('file_saver')) shared.gradio['delete_template'].click( lambda x: f'{x}.yaml', gradio('instruction_template'), gradio('delete_filename')).then( - lambda: 'characters/instruction-following/', None, gradio('delete_root')).then( + lambda: 'instruction-templates/', None, gradio('delete_root')).then( lambda: gr.update(visible=True), None, gradio('file_deleter')) shared.gradio['save_chat_history'].click( diff --git a/modules/utils.py b/modules/utils.py index 9ae5dc86..adaa15e8 100644 --- a/modules/utils.py +++ b/modules/utils.py @@ -90,11 +90,11 @@ def get_available_prompts(): def get_available_characters(): paths = (x for x in Path('characters').iterdir() if x.suffix in ('.json', '.yaml', '.yml')) - return ['None'] + sorted(set((k.stem for k in paths if k.stem != "instruction-following")), key=natural_keys) + return ['None'] + sorted(set((k.stem for k in paths)), key=natural_keys) def get_available_instruction_templates(): - path = "characters/instruction-following" + path = "instruction-templates" paths = [] if os.path.exists(path): paths = (x for x in Path(path).iterdir() if x.suffix in ('.json', '.yaml', '.yml'))