add hide_config
This commit is contained in:
@@ -142,6 +142,11 @@ listen_port = 8502
|
|||||||
# 文生视频时的最大并发任务数
|
# 文生视频时的最大并发任务数
|
||||||
max_concurrent_tasks = 5
|
max_concurrent_tasks = 5
|
||||||
|
|
||||||
|
# webui界面是否显示配置项
|
||||||
|
# webui hide baisc config panel
|
||||||
|
hide_config = false
|
||||||
|
|
||||||
|
|
||||||
[whisper]
|
[whisper]
|
||||||
# Only effective when subtitle_provider is "whisper"
|
# Only effective when subtitle_provider is "whisper"
|
||||||
|
|
||||||
|
|||||||
287
webui/Main.py
287
webui/Main.py
@@ -150,167 +150,168 @@ def tr(key):
|
|||||||
|
|
||||||
st.write(tr("Get Help"))
|
st.write(tr("Get Help"))
|
||||||
|
|
||||||
with st.expander(tr("Basic Settings"), expanded=False):
|
if not config.app.get("hide_config", False):
|
||||||
config_panels = st.columns(3)
|
with st.expander(tr("Basic Settings"), expanded=False):
|
||||||
left_config_panel = config_panels[0]
|
config_panels = st.columns(3)
|
||||||
middle_config_panel = config_panels[1]
|
left_config_panel = config_panels[0]
|
||||||
right_config_panel = config_panels[2]
|
middle_config_panel = config_panels[1]
|
||||||
with left_config_panel:
|
right_config_panel = config_panels[2]
|
||||||
display_languages = []
|
with left_config_panel:
|
||||||
selected_index = 0
|
display_languages = []
|
||||||
for i, code in enumerate(locales.keys()):
|
selected_index = 0
|
||||||
display_languages.append(f"{code} - {locales[code].get('Language')}")
|
for i, code in enumerate(locales.keys()):
|
||||||
if code == st.session_state['ui_language']:
|
display_languages.append(f"{code} - {locales[code].get('Language')}")
|
||||||
selected_index = i
|
if code == st.session_state['ui_language']:
|
||||||
|
selected_index = i
|
||||||
|
|
||||||
selected_language = st.selectbox(tr("Language"), options=display_languages,
|
selected_language = st.selectbox(tr("Language"), options=display_languages,
|
||||||
index=selected_index)
|
index=selected_index)
|
||||||
if selected_language:
|
if selected_language:
|
||||||
code = selected_language.split(" - ")[0].strip()
|
code = selected_language.split(" - ")[0].strip()
|
||||||
st.session_state['ui_language'] = code
|
st.session_state['ui_language'] = code
|
||||||
config.ui['language'] = code
|
config.ui['language'] = code
|
||||||
|
|
||||||
with middle_config_panel:
|
with middle_config_panel:
|
||||||
# openai
|
# openai
|
||||||
# moonshot (月之暗面)
|
# moonshot (月之暗面)
|
||||||
# oneapi
|
# oneapi
|
||||||
# g4f
|
# g4f
|
||||||
# azure
|
# azure
|
||||||
# qwen (通义千问)
|
# qwen (通义千问)
|
||||||
# gemini
|
# gemini
|
||||||
# ollama
|
# ollama
|
||||||
llm_providers = ['OpenAI', 'Moonshot', 'Azure', 'Qwen', 'Gemini', 'Ollama', 'G4f', 'OneAPI', "Cloudflare"]
|
llm_providers = ['OpenAI', 'Moonshot', 'Azure', 'Qwen', 'Gemini', 'Ollama', 'G4f', 'OneAPI', "Cloudflare"]
|
||||||
saved_llm_provider = config.app.get("llm_provider", "OpenAI").lower()
|
saved_llm_provider = config.app.get("llm_provider", "OpenAI").lower()
|
||||||
saved_llm_provider_index = 0
|
saved_llm_provider_index = 0
|
||||||
for i, provider in enumerate(llm_providers):
|
for i, provider in enumerate(llm_providers):
|
||||||
if provider.lower() == saved_llm_provider:
|
if provider.lower() == saved_llm_provider:
|
||||||
saved_llm_provider_index = i
|
saved_llm_provider_index = i
|
||||||
break
|
break
|
||||||
|
|
||||||
llm_provider = st.selectbox(tr("LLM Provider"), options=llm_providers, index=saved_llm_provider_index)
|
llm_provider = st.selectbox(tr("LLM Provider"), options=llm_providers, index=saved_llm_provider_index)
|
||||||
llm_helper = st.container()
|
llm_helper = st.container()
|
||||||
llm_provider = llm_provider.lower()
|
llm_provider = llm_provider.lower()
|
||||||
config.app["llm_provider"] = llm_provider
|
config.app["llm_provider"] = llm_provider
|
||||||
|
|
||||||
llm_api_key = config.app.get(f"{llm_provider}_api_key", "")
|
llm_api_key = config.app.get(f"{llm_provider}_api_key", "")
|
||||||
llm_base_url = config.app.get(f"{llm_provider}_base_url", "")
|
llm_base_url = config.app.get(f"{llm_provider}_base_url", "")
|
||||||
llm_model_name = config.app.get(f"{llm_provider}_model_name", "")
|
llm_model_name = config.app.get(f"{llm_provider}_model_name", "")
|
||||||
llm_account_id = config.app.get(f"{llm_provider}_account_id", "")
|
llm_account_id = config.app.get(f"{llm_provider}_account_id", "")
|
||||||
|
|
||||||
tips = ""
|
tips = ""
|
||||||
if llm_provider == 'ollama':
|
if llm_provider == 'ollama':
|
||||||
if not llm_model_name:
|
if not llm_model_name:
|
||||||
llm_model_name = "qwen:7b"
|
llm_model_name = "qwen:7b"
|
||||||
if not llm_base_url:
|
if not llm_base_url:
|
||||||
llm_base_url = "http://localhost:11434/v1"
|
llm_base_url = "http://localhost:11434/v1"
|
||||||
|
|
||||||
with llm_helper:
|
with llm_helper:
|
||||||
tips = """
|
tips = """
|
||||||
##### Ollama配置说明
|
##### Ollama配置说明
|
||||||
- **API Key**: 随便填写,比如 123
|
- **API Key**: 随便填写,比如 123
|
||||||
- **Base Url**: 一般为 http://localhost:11434/v1
|
- **Base Url**: 一般为 http://localhost:11434/v1
|
||||||
- 如果 `MoneyPrinterTurbo` 和 `Ollama` **不在同一台机器上**,需要填写 `Ollama` 机器的IP地址
|
- 如果 `MoneyPrinterTurbo` 和 `Ollama` **不在同一台机器上**,需要填写 `Ollama` 机器的IP地址
|
||||||
- 如果 `MoneyPrinterTurbo` 是 `Docker` 部署,建议填写 `http://host.docker.internal:11434/v1`
|
- 如果 `MoneyPrinterTurbo` 是 `Docker` 部署,建议填写 `http://host.docker.internal:11434/v1`
|
||||||
- **Model Name**: 使用 `ollama list` 查看,比如 `qwen:7b`
|
- **Model Name**: 使用 `ollama list` 查看,比如 `qwen:7b`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if llm_provider == 'openai':
|
if llm_provider == 'openai':
|
||||||
if not llm_model_name:
|
if not llm_model_name:
|
||||||
llm_model_name = "gpt-3.5-turbo"
|
llm_model_name = "gpt-3.5-turbo"
|
||||||
with llm_helper:
|
with llm_helper:
|
||||||
tips = """
|
tips = """
|
||||||
##### OpenAI 配置说明
|
##### OpenAI 配置说明
|
||||||
> 需要VPN开启全局流量模式
|
> 需要VPN开启全局流量模式
|
||||||
- **API Key**: [点击到官网申请](https://platform.openai.com/api-keys)
|
- **API Key**: [点击到官网申请](https://platform.openai.com/api-keys)
|
||||||
- **Base Url**: 可以留空
|
- **Base Url**: 可以留空
|
||||||
- **Model Name**: 填写**有权限**的模型,[点击查看模型列表](https://platform.openai.com/settings/organization/limits)
|
- **Model Name**: 填写**有权限**的模型,[点击查看模型列表](https://platform.openai.com/settings/organization/limits)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if llm_provider == 'moonshot':
|
if llm_provider == 'moonshot':
|
||||||
if not llm_model_name:
|
if not llm_model_name:
|
||||||
llm_model_name = "moonshot-v1-8k"
|
llm_model_name = "moonshot-v1-8k"
|
||||||
with llm_helper:
|
with llm_helper:
|
||||||
tips = """
|
tips = """
|
||||||
##### Moonshot 配置说明
|
##### Moonshot 配置说明
|
||||||
- **API Key**: [点击到官网申请](https://platform.moonshot.cn/console/api-keys)
|
- **API Key**: [点击到官网申请](https://platform.moonshot.cn/console/api-keys)
|
||||||
- **Base Url**: 固定为 https://api.moonshot.cn/v1
|
- **Base Url**: 固定为 https://api.moonshot.cn/v1
|
||||||
- **Model Name**: 比如 moonshot-v1-8k,[点击查看模型列表](https://platform.moonshot.cn/docs/intro#%E6%A8%A1%E5%9E%8B%E5%88%97%E8%A1%A8)
|
- **Model Name**: 比如 moonshot-v1-8k,[点击查看模型列表](https://platform.moonshot.cn/docs/intro#%E6%A8%A1%E5%9E%8B%E5%88%97%E8%A1%A8)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if llm_provider == 'qwen':
|
if llm_provider == 'qwen':
|
||||||
if not llm_model_name:
|
if not llm_model_name:
|
||||||
llm_model_name = "qwen-max"
|
llm_model_name = "qwen-max"
|
||||||
with llm_helper:
|
with llm_helper:
|
||||||
tips = """
|
tips = """
|
||||||
##### 通义千问Qwen 配置说明
|
##### 通义千问Qwen 配置说明
|
||||||
- **API Key**: [点击到官网申请](https://dashscope.console.aliyun.com/apiKey)
|
- **API Key**: [点击到官网申请](https://dashscope.console.aliyun.com/apiKey)
|
||||||
- **Base Url**: 留空
|
- **Base Url**: 留空
|
||||||
- **Model Name**: 比如 qwen-max,[点击查看模型列表](https://help.aliyun.com/zh/dashscope/developer-reference/model-introduction#3ef6d0bcf91wy)
|
- **Model Name**: 比如 qwen-max,[点击查看模型列表](https://help.aliyun.com/zh/dashscope/developer-reference/model-introduction#3ef6d0bcf91wy)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if llm_provider == 'g4f':
|
if llm_provider == 'g4f':
|
||||||
if not llm_model_name:
|
if not llm_model_name:
|
||||||
llm_model_name = "gpt-3.5-turbo"
|
llm_model_name = "gpt-3.5-turbo"
|
||||||
with llm_helper:
|
with llm_helper:
|
||||||
tips = """
|
tips = """
|
||||||
##### gpt4free 配置说明
|
##### gpt4free 配置说明
|
||||||
> [GitHub开源项目](https://github.com/xtekky/gpt4free),可以免费使用GPT模型,但是**稳定性较差**
|
> [GitHub开源项目](https://github.com/xtekky/gpt4free),可以免费使用GPT模型,但是**稳定性较差**
|
||||||
- **API Key**: 随便填写,比如 123
|
- **API Key**: 随便填写,比如 123
|
||||||
- **Base Url**: 留空
|
- **Base Url**: 留空
|
||||||
- **Model Name**: 比如 gpt-3.5-turbo,[点击查看模型列表](https://github.com/xtekky/gpt4free/blob/main/g4f/models.py#L308)
|
- **Model Name**: 比如 gpt-3.5-turbo,[点击查看模型列表](https://github.com/xtekky/gpt4free/blob/main/g4f/models.py#L308)
|
||||||
"""
|
"""
|
||||||
if llm_provider == 'azure':
|
if llm_provider == 'azure':
|
||||||
with llm_helper:
|
with llm_helper:
|
||||||
tips = """
|
tips = """
|
||||||
##### Azure 配置说明
|
##### Azure 配置说明
|
||||||
> [点击查看如何部署模型](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/how-to/create-resource)
|
> [点击查看如何部署模型](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/how-to/create-resource)
|
||||||
- **API Key**: [点击到Azure后台创建](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI)
|
- **API Key**: [点击到Azure后台创建](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI)
|
||||||
- **Base Url**: 留空
|
- **Base Url**: 留空
|
||||||
- **Model Name**: 填写你实际的部署名
|
- **Model Name**: 填写你实际的部署名
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if llm_provider == 'gemini':
|
if llm_provider == 'gemini':
|
||||||
if not llm_model_name:
|
if not llm_model_name:
|
||||||
llm_model_name = "gemini-1.0-pro"
|
llm_model_name = "gemini-1.0-pro"
|
||||||
|
|
||||||
with llm_helper:
|
with llm_helper:
|
||||||
tips = """
|
tips = """
|
||||||
##### Gemini 配置说明
|
##### Gemini 配置说明
|
||||||
> 需要VPN开启全局流量模式
|
> 需要VPN开启全局流量模式
|
||||||
- **API Key**: [点击到官网申请](https://ai.google.dev/)
|
- **API Key**: [点击到官网申请](https://ai.google.dev/)
|
||||||
- **Base Url**: 留空
|
- **Base Url**: 留空
|
||||||
- **Model Name**: 比如 gemini-1.0-pro
|
- **Model Name**: 比如 gemini-1.0-pro
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if tips and config.ui['language'] == 'zh':
|
if tips and config.ui['language'] == 'zh':
|
||||||
st.info(tips)
|
st.info(tips)
|
||||||
|
|
||||||
st_llm_api_key = st.text_input(tr("API Key"), value=llm_api_key, type="password")
|
st_llm_api_key = st.text_input(tr("API Key"), value=llm_api_key, type="password")
|
||||||
st_llm_base_url = st.text_input(tr("Base Url"), value=llm_base_url)
|
st_llm_base_url = st.text_input(tr("Base Url"), value=llm_base_url)
|
||||||
st_llm_model_name = st.text_input(tr("Model Name"), value=llm_model_name)
|
st_llm_model_name = st.text_input(tr("Model Name"), value=llm_model_name)
|
||||||
|
|
||||||
if st_llm_api_key:
|
if st_llm_api_key:
|
||||||
config.app[f"{llm_provider}_api_key"] = st_llm_api_key
|
config.app[f"{llm_provider}_api_key"] = st_llm_api_key
|
||||||
if st_llm_base_url:
|
if st_llm_base_url:
|
||||||
config.app[f"{llm_provider}_base_url"] = st_llm_base_url
|
config.app[f"{llm_provider}_base_url"] = st_llm_base_url
|
||||||
if st_llm_model_name:
|
if st_llm_model_name:
|
||||||
config.app[f"{llm_provider}_model_name"] = st_llm_model_name
|
config.app[f"{llm_provider}_model_name"] = st_llm_model_name
|
||||||
|
|
||||||
if llm_provider == 'cloudflare':
|
if llm_provider == 'cloudflare':
|
||||||
st_llm_account_id = st.text_input(tr("Account ID"), value=llm_account_id)
|
st_llm_account_id = st.text_input(tr("Account ID"), value=llm_account_id)
|
||||||
if st_llm_account_id:
|
if st_llm_account_id:
|
||||||
config.app[f"{llm_provider}_account_id"] = st_llm_account_id
|
config.app[f"{llm_provider}_account_id"] = st_llm_account_id
|
||||||
|
|
||||||
with right_config_panel:
|
with right_config_panel:
|
||||||
pexels_api_keys = config.app.get("pexels_api_keys", [])
|
pexels_api_keys = config.app.get("pexels_api_keys", [])
|
||||||
if isinstance(pexels_api_keys, str):
|
if isinstance(pexels_api_keys, str):
|
||||||
pexels_api_keys = [pexels_api_keys]
|
pexels_api_keys = [pexels_api_keys]
|
||||||
pexels_api_key = ", ".join(pexels_api_keys)
|
pexels_api_key = ", ".join(pexels_api_keys)
|
||||||
|
|
||||||
pexels_api_key = st.text_input(tr("Pexels API Key"), value=pexels_api_key, type="password")
|
pexels_api_key = st.text_input(tr("Pexels API Key"), value=pexels_api_key, type="password")
|
||||||
pexels_api_key = pexels_api_key.replace(" ", "")
|
pexels_api_key = pexels_api_key.replace(" ", "")
|
||||||
if pexels_api_key:
|
if pexels_api_key:
|
||||||
config.app["pexels_api_keys"] = pexels_api_key.split(",")
|
config.app["pexels_api_keys"] = pexels_api_key.split(",")
|
||||||
|
|
||||||
panel = st.columns(3)
|
panel = st.columns(3)
|
||||||
left_panel = panel[0]
|
left_panel = panel[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user