mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-03-18 03:14:39 +01:00
UI: Minor defensive changes to autosave
This commit is contained in:
parent
bb00d96dc3
commit
980a9d1657
|
|
@ -6,6 +6,7 @@ import json
|
|||
import pprint
|
||||
import re
|
||||
import shutil
|
||||
import threading
|
||||
import time
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
|
|
@ -40,6 +41,8 @@ from modules.utils import (
|
|||
)
|
||||
from modules.web_search import add_web_search_attachments
|
||||
|
||||
_history_file_lock = threading.Lock()
|
||||
|
||||
|
||||
def strftime_now(format):
|
||||
return datetime.now().strftime(format)
|
||||
|
|
@ -1200,8 +1203,9 @@ def save_history(history, unique_id, character, mode):
|
|||
if not p.parent.is_dir():
|
||||
p.parent.mkdir(parents=True)
|
||||
|
||||
with open(p, 'w', encoding='utf-8') as f:
|
||||
f.write(json.dumps(history, indent=4, ensure_ascii=False))
|
||||
with _history_file_lock:
|
||||
with open(p, 'w', encoding='utf-8') as f:
|
||||
f.write(json.dumps(history, indent=4, ensure_ascii=False))
|
||||
|
||||
|
||||
def rename_history(old_id, new_id, character, mode):
|
||||
|
|
|
|||
|
|
@ -303,12 +303,16 @@ def save_settings(state, preset, extensions_list, show_controls, theme_state, ma
|
|||
if k in shared.settings and k not in exclude:
|
||||
output[k] = state[k]
|
||||
|
||||
output['preset'] = preset
|
||||
if preset:
|
||||
output['preset'] = preset
|
||||
output['prompt-notebook'] = state['prompt_menu-default'] if state['show_two_notebook_columns'] else state['prompt_menu-notebook']
|
||||
output['character'] = state['character_menu']
|
||||
if 'user_menu' in state and state['user_menu']:
|
||||
if state.get('character_menu'):
|
||||
output['character'] = state['character_menu']
|
||||
if state.get('user_menu'):
|
||||
output['user'] = state['user_menu']
|
||||
output['seed'] = int(output['seed'])
|
||||
output['custom_stopping_strings'] = output.get('custom_stopping_strings') or ''
|
||||
output['custom_token_bans'] = output.get('custom_token_bans') or ''
|
||||
output['show_controls'] = show_controls
|
||||
output['dark_theme'] = True if theme_state == 'dark' else False
|
||||
output.pop('instruction_template_str')
|
||||
|
|
@ -470,7 +474,6 @@ def setup_auto_save():
|
|||
'skip_special_tokens',
|
||||
'stream',
|
||||
'static_cache',
|
||||
'truncation_length',
|
||||
'seed',
|
||||
'sampler_priority',
|
||||
'custom_stopping_strings',
|
||||
|
|
|
|||
Loading…
Reference in a new issue