move github proxy to settings, System page.
This commit is contained in:
parent
ee642a2ff4
commit
4981c7d370
|
@ -391,6 +391,7 @@ options_templates.update(options_section(('system', "System"), {
|
|||
"print_hypernet_extra": OptionInfo(False, "Print extra hypernetwork information to console."),
|
||||
"list_hidden_files": OptionInfo(True, "Load models/files in hidden directories").info("directory is hidden if its name starts with \".\""),
|
||||
"disable_mmap_load_safetensors": OptionInfo(False, "Disable memmapping for loading .safetensors files.").info("fixes very slow loading speed in some cases"),
|
||||
"github_proxy": OptionInfo("None", "Github proxy", ui_components.DropdownEditable, lambda: {"choices": ["None", "ghproxy.com", "hub.yzuu.cf", "hub.njuu.cf", "hub.nuaa.cf"]}).info("for custom inputs will just replace github.com with the input"),
|
||||
}))
|
||||
|
||||
options_templates.update(options_section(('training', "Training"), {
|
||||
|
|
|
@ -325,7 +325,18 @@ def normalize_git_url(url):
|
|||
return url
|
||||
|
||||
|
||||
def install_extension_from_url(dirname, proxy, url, branch_name=None):
|
||||
def github_proxy(url):
|
||||
proxy = shared.opts.github_proxy
|
||||
|
||||
if proxy == 'None':
|
||||
return url
|
||||
if proxy == 'ghproxy.com':
|
||||
return "https://ghproxy.com/" + url
|
||||
|
||||
return url.replace('github.com', proxy)
|
||||
|
||||
|
||||
def install_extension_from_url(dirname, url, branch_name=None):
|
||||
check_access()
|
||||
|
||||
if isinstance(dirname, str):
|
||||
|
@ -335,18 +346,7 @@ def install_extension_from_url(dirname, proxy, url, branch_name=None):
|
|||
|
||||
assert url, 'No URL specified'
|
||||
|
||||
proxy_list = {
|
||||
"none": "",
|
||||
"ghproxy": "https://ghproxy.com/",
|
||||
"yzuu": "hub.yzuu.cf",
|
||||
"njuu": "hub.njuu.cf",
|
||||
"nuaa": "hub.nuaa.cf",
|
||||
}
|
||||
|
||||
if proxy in ['yzuu', 'njuu', 'nuaa']:
|
||||
url = url.replace('github.com', proxy_list[proxy])
|
||||
elif proxy == 'ghproxy':
|
||||
url = proxy_list[proxy] + url
|
||||
url = github_proxy(url)
|
||||
|
||||
if dirname is None or dirname == "":
|
||||
*parts, last_part = url.split('/')
|
||||
|
@ -628,11 +628,6 @@ def create_ui():
|
|||
)
|
||||
|
||||
with gr.TabItem("Install from URL", id="install_from_url"):
|
||||
install_proxy = gr.Radio(
|
||||
label="Install Proxy", choices=["none", "ghproxy", "nuaa", "yzuu", "njuu"], value="none",
|
||||
info="If you can't access github.com, you can use a proxy to install extensions from github.com"
|
||||
)
|
||||
|
||||
install_url = gr.Text(label="URL for extension's git repository")
|
||||
install_branch = gr.Text(label="Specific branch name", placeholder="Leave empty for default main branch")
|
||||
install_dirname = gr.Text(label="Local directory name", placeholder="Leave empty for auto")
|
||||
|
@ -641,7 +636,7 @@ def create_ui():
|
|||
|
||||
install_button.click(
|
||||
fn=modules.ui.wrap_gradio_call(lambda *args: [gr.update(), *install_extension_from_url(*args)], extra_outputs=[gr.update(), gr.update()]),
|
||||
inputs=[install_dirname, install_proxy, install_url, install_branch],
|
||||
inputs=[install_dirname, install_url, install_branch],
|
||||
outputs=[install_url, extensions_table, install_result],
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue