mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-03-10 07:34:00 +01:00
Reorganize the Session tab
This commit is contained in:
parent
af6bb7513a
commit
42e7864d62
|
|
@ -1,38 +0,0 @@
|
|||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
new_extensions = set()
|
||||
|
||||
|
||||
def clone_or_pull_repository(github_url):
|
||||
global new_extensions
|
||||
|
||||
repository_folder = Path("extensions")
|
||||
repo_name = github_url.rstrip("/").split("/")[-1].split(".")[0]
|
||||
|
||||
# Check if the repository folder exists
|
||||
if not repository_folder.exists():
|
||||
repository_folder.mkdir(parents=True)
|
||||
|
||||
repo_path = repository_folder / repo_name
|
||||
|
||||
# Check if the repository is already cloned
|
||||
if repo_path.exists():
|
||||
yield f"Updating {github_url}..."
|
||||
# Perform a 'git pull' to update the repository
|
||||
try:
|
||||
pull_output = subprocess.check_output(["git", "-C", repo_path, "pull"], stderr=subprocess.STDOUT)
|
||||
yield "Done."
|
||||
return pull_output.decode()
|
||||
except subprocess.CalledProcessError as e:
|
||||
return str(e)
|
||||
|
||||
# Clone the repository
|
||||
try:
|
||||
yield f"Cloning {github_url}..."
|
||||
clone_output = subprocess.check_output(["git", "clone", github_url, repo_path], stderr=subprocess.STDOUT)
|
||||
new_extensions.add(repo_name)
|
||||
yield f"The extension `{repo_name}` has been downloaded.\n\nPlease close the web UI completely and launch it again to be able to load it."
|
||||
return clone_output.decode()
|
||||
except subprocess.CalledProcessError as e:
|
||||
return str(e)
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
import gradio as gr
|
||||
|
||||
from modules import shared, ui, utils
|
||||
from modules.github import clone_or_pull_repository
|
||||
from modules.utils import gradio
|
||||
|
||||
|
||||
|
|
@ -10,10 +9,12 @@ def create_ui():
|
|||
with gr.Tab("Session", elem_id="session-tab"):
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
with gr.Row():
|
||||
shared.gradio['toggle_dark_mode'] = gr.Button('Toggle 💡')
|
||||
shared.gradio['save_settings'] = gr.Button('Save UI defaults to user_data/settings.yaml', interactive=not mu)
|
||||
gr.Markdown("## Settings")
|
||||
shared.gradio['save_settings'] = gr.Button('Save settings to user_data/settings.yaml', elem_classes='refresh-button', interactive=not mu)
|
||||
shared.gradio['toggle_dark_mode'] = gr.Button('Toggle light/dark theme 💡', elem_classes='refresh-button')
|
||||
|
||||
with gr.Column():
|
||||
gr.Markdown("## Extensions & flags")
|
||||
shared.gradio['reset_interface'] = gr.Button("Apply flags/extensions and restart", interactive=not mu)
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
|
|
@ -22,17 +23,7 @@ def create_ui():
|
|||
with gr.Column():
|
||||
shared.gradio['bool_menu'] = gr.CheckboxGroup(choices=get_boolean_arguments(), value=get_boolean_arguments(active=True), label="Boolean command-line flags", elem_classes='checkboxgroup-table')
|
||||
|
||||
with gr.Column():
|
||||
if not shared.args.portable:
|
||||
extension_name = gr.Textbox(lines=1, label='Install or update an extension', info='Enter the GitHub URL below and press Enter. For a list of extensions, see: https://github.com/oobabooga/text-generation-webui-extensions ⚠️ WARNING ⚠️ : extensions can execute arbitrary code. Make sure to inspect their source code before activating them.', interactive=not mu)
|
||||
extension_status = gr.Markdown()
|
||||
else:
|
||||
pass
|
||||
|
||||
shared.gradio['theme_state'] = gr.Textbox(visible=False, value='dark' if shared.settings['dark_theme'] else 'light')
|
||||
if not shared.args.portable:
|
||||
extension_name.submit(clone_or_pull_repository, extension_name, extension_status, show_progress=False)
|
||||
|
||||
shared.gradio['save_settings'].click(
|
||||
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
|
||||
handle_save_settings, gradio('interface_state', 'preset_menu', 'extensions_menu', 'show_controls', 'theme_state'), gradio('save_contents', 'save_filename', 'save_root', 'file_saver'), show_progress=False)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import re
|
|||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from modules import github, shared
|
||||
from modules import shared
|
||||
from modules.logging_colors import logger
|
||||
|
||||
|
||||
|
|
@ -182,7 +182,6 @@ def get_available_instruction_templates():
|
|||
|
||||
def get_available_extensions():
|
||||
extensions = sorted(set(map(lambda x: x.parts[1], Path('extensions').glob('*/script.py'))), key=natural_keys)
|
||||
extensions = [v for v in extensions if v not in github.new_extensions]
|
||||
return extensions
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue