mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-04-04 22:27:29 +00:00
Better autosave behavior for notebook tab when there are 2 columns
This commit is contained in:
parent
197b327374
commit
6cc7bbf009
2 changed files with 20 additions and 57 deletions
|
|
@ -11,7 +11,6 @@ from modules.text_generation import (
|
|||
get_token_ids,
|
||||
stop_everything_event
|
||||
)
|
||||
from modules.ui_default import autosave_prompt
|
||||
from modules.utils import gradio
|
||||
|
||||
_notebook_file_lock = threading.Lock()
|
||||
|
|
@ -249,6 +248,14 @@ def handle_rename_prompt_confirm_notebook(new_name, current_name):
|
|||
]
|
||||
|
||||
|
||||
def autosave_prompt(text, prompt_name):
|
||||
"""Automatically save the text to the selected prompt file"""
|
||||
if prompt_name and text.strip():
|
||||
prompt_path = Path("user_data/logs/notebook") / f"{prompt_name}.txt"
|
||||
prompt_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
prompt_path.write_text(text, encoding='utf-8')
|
||||
|
||||
|
||||
def safe_autosave_prompt(content, prompt_name):
|
||||
"""Thread-safe wrapper for autosave_prompt to prevent file corruption"""
|
||||
with _notebook_file_lock:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue