mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-03-06 21:53:50 +01:00
Fix blank prompt dropdown in Notebook/Default tabs on first startup
This commit is contained in:
parent
0804296f4d
commit
d45aa6606a
|
|
@ -209,6 +209,12 @@ def get_available_prompts():
|
|||
notebook_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
prompt_files = list(notebook_dir.glob('*.txt'))
|
||||
if not prompt_files:
|
||||
new_name = current_time()
|
||||
new_path = notebook_dir / f"{new_name}.txt"
|
||||
new_path.write_text("In this story,", encoding='utf-8')
|
||||
prompt_files = [new_path]
|
||||
|
||||
sorted_files = sorted(prompt_files, key=lambda x: x.stat().st_mtime, reverse=True)
|
||||
prompts = [file.stem for file in sorted_files]
|
||||
return prompts
|
||||
|
|
|
|||
14
server.py
14
server.py
|
|
@ -109,12 +109,14 @@ def create_interface():
|
|||
'filter_by_loader': (shared.args.loader or 'All') if not shared.args.portable else 'llama.cpp'
|
||||
})
|
||||
|
||||
if shared.settings['prompt-notebook']:
|
||||
prompt = load_prompt(shared.settings['prompt-notebook'])
|
||||
shared.persistent_interface_state.update({
|
||||
'textbox-default': prompt,
|
||||
'textbox-notebook': prompt
|
||||
})
|
||||
if not shared.settings['prompt-notebook']:
|
||||
shared.settings['prompt-notebook'] = utils.get_available_prompts()[0]
|
||||
|
||||
prompt = load_prompt(shared.settings['prompt-notebook'])
|
||||
shared.persistent_interface_state.update({
|
||||
'textbox-default': prompt,
|
||||
'textbox-notebook': prompt
|
||||
})
|
||||
|
||||
# Clear existing cache files
|
||||
for cache_file in ['pfp_character.png', 'pfp_character_thumb.png']:
|
||||
|
|
|
|||
Loading…
Reference in a new issue