From c3dc348d1c485cfe6f048a2806a6e797cd98cd69 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Mon, 17 Apr 2023 13:52:23 -0300 Subject: [PATCH] Don't show 'None' in the LoRA list --- modules/chat.py | 9 +++++---- server.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/chat.py b/modules/chat.py index e3c4e00f..585193c9 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -41,7 +41,6 @@ def generate_chat_prompt(user_input, state, **kwargs): i = len(shared.history['internal']) - 1 while i >= 0 and len(encode(''.join(rows))[0]) < max_length: - if _continue and i == len(shared.history['internal']) - 1: rows.insert(1, f"{prefix2}{shared.history['internal'][i][1]}") else: @@ -433,12 +432,12 @@ def load_character(character, name1, name2, mode): filepath = Path(f'{folder}/{character}.{extension}') if filepath.exists(): break + file_contents = open(filepath, 'r', encoding='utf-8').read() data = json.loads(file_contents) if extension == "json" else yaml.safe_load(file_contents) - + name2 = data['name'] if 'name' in data else data['char_name'] if 'your_name' in data and data['your_name'] != '': name1 = data['your_name'] - name2 = data['name'] if 'name' in data else data['char_name'] for field in ['context', 'greeting', 'example_dialogue', 'char_persona', 'char_greeting', 'world_scenario']: if field in data: @@ -452,10 +451,13 @@ def load_character(character, name1, name2, mode): if 'example_dialogue' in data: context += f"{data['example_dialogue'].strip()}\n" + if greeting_field in data: greeting = data[greeting_field] + if 'end_of_turn' in data: end_of_turn = data['end_of_turn'] + else: context = shared.settings['context'] name2 = shared.settings['name2'] @@ -465,7 +467,6 @@ def load_character(character, name1, name2, mode): if mode != 'instruct': shared.history['internal'] = [] shared.history['visible'] = [] - if Path(f'logs/{shared.character}_persistent.json').exists(): load_history(open(Path(f'logs/{shared.character}_persistent.json'), 'rb').read(), name1, name2) else: diff --git a/server.py b/server.py index be3b8185..b7abf984 100644 --- a/server.py +++ b/server.py @@ -73,7 +73,7 @@ def get_available_softprompts(): def get_available_loras(): - return ['None'] + sorted([item.name for item in list(Path(shared.args.lora_dir).glob('*')) if not item.name.endswith(('.txt', '-np', '.pt', '.json'))], key=str.lower) + return sorted([item.name for item in list(Path(shared.args.lora_dir).glob('*')) if not item.name.endswith(('.txt', '-np', '.pt', '.json'))], key=str.lower) def load_model_wrapper(selected_model):