diff --git a/modules/prompts.py b/modules/prompts.py index d107ce5a..85dc32e3 100644 --- a/modules/prompts.py +++ b/modules/prompts.py @@ -1,6 +1,7 @@ from pathlib import Path from modules import shared, utils +from modules.utils import sanitize_filename from modules.text_generation import get_encoded_length @@ -18,6 +19,7 @@ def load_prompt(fname): return initial_content + fname = sanitize_filename(fname) file_path = shared.user_data_dir / 'logs' / 'notebook' / f'{fname}.txt' if file_path.exists(): with open(file_path, 'r', encoding='utf-8') as f: diff --git a/modules/tool_parsing.py b/modules/tool_parsing.py index 45da25c9..919e523a 100644 --- a/modules/tool_parsing.py +++ b/modules/tool_parsing.py @@ -699,6 +699,8 @@ def parse_tool_call(answer: str, tool_names: list[str], return_prefix: bool = Fa if not isinstance(candidates, list): candidates = [candidates] for candidate_dict in candidates: + if not isinstance(candidate_dict, dict): + continue checked_candidate = check_and_sanitize_tool_call_candidate(candidate_dict, tool_names) if checked_candidate is not None: matches.append(checked_candidate) diff --git a/modules/ui_default.py b/modules/ui_default.py index 2c367cca..48cb2fc2 100644 --- a/modules/ui_default.py +++ b/modules/ui_default.py @@ -10,7 +10,7 @@ from modules.text_generation import ( stop_everything_event ) from modules.ui_notebook import store_notebook_state_and_debounce -from modules.utils import gradio +from modules.utils import gradio, sanitize_filename inputs = ('textbox-default', 'interface_state') outputs = ('output_textbox', 'html-default') @@ -167,6 +167,7 @@ def handle_new_prompt(): def handle_delete_prompt_confirm_default(prompt_name): + prompt_name = sanitize_filename(prompt_name) available_prompts = utils.get_available_prompts() current_index = available_prompts.index(prompt_name) if prompt_name in available_prompts else 0 @@ -199,6 +200,8 @@ def handle_rename_prompt_click_default(current_name): def handle_rename_prompt_confirm_default(new_name, current_name): + new_name = sanitize_filename(new_name) + current_name = sanitize_filename(current_name) old_path = shared.user_data_dir / "logs" / "notebook" / f"{current_name}.txt" new_path = shared.user_data_dir / "logs" / "notebook" / f"{new_name}.txt" diff --git a/modules/ui_notebook.py b/modules/ui_notebook.py index f550e646..88f00ac5 100644 --- a/modules/ui_notebook.py +++ b/modules/ui_notebook.py @@ -11,7 +11,7 @@ from modules.text_generation import ( get_token_ids, stop_everything_event ) -from modules.utils import gradio +from modules.utils import gradio, sanitize_filename _notebook_file_lock = threading.Lock() _notebook_auto_save_timer = None @@ -202,6 +202,7 @@ def handle_new_prompt(): def handle_delete_prompt_confirm_notebook(prompt_name): + prompt_name = sanitize_filename(prompt_name) available_prompts = utils.get_available_prompts() current_index = available_prompts.index(prompt_name) if prompt_name in available_prompts else 0 @@ -233,6 +234,8 @@ def handle_rename_prompt_click_notebook(current_name): def handle_rename_prompt_confirm_notebook(new_name, current_name): + new_name = sanitize_filename(new_name) + current_name = sanitize_filename(current_name) old_path = shared.user_data_dir / "logs" / "notebook" / f"{current_name}.txt" new_path = shared.user_data_dir / "logs" / "notebook" / f"{new_name}.txt" @@ -249,6 +252,7 @@ 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""" + prompt_name = sanitize_filename(prompt_name) if prompt_name and text.strip(): prompt_path = shared.user_data_dir / "logs" / "notebook" / f"{prompt_name}.txt" prompt_path.parent.mkdir(parents=True, exist_ok=True) diff --git a/requirements/full/requirements.txt b/requirements/full/requirements.txt index 4d9d243c..b7a5ca97 100644 --- a/requirements/full/requirements.txt +++ b/requirements/full/requirements.txt @@ -31,8 +31,8 @@ tqdm wandb # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/full/requirements_amd.txt b/requirements/full/requirements_amd.txt index b6caf320..2c627585 100644 --- a/requirements/full/requirements_amd.txt +++ b/requirements/full/requirements_amd.txt @@ -28,8 +28,8 @@ trafilatura==2.0.0 wandb # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/full/requirements_apple_intel.txt b/requirements/full/requirements_apple_intel.txt index ae2f6263..7e3fc35f 100644 --- a/requirements/full/requirements_apple_intel.txt +++ b/requirements/full/requirements_apple_intel.txt @@ -28,8 +28,8 @@ trafilatura==2.0.0 wandb # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/full/requirements_apple_silicon.txt b/requirements/full/requirements_apple_silicon.txt index f4783d2b..2603201d 100644 --- a/requirements/full/requirements_apple_silicon.txt +++ b/requirements/full/requirements_apple_silicon.txt @@ -28,8 +28,8 @@ trafilatura==2.0.0 wandb # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/full/requirements_cpu_only.txt b/requirements/full/requirements_cpu_only.txt index 11d670b6..fe3bf3ba 100644 --- a/requirements/full/requirements_cpu_only.txt +++ b/requirements/full/requirements_cpu_only.txt @@ -28,8 +28,8 @@ trafilatura==2.0.0 wandb # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/full/requirements_nowheels.txt b/requirements/full/requirements_nowheels.txt index d4b1ca80..acae301e 100644 --- a/requirements/full/requirements_nowheels.txt +++ b/requirements/full/requirements_nowheels.txt @@ -28,8 +28,8 @@ trafilatura==2.0.0 wandb # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements.txt b/requirements/portable/requirements.txt index 901d1494..56795843 100644 --- a/requirements/portable/requirements.txt +++ b/requirements/portable/requirements.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements_amd.txt b/requirements/portable/requirements_amd.txt index 5705c64c..abaa1338 100644 --- a/requirements/portable/requirements_amd.txt +++ b/requirements/portable/requirements_amd.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements_apple_intel.txt b/requirements/portable/requirements_apple_intel.txt index 3c3deaed..b22a03d9 100644 --- a/requirements/portable/requirements_apple_intel.txt +++ b/requirements/portable/requirements_apple_intel.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements_apple_silicon.txt b/requirements/portable/requirements_apple_silicon.txt index 3f1e814c..97c5903c 100644 --- a/requirements/portable/requirements_apple_silicon.txt +++ b/requirements/portable/requirements_apple_silicon.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements_cpu_only.txt b/requirements/portable/requirements_cpu_only.txt index 3bfed7f8..57e92f74 100644 --- a/requirements/portable/requirements_cpu_only.txt +++ b/requirements/portable/requirements_cpu_only.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements_cuda131.txt b/requirements/portable/requirements_cuda131.txt index dd7059c8..1f7d27a7 100644 --- a/requirements/portable/requirements_cuda131.txt +++ b/requirements/portable/requirements_cuda131.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements_ik.txt b/requirements/portable/requirements_ik.txt index 4fdd10fe..65f6a004 100644 --- a/requirements/portable/requirements_ik.txt +++ b/requirements/portable/requirements_ik.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements_ik_cpu_only.txt b/requirements/portable/requirements_ik_cpu_only.txt index 1b377463..0a82adb7 100644 --- a/requirements/portable/requirements_ik_cpu_only.txt +++ b/requirements/portable/requirements_ik_cpu_only.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements_ik_cuda131.txt b/requirements/portable/requirements_ik_cuda131.txt index b85607d3..3d812045 100644 --- a/requirements/portable/requirements_ik_cuda131.txt +++ b/requirements/portable/requirements_ik_cuda131.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements_nowheels.txt b/requirements/portable/requirements_nowheels.txt index 39628ee6..91bef10b 100644 --- a/requirements/portable/requirements_nowheels.txt +++ b/requirements/portable/requirements_nowheels.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15 diff --git a/requirements/portable/requirements_vulkan.txt b/requirements/portable/requirements_vulkan.txt index 16aa5593..7c61f0cc 100644 --- a/requirements/portable/requirements_vulkan.txt +++ b/requirements/portable/requirements_vulkan.txt @@ -14,8 +14,8 @@ trafilatura==2.0.0 tqdm # Gradio -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio-4.37.2+custom.17-py3-none-any.whl -https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.17/gradio_client-1.0.2+custom.17-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio-4.37.2+custom.18-py3-none-any.whl +https://github.com/oobabooga/gradio/releases/download/4.37.2-custom.18/gradio_client-1.0.2+custom.18-py3-none-any.whl # API flask_cloudflared==0.0.15