Minor bug fixes

This commit is contained in:
oobabooga 2023-06-17 17:57:56 -03:00
parent d8d29edf54
commit 239b11c94b

View File

@ -94,7 +94,11 @@ def load_prompt(fname):
return ''
elif fname.startswith('Instruct-'):
fname = re.sub('^Instruct-', '', fname)
with open(Path(f'characters/instruction-following/{fname}.yaml'), 'r', encoding='utf-8') as f:
file_path = Path(f'characters/instruction-following/{fname}.yaml')
if not file_path.exists():
return ''
with open(file_path, 'r', encoding='utf-8') as f:
data = yaml.safe_load(f)
output = ''
if 'context' in data:
@ -109,7 +113,11 @@ def load_prompt(fname):
output += utils.replace_all(data['turn_template'].split('<|bot-message|>')[0], replacements)
return output.rstrip(' ')
else:
with open(Path(f'prompts/{fname}.txt'), 'r', encoding='utf-8') as f:
file_path = Path(f'prompts/{fname}.txt')
if not file_path.exists():
return ''
with open(file_path, 'r', encoding='utf-8') as f:
text = f.read()
if text[-1] == '\n':
text = text[:-1]
@ -228,7 +236,7 @@ def create_model_menus():
shared.gradio['bf16'] = gr.Checkbox(label="bf16", value=shared.args.bf16)
shared.gradio['auto_devices'] = gr.Checkbox(label="auto-devices", value=shared.args.auto_devices)
shared.gradio['disk'] = gr.Checkbox(label="disk", value=shared.args.disk)
shared.gradio['load_in_4bit'] = gr.Checkbox(label="load-in-4bit")
shared.gradio['load_in_4bit'] = gr.Checkbox(label="load-in-4bit", value=shared.args.load_in_4bit)
shared.gradio['use_double_quant'] = gr.Checkbox(label="use_double_quant", value=shared.args.use_double_quant)
shared.gradio['no_mmap'] = gr.Checkbox(label="no-mmap", value=shared.args.no_mmap)
shared.gradio['mlock'] = gr.Checkbox(label="mlock", value=shared.args.mlock)