mirror of
https://github.com/harry0703/MoneyPrinterTurbo.git
synced 2026-02-21 16:37:21 +08:00
feat: Add PDM support with auth & i18n enhancements
1. Added PDM project dependency management - Created pyproject.toml for dependency definitions - Added PDM lock file for reproducible builds - Created .pdm-python for virtual environment management 2. Enhanced authentication & configuration - Added user validation in base configuration - Implemented streamlit-authenticator for login functionality - Updated config.example.toml with user authentication fields 3. Improved internationalization (i18n) - Updated translation files for multiple languages (en, de, pt, vi, zh) - Enhanced i18n support in the web UI - Standardized translation structure across language files
This commit is contained in:
parent
36dffe8de3
commit
148d087ccd
1
.pdm-python
Normal file
1
.pdm-python
Normal file
@ -0,0 +1 @@
|
||||
/Users/yyh/Projects/self_projects/MoneyPrinterTurbo/.venv/bin/python
|
||||
159
README-en.md
159
README-en.md
@ -35,9 +35,18 @@ like to express our special thanks to
|
||||
**RecCloud (AI-Powered Multimedia Service Platform)** for providing a free `AI Video Generator` service based on this
|
||||
project. It allows for online use without deployment, which is very convenient.
|
||||
|
||||
https://reccloud.com
|
||||
- Chinese version: https://reccloud.cn
|
||||
- English version: https://reccloud.com
|
||||
|
||||

|
||||

|
||||
|
||||
## Thanks for Sponsorship 🙏
|
||||
|
||||
Thanks to Picwish https://picwish.cn for supporting and sponsoring this project, enabling continuous updates and maintenance.
|
||||
|
||||
Picwish focuses on the **image processing field**, providing a rich set of **image processing tools** that extremely simplify complex operations, truly making image processing easier.
|
||||
|
||||

|
||||
|
||||
## Features 🎯
|
||||
|
||||
@ -51,28 +60,26 @@ https://reccloud.com
|
||||
satisfactory one
|
||||
- [x] Supports setting the **duration of video clips**, facilitating adjustments to material switching frequency
|
||||
- [x] Supports video copy in both **Chinese** and **English**
|
||||
- [x] Supports **multiple voice** synthesis
|
||||
- [x] Supports **multiple voice** synthesis, with **real-time preview** of effects
|
||||
- [x] Supports **subtitle generation**, with adjustable `font`, `position`, `color`, `size`, and also
|
||||
supports `subtitle outlining`
|
||||
- [x] Supports **background music**, either random or specified music files, with adjustable `background music volume`
|
||||
- [x] Video material sources are **high-definition** and **royalty-free**
|
||||
- [x] Supports integration with various models such as **OpenAI**, **moonshot**, **Azure**, **gpt4free**, **one-api**,
|
||||
**qianwen**, **Google Gemini**, **Ollama** and more
|
||||
- [x] Video material sources are **high-definition** and **royalty-free**, and you can also use your own **local materials**
|
||||
- [x] Supports integration with various models such as **OpenAI**, **Moonshot**, **Azure**, **gpt4free**, **one-api**,
|
||||
**Qwen**, **Google Gemini**, **Ollama**, **DeepSeek**, **ERNIE** and more
|
||||
- For users in China, it is recommended to use **DeepSeek** or **Moonshot** as the large model provider (directly accessible in China, no VPN needed. Free credits upon registration, generally sufficient for use)
|
||||
|
||||
❓[How to Use the Free OpenAI GPT-3.5 Model?](https://github.com/harry0703/MoneyPrinterTurbo/blob/main/README-en.md#common-questions-)
|
||||
|
||||
### Future Plans 📅
|
||||
|
||||
- [ ] Introduce support for GPT-SoVITS dubbing
|
||||
- [ ] Enhance voice synthesis with large models for a more natural and emotionally resonant voice output
|
||||
- [ ] Incorporate video transition effects to ensure a smoother viewing experience
|
||||
- [ ] Improve the relevance of video content
|
||||
- [ ] Add options for video length: short, medium, long
|
||||
- [ ] Package the application into a one-click launch bundle for Windows and macOS for ease of use
|
||||
- [ ] Enable the use of custom materials
|
||||
- [ ] Offer voiceover and background music options with real-time preview
|
||||
- [ ] Support a wider range of voice synthesis providers, such as OpenAI TTS, Azure TTS
|
||||
- [ ] Automate the upload process to the YouTube platform
|
||||
- [ ] GPT-SoVITS dubbing support
|
||||
- [ ] Optimize voice synthesis using large models for more natural and emotionally rich voice output
|
||||
- [ ] Add video transition effects for a smoother viewing experience
|
||||
- [ ] Add more video material sources, improve the matching between video materials and script
|
||||
- [ ] Add video length options: short, medium, long
|
||||
- [ ] Support more voice synthesis providers, such as OpenAI TTS
|
||||
- [ ] Automate upload to YouTube platform
|
||||
|
||||
## Video Demos 📺
|
||||
|
||||
@ -115,10 +122,27 @@ https://reccloud.com
|
||||
- Recommended minimum 4 CPU cores or more, 8G of memory or more, GPU is not required
|
||||
- Windows 10 or MacOS 11.0, and their later versions
|
||||
|
||||
## Quick Start 🚀
|
||||
|
||||
Download the one-click startup package, extract and use directly (the path should not contain **Chinese characters**, **special characters**, or **spaces**)
|
||||
|
||||
### Windows
|
||||
- Baidu Netdisk (1.2.1 latest version): https://pan.baidu.com/s/1pSNjxTYiVENulTLm6zieMQ?pwd=g36q Extraction code: g36q
|
||||
|
||||
After downloading, it is recommended to **double-click** `update.bat` first to update to the **latest code**, then double-click `start.bat` to launch
|
||||
|
||||
After launching, the browser will open automatically (if it opens blank, it is recommended to use **Chrome** or **Edge**)
|
||||
|
||||
### Other Systems
|
||||
|
||||
One-click startup packages have not been created yet. See the **Installation & Deployment** section below. It is recommended to use **docker** for deployment, which is more convenient.
|
||||
|
||||
## Installation & Deployment 📥
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Try to avoid using **Chinese paths** to prevent unpredictable issues
|
||||
- Ensure your **network** is stable, meaning you can access foreign websites normally
|
||||
- Ensure your **network** is stable, VPN needs to be in `global traffic` mode
|
||||
|
||||
#### ① Clone the Project
|
||||
|
||||
@ -132,11 +156,6 @@ git clone https://github.com/harry0703/MoneyPrinterTurbo.git
|
||||
- Follow the instructions in the `config.toml` file to configure `pexels_api_keys` and `llm_provider`, and according to
|
||||
the llm_provider's service provider, set up the corresponding API Key
|
||||
|
||||
#### ③ Configure Large Language Models (LLM)
|
||||
|
||||
- To use `GPT-4.0` or `GPT-3.5`, you need an `API Key` from `OpenAI`. If you don't have one, you can set `llm_provider`
|
||||
to `g4f` (a free-to-use GPT library https://github.com/xtekky/gpt4free)
|
||||
|
||||
### Docker Deployment 🐳
|
||||
|
||||
#### ① Launch the Docker Container
|
||||
@ -164,27 +183,28 @@ Open your browser and visit http://0.0.0.0:8080/docs Or http://0.0.0.0:8080/redo
|
||||
|
||||
### Manual Deployment 📦
|
||||
|
||||
#### ① Create a Python Virtual Environment
|
||||
> Video tutorials
|
||||
>
|
||||
> - Complete usage demonstration: https://v.douyin.com/iFhnwsKY/
|
||||
> - How to deploy on Windows: https://v.douyin.com/iFyjoW3M
|
||||
|
||||
It is recommended to create a Python virtual environment
|
||||
using [conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
|
||||
#### ① Install Dependencies
|
||||
|
||||
It is recommended to use [pdm](https://pdm-project.org/en/latest/#installation)
|
||||
|
||||
```shell
|
||||
git clone https://github.com/harry0703/MoneyPrinterTurbo.git
|
||||
cd MoneyPrinterTurbo
|
||||
conda create -n MoneyPrinterTurbo python=3.11
|
||||
conda activate MoneyPrinterTurbo
|
||||
pip install -r requirements.txt
|
||||
pdm sync
|
||||
```
|
||||
|
||||
#### ② Install ImageMagick
|
||||
|
||||
###### Windows:
|
||||
|
||||
- Download https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-29-Q16-x64-static.exe
|
||||
- Download https://imagemagick.org/script/download.php Choose the Windows version, make sure to select the **static library** version, such as ImageMagick-7.1.1-32-Q16-x64-**static**.exe
|
||||
- Install the downloaded ImageMagick, **do not change the installation path**
|
||||
- Modify the `config.toml` configuration file, set `imagemagick_path` to your actual installation path (if you didn't
|
||||
change the path during installation, just uncomment it)
|
||||
- Modify the `config.toml` configuration file, set `imagemagick_path` to your actual installation path
|
||||
|
||||
###### MacOS:
|
||||
|
||||
@ -211,14 +231,12 @@ Note that you need to execute the following commands in the `root directory` of
|
||||
###### Windows
|
||||
|
||||
```bat
|
||||
conda activate MoneyPrinterTurbo
|
||||
webui.bat
|
||||
```
|
||||
|
||||
###### MacOS or Linux
|
||||
|
||||
```shell
|
||||
conda activate MoneyPrinterTurbo
|
||||
sh webui.sh
|
||||
```
|
||||
|
||||
@ -237,13 +255,15 @@ online for a quick experience.
|
||||
|
||||
A list of all supported voices can be viewed here: [Voice List](./docs/voice-list.txt)
|
||||
|
||||
2024-04-16 v1.1.2 Added 9 new Azure voice synthesis voices that require API KEY configuration. These voices sound more realistic.
|
||||
|
||||
## Subtitle Generation 📜
|
||||
|
||||
Currently, there are 2 ways to generate subtitles:
|
||||
|
||||
- edge: Faster generation speed, better performance, no specific requirements for computer configuration, but the
|
||||
- **edge**: Faster generation speed, better performance, no specific requirements for computer configuration, but the
|
||||
quality may be unstable
|
||||
- whisper: Slower generation speed, poorer performance, specific requirements for computer configuration, but more
|
||||
- **whisper**: Slower generation speed, poorer performance, specific requirements for computer configuration, but more
|
||||
reliable quality
|
||||
|
||||
You can switch between them by modifying the `subtitle_provider` in the `config.toml` configuration file
|
||||
@ -252,18 +272,22 @@ It is recommended to use `edge` mode, and switch to `whisper` mode if the qualit
|
||||
satisfactory.
|
||||
|
||||
> Note:
|
||||
> If left blank, it means no subtitles will be generated.
|
||||
>
|
||||
> 1. In whisper mode, you need to download a model file from HuggingFace, about 3GB in size, please ensure good internet connectivity
|
||||
> 2. If left blank, it means no subtitles will be generated.
|
||||
|
||||
**Download whisper**
|
||||
- Please ensure a good internet connectivity
|
||||
- `whisper` model can be downloaded from HuggingFace: https://huggingface.co/openai/whisper-large-v3/tree/main
|
||||
> Since HuggingFace is not accessible in China, you can use the following methods to download the `whisper-large-v3` model file
|
||||
|
||||
After downloading the model to local machine, copy the whole folder and put it into the following path: `.\MoneyPrinterTurbo\models`
|
||||
Download links:
|
||||
|
||||
This is what the final path should look like: `.\MoneyPrinterTurbo\models\whisper-large-v3`
|
||||
- Baidu Netdisk: https://pan.baidu.com/s/11h3Q6tsDtjQKTjUu3sc5cA?pwd=xjs9
|
||||
- Quark Netdisk: https://pan.quark.cn/s/3ee3d991d64b
|
||||
|
||||
After downloading the model, extract it and place the entire directory in `.\MoneyPrinterTurbo\models`,
|
||||
The final file path should look like this: `.\MoneyPrinterTurbo\models\whisper-large-v3`
|
||||
|
||||
```
|
||||
MoneyPrinterTurbo
|
||||
MoneyPrinterTurbo
|
||||
├─models
|
||||
│ └─whisper-large-v3
|
||||
│ config.json
|
||||
@ -304,6 +328,16 @@ Once successfully started, modify the `config.toml` configuration as follows:
|
||||
- Change `openai_base_url` to `http://localhost:3040/v1/`
|
||||
- Set `openai_model_name` to `gpt-3.5-turbo`
|
||||
|
||||
> Note: This method may be unstable
|
||||
|
||||
### ❓AttributeError: 'str' object has no attribute 'choices'
|
||||
|
||||
This issue is caused by the large language model not returning a correct response.
|
||||
|
||||
It's likely a network issue. Use a **VPN**, or set `openai_base_url` to your proxy, which should solve the problem.
|
||||
|
||||
At the same time, it is recommended to use **Moonshot** or **DeepSeek** as the large model provider, as these service providers have faster access and are more stable in China.
|
||||
|
||||
### ❓RuntimeError: No ffmpeg exe could be found
|
||||
|
||||
Normally, ffmpeg will be automatically downloaded and detected.
|
||||
@ -328,14 +362,14 @@ ffmpeg_path = "C:\\Users\\harry\\Downloads\\ffmpeg.exe"
|
||||
[issue 56](https://github.com/harry0703/MoneyPrinterTurbo/issues/56)
|
||||
|
||||
```
|
||||
failed to generate audio, maybe the network is not available.
|
||||
failed to generate audio, maybe the network is not available.
|
||||
if you are in China, please use a VPN.
|
||||
```
|
||||
|
||||
[issue 44](https://github.com/harry0703/MoneyPrinterTurbo/issues/44)
|
||||
|
||||
```
|
||||
failed to download videos, maybe the network is not available.
|
||||
failed to download videos, maybe the network is not available.
|
||||
if you are in China, please use a VPN.
|
||||
```
|
||||
|
||||
@ -355,6 +389,43 @@ For Linux systems, you can manually install it, refer to https://cn.linux-consol
|
||||
|
||||
Thanks to [@wangwenqiao666](https://github.com/wangwenqiao666) for their research and exploration
|
||||
|
||||
### ❓ImageMagick's security policy prevents operations related to temporary file @/tmp/tmpur5hyyto.txt
|
||||
|
||||
You can find these policies in ImageMagick's configuration file policy.xml.
|
||||
This file is usually located in /etc/ImageMagick-`X`/ or a similar location in the ImageMagick installation directory.
|
||||
Modify the entry containing `pattern="@"`, change `rights="none"` to `rights="read|write"` to allow read and write operations on files.
|
||||
|
||||
### ❓OSError: [Errno 24] Too many open files
|
||||
|
||||
This issue is caused by the system's limit on the number of open files. You can solve it by modifying the system's file open limit.
|
||||
|
||||
Check the current limit:
|
||||
|
||||
```shell
|
||||
ulimit -n
|
||||
```
|
||||
|
||||
If it's too low, you can increase it, for example:
|
||||
|
||||
```shell
|
||||
ulimit -n 10240
|
||||
```
|
||||
|
||||
### ❓Whisper model download failed, with the following error
|
||||
|
||||
LocalEntryNotfoundEror: Cannot find an appropriate cached snapshotfolderfor the specified revision on the local disk and
|
||||
outgoing trafic has been disabled.
|
||||
To enablerepo look-ups and downloads online, pass 'local files only=False' as input.
|
||||
|
||||
or
|
||||
|
||||
An error occured while synchronizing the model Systran/faster-whisper-large-v3 from the Hugging Face Hub:
|
||||
An error happened while trying to locate the files on the Hub and we cannot find the appropriate snapshot folder for the
|
||||
specified revision on the local disk. Please check your internet connection and try again.
|
||||
Trying to load the model directly from the local cache, if it exists.
|
||||
|
||||
Solution: [Click to see how to manually download the model from netdisk](#subtitle-generation-)
|
||||
|
||||
## Feedback & Suggestions 📢
|
||||
|
||||
- You can submit an [issue](https://github.com/harry0703/MoneyPrinterTurbo/issues) or
|
||||
|
||||
10
README.md
10
README.md
@ -182,16 +182,14 @@ docker-compose up
|
||||
- 完整的使用演示:https://v.douyin.com/iFhnwsKY/
|
||||
- 如何在Windows上部署:https://v.douyin.com/iFyjoW3M
|
||||
|
||||
#### ① 创建虚拟环境
|
||||
#### ① 依赖安装
|
||||
|
||||
建议使用 [conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) 创建 python 虚拟环境
|
||||
建议使用 [pdm](https://pdm-project.org/en/latest/#installation)
|
||||
|
||||
```shell
|
||||
git clone https://github.com/harry0703/MoneyPrinterTurbo.git
|
||||
cd MoneyPrinterTurbo
|
||||
conda create -n MoneyPrinterTurbo python=3.11
|
||||
conda activate MoneyPrinterTurbo
|
||||
pip install -r requirements.txt
|
||||
pdm sync
|
||||
```
|
||||
|
||||
#### ② 安装好 ImageMagick
|
||||
@ -222,14 +220,12 @@ pip install -r requirements.txt
|
||||
###### Windows
|
||||
|
||||
```bat
|
||||
conda activate MoneyPrinterTurbo
|
||||
webui.bat
|
||||
```
|
||||
|
||||
###### MacOS or Linux
|
||||
|
||||
```shell
|
||||
conda activate MoneyPrinterTurbo
|
||||
sh webui.sh
|
||||
```
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ project_description = _cfg.get(
|
||||
"project_description",
|
||||
"<a href='https://github.com/harry0703/MoneyPrinterTurbo'>https://github.com/harry0703/MoneyPrinterTurbo</a>",
|
||||
)
|
||||
project_version = _cfg.get("project_version", "1.2.2")
|
||||
project_version = _cfg.get("project_version", "1.2.3")
|
||||
reload_debug = False
|
||||
|
||||
imagemagick_path = app.get("imagemagick_path", "")
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
[app]
|
||||
|
||||
video_source = "pexels" # "pexels" or "pixabay"
|
||||
|
||||
# 是否隐藏配置面板
|
||||
# hide_config = false
|
||||
|
||||
[user]
|
||||
# 管理员用户名和密码,用于访问基础设置
|
||||
username = "admin"
|
||||
password = "admin"
|
||||
email = "admin@example.com" # 添加email字段,用于身份验证
|
||||
# Pexels API Key
|
||||
# Register at https://www.pexels.com/api/ to get your API key.
|
||||
# You can use multiple keys to avoid rate limits.
|
||||
|
||||
32
pyproject.toml
Normal file
32
pyproject.toml
Normal file
@ -0,0 +1,32 @@
|
||||
[project]
|
||||
name = "MoneyPrinterTurbo"
|
||||
version = "1.2.3"
|
||||
description = "Default template for PDM package"
|
||||
authors = [
|
||||
{name = "yyhhyyyyyy", email = "yyhhyyyyyy8@gmail.com"},
|
||||
]
|
||||
dependencies = [
|
||||
"moviepy==2.1.1",
|
||||
"streamlit==1.40.2",
|
||||
"edge-tts==6.1.19",
|
||||
"fastapi==0.115.6",
|
||||
"uvicorn==0.32.1",
|
||||
"openai==1.56.1",
|
||||
"faster-whisper==1.1.0",
|
||||
"loguru==0.7.2",
|
||||
"google-generativeai==0.8.3",
|
||||
"dashscope==1.20.14",
|
||||
"g4f==0.3.8.1",
|
||||
"azure-cognitiveservices-speech==1.41.1",
|
||||
"redis==5.2.0",
|
||||
"python-multipart==0.0.19",
|
||||
"streamlit-authenticator==0.4.1",
|
||||
"pyyaml",
|
||||
]
|
||||
requires-python = "==3.11.*"
|
||||
readme = "README.md"
|
||||
license = {text = "MIT"}
|
||||
|
||||
|
||||
[tool.pdm]
|
||||
distribution = false
|
||||
631
webui/Main.py
631
webui/Main.py
@ -4,6 +4,7 @@ import sys
|
||||
from uuid import uuid4
|
||||
|
||||
import streamlit as st
|
||||
import streamlit_authenticator as stauth
|
||||
from loguru import logger
|
||||
|
||||
# Add the root directory of the project to the system path to allow importing modules from the project
|
||||
@ -15,7 +16,6 @@ if root_dir not in sys.path:
|
||||
print("")
|
||||
|
||||
from app.config import config
|
||||
from app.models.const import FILE_TYPE_IMAGES, FILE_TYPE_VIDEOS
|
||||
from app.models.schema import (
|
||||
MaterialInfo,
|
||||
VideoAspect,
|
||||
@ -46,7 +46,41 @@ hide_streamlit_style = """
|
||||
<style>#root > div:nth-child(1) > div > div > div > div > section > div {padding-top: 0rem;}</style>
|
||||
"""
|
||||
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
||||
st.title(f"MoneyPrinterTurbo v{config.project_version}")
|
||||
# 定义资源目录
|
||||
font_dir = os.path.join(root_dir, "resource", "fonts")
|
||||
song_dir = os.path.join(root_dir, "resource", "songs")
|
||||
i18n_dir = os.path.join(root_dir, "webui", "i18n")
|
||||
config_file = os.path.join(root_dir, "webui", ".streamlit", "webui.toml")
|
||||
system_locale = utils.get_system_locale()
|
||||
|
||||
# 加载语言文件
|
||||
locales = utils.load_locales(i18n_dir)
|
||||
|
||||
# 创建一个顶部栏,包含标题和语言选择
|
||||
title_col, lang_col = st.columns([3, 1])
|
||||
|
||||
with title_col:
|
||||
st.title(f"MoneyPrinterTurbo v{config.project_version}")
|
||||
|
||||
with lang_col:
|
||||
display_languages = []
|
||||
selected_index = 0
|
||||
for i, code in enumerate(locales.keys()):
|
||||
display_languages.append(f"{code} - {locales[code].get('Language')}")
|
||||
if code == st.session_state.get("ui_language", ""):
|
||||
selected_index = i
|
||||
|
||||
selected_language = st.selectbox(
|
||||
"Language / 语言",
|
||||
options=display_languages,
|
||||
index=selected_index,
|
||||
key="top_language_selector",
|
||||
label_visibility="collapsed",
|
||||
)
|
||||
if selected_language:
|
||||
code = selected_language.split(" - ")[0].strip()
|
||||
st.session_state["ui_language"] = code
|
||||
config.ui["language"] = code
|
||||
|
||||
support_locales = [
|
||||
"zh-CN",
|
||||
@ -59,11 +93,6 @@ support_locales = [
|
||||
"th-TH",
|
||||
]
|
||||
|
||||
font_dir = os.path.join(root_dir, "resource", "fonts")
|
||||
song_dir = os.path.join(root_dir, "resource", "songs")
|
||||
i18n_dir = os.path.join(root_dir, "webui", "i18n")
|
||||
config_file = os.path.join(root_dir, "webui", ".streamlit", "webui.toml")
|
||||
system_locale = utils.get_system_locale()
|
||||
# print(f"******** system locale: {system_locale} ********")
|
||||
|
||||
if "video_subject" not in st.session_state:
|
||||
@ -167,269 +196,361 @@ def tr(key):
|
||||
return loc.get("Translation", {}).get(key, key)
|
||||
|
||||
|
||||
# 加载用户认证配置
|
||||
# 确保用户配置存在并包含所有必需的字段
|
||||
if "user" not in config._cfg:
|
||||
config._cfg["user"] = {
|
||||
"username": "admin",
|
||||
"password": "admin",
|
||||
"email": "admin@example.com",
|
||||
}
|
||||
config.save_config()
|
||||
elif "email" not in config._cfg["user"]:
|
||||
# 如果用户配置存在但没有email字段,添加默认email
|
||||
config._cfg["user"]["email"] = f"{config._cfg['user']['username']}@example.com"
|
||||
config.save_config()
|
||||
|
||||
# 创建认证对象
|
||||
authenticator = None
|
||||
auth_status = False
|
||||
|
||||
# 检查是否需要身份验证才能访问配置
|
||||
if not config.app.get("hide_config", False):
|
||||
# 创建认证配置
|
||||
credentials = {
|
||||
"usernames": {
|
||||
config._cfg["user"]["username"]: {
|
||||
"name": config._cfg["user"]["username"],
|
||||
"password": config._cfg["user"]["password"],
|
||||
"email": config._cfg["user"]["email"],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cookie_name = "mpt_auth_cookie"
|
||||
cookie_key = "mpt_auth_key_123"
|
||||
cookie_expiry_days = 30
|
||||
|
||||
authenticator = stauth.Authenticate(
|
||||
credentials, cookie_name, cookie_key, cookie_expiry_days
|
||||
)
|
||||
|
||||
# 从 session_state 获取认证状态
|
||||
auth_status = st.session_state.get("authentication_status")
|
||||
|
||||
st.write(tr("Get Help"))
|
||||
|
||||
llm_provider = config.app.get("llm_provider", "").lower()
|
||||
|
||||
if not config.app.get("hide_config", False):
|
||||
# 创建基础设置折叠框
|
||||
with st.expander(tr("Basic Settings"), expanded=False):
|
||||
config_panels = st.columns(3)
|
||||
left_config_panel = config_panels[0]
|
||||
middle_config_panel = config_panels[1]
|
||||
right_config_panel = config_panels[2]
|
||||
with left_config_panel:
|
||||
display_languages = []
|
||||
selected_index = 0
|
||||
for i, code in enumerate(locales.keys()):
|
||||
display_languages.append(f"{code} - {locales[code].get('Language')}")
|
||||
if code == st.session_state["ui_language"]:
|
||||
selected_index = i
|
||||
# 检查用户是否已登录
|
||||
if not auth_status:
|
||||
# 用户未登录,显示登录表单
|
||||
st.warning(tr("Please login to access settings"))
|
||||
|
||||
selected_language = st.selectbox(
|
||||
tr("Language"), options=display_languages, index=selected_index
|
||||
)
|
||||
if selected_language:
|
||||
code = selected_language.split(" - ")[0].strip()
|
||||
st.session_state["ui_language"] = code
|
||||
config.ui["language"] = code
|
||||
# 显示登录表单
|
||||
try:
|
||||
# 自定义登录表单文本,使用我们的翻译系统
|
||||
login_form_fields = {
|
||||
"Form name": tr("Login"),
|
||||
"Username": tr("Username"),
|
||||
"Password": tr("Password"),
|
||||
"Login": tr("Login"),
|
||||
}
|
||||
|
||||
# 是否禁用日志显示
|
||||
hide_log = st.checkbox(
|
||||
tr("Hide Log"), value=config.app.get("hide_log", False)
|
||||
)
|
||||
config.ui["hide_log"] = hide_log
|
||||
authenticator.login(location="main", fields=login_form_fields)
|
||||
|
||||
with middle_config_panel:
|
||||
# openai
|
||||
# moonshot (月之暗面)
|
||||
# oneapi
|
||||
# g4f
|
||||
# azure
|
||||
# qwen (通义千问)
|
||||
# gemini
|
||||
# ollama
|
||||
llm_providers = [
|
||||
"OpenAI",
|
||||
"Moonshot",
|
||||
"Azure",
|
||||
"Qwen",
|
||||
"DeepSeek",
|
||||
"Gemini",
|
||||
"Ollama",
|
||||
"G4f",
|
||||
"OneAPI",
|
||||
"Cloudflare",
|
||||
"ERNIE",
|
||||
]
|
||||
saved_llm_provider = config.app.get("llm_provider", "OpenAI").lower()
|
||||
saved_llm_provider_index = 0
|
||||
for i, provider in enumerate(llm_providers):
|
||||
if provider.lower() == saved_llm_provider:
|
||||
saved_llm_provider_index = i
|
||||
break
|
||||
# 从 session_state 获取认证状态
|
||||
auth_status = st.session_state.get("authentication_status")
|
||||
|
||||
llm_provider = st.selectbox(
|
||||
tr("LLM Provider"),
|
||||
options=llm_providers,
|
||||
index=saved_llm_provider_index,
|
||||
)
|
||||
llm_helper = st.container()
|
||||
llm_provider = llm_provider.lower()
|
||||
config.app["llm_provider"] = llm_provider
|
||||
if auth_status is False:
|
||||
st.error(tr("Incorrect username or password"))
|
||||
elif auth_status is None:
|
||||
st.info(tr("Please enter your username and password"))
|
||||
|
||||
llm_api_key = config.app.get(f"{llm_provider}_api_key", "")
|
||||
llm_secret_key = config.app.get(
|
||||
f"{llm_provider}_secret_key", ""
|
||||
) # only for baidu ernie
|
||||
llm_base_url = config.app.get(f"{llm_provider}_base_url", "")
|
||||
llm_model_name = config.app.get(f"{llm_provider}_model_name", "")
|
||||
llm_account_id = config.app.get(f"{llm_provider}_account_id", "")
|
||||
# 如果用户登录成功,刷新页面以显示配置面板
|
||||
if auth_status:
|
||||
st.rerun()
|
||||
except Exception as e:
|
||||
st.error(f"{tr('Login Error')}: {e}")
|
||||
|
||||
tips = ""
|
||||
if llm_provider == "ollama":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "qwen:7b"
|
||||
if not llm_base_url:
|
||||
llm_base_url = "http://localhost:11434/v1"
|
||||
# 只有在用户已登录时才显示配置面板
|
||||
if auth_status:
|
||||
config_panels = st.columns(3)
|
||||
left_config_panel = config_panels[0]
|
||||
middle_config_panel = config_panels[1]
|
||||
right_config_panel = config_panels[2]
|
||||
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### Ollama配置说明
|
||||
- **API Key**: 随便填写,比如 123
|
||||
- **Base Url**: 一般为 http://localhost:11434/v1
|
||||
- 如果 `MoneyPrinterTurbo` 和 `Ollama` **不在同一台机器上**,需要填写 `Ollama` 机器的IP地址
|
||||
- 如果 `MoneyPrinterTurbo` 是 `Docker` 部署,建议填写 `http://host.docker.internal:11434/v1`
|
||||
- **Model Name**: 使用 `ollama list` 查看,比如 `qwen:7b`
|
||||
"""
|
||||
# 左侧面板 - 日志设置
|
||||
with left_config_panel:
|
||||
# 是否禁用日志显示
|
||||
hide_log = st.checkbox(
|
||||
tr("Hide Log"), value=config.app.get("hide_log", False)
|
||||
)
|
||||
config.ui["hide_log"] = hide_log
|
||||
|
||||
if llm_provider == "openai":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "gpt-3.5-turbo"
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### OpenAI 配置说明
|
||||
> 需要VPN开启全局流量模式
|
||||
- **API Key**: [点击到官网申请](https://platform.openai.com/api-keys)
|
||||
- **Base Url**: 可以留空
|
||||
- **Model Name**: 填写**有权限**的模型,[点击查看模型列表](https://platform.openai.com/settings/organization/limits)
|
||||
"""
|
||||
# 中间面板 - LLM 设置
|
||||
with middle_config_panel:
|
||||
# openai
|
||||
# moonshot (月之暗面)
|
||||
# oneapi
|
||||
# g4f
|
||||
# azure
|
||||
# qwen (通义千问)
|
||||
# gemini
|
||||
# ollama
|
||||
llm_providers = [
|
||||
"OpenAI",
|
||||
"Moonshot",
|
||||
"Azure",
|
||||
"Qwen",
|
||||
"DeepSeek",
|
||||
"Gemini",
|
||||
"Ollama",
|
||||
"G4f",
|
||||
"OneAPI",
|
||||
"Cloudflare",
|
||||
"ERNIE",
|
||||
]
|
||||
saved_llm_provider = config.app.get("llm_provider", "OpenAI").lower()
|
||||
saved_llm_provider_index = 0
|
||||
for i, provider in enumerate(llm_providers):
|
||||
if provider.lower() == saved_llm_provider:
|
||||
saved_llm_provider_index = i
|
||||
break
|
||||
|
||||
if llm_provider == "moonshot":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "moonshot-v1-8k"
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### Moonshot 配置说明
|
||||
- **API Key**: [点击到官网申请](https://platform.moonshot.cn/console/api-keys)
|
||||
- **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)
|
||||
"""
|
||||
if llm_provider == "oneapi":
|
||||
if not llm_model_name:
|
||||
llm_model_name = (
|
||||
"claude-3-5-sonnet-20240620" # 默认模型,可以根据需要调整
|
||||
llm_provider = st.selectbox(
|
||||
tr("LLM Provider"),
|
||||
options=llm_providers,
|
||||
index=saved_llm_provider_index,
|
||||
)
|
||||
llm_helper = st.container()
|
||||
llm_provider = llm_provider.lower()
|
||||
config.app["llm_provider"] = llm_provider
|
||||
|
||||
llm_api_key = config.app.get(f"{llm_provider}_api_key", "")
|
||||
llm_secret_key = config.app.get(
|
||||
f"{llm_provider}_secret_key", ""
|
||||
) # only for baidu ernie
|
||||
llm_base_url = config.app.get(f"{llm_provider}_base_url", "")
|
||||
llm_model_name = config.app.get(f"{llm_provider}_model_name", "")
|
||||
llm_account_id = config.app.get(f"{llm_provider}_account_id", "")
|
||||
|
||||
tips = ""
|
||||
if llm_provider == "ollama":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "qwen:7b"
|
||||
if not llm_base_url:
|
||||
llm_base_url = "http://localhost:11434/v1"
|
||||
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### Ollama配置说明
|
||||
- **API Key**: 随便填写,比如 123
|
||||
- **Base Url**: 一般为 http://localhost:11434/v1
|
||||
- 如果 `MoneyPrinterTurbo` 和 `Ollama` **不在同一台机器上**,需要填写 `Ollama` 机器的IP地址
|
||||
- 如果 `MoneyPrinterTurbo` 是 `Docker` 部署,建议填写 `http://host.docker.internal:11434/v1`
|
||||
- **Model Name**: 使用 `ollama list` 查看,比如 `qwen:7b`
|
||||
"""
|
||||
|
||||
if llm_provider == "openai":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "gpt-3.5-turbo"
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### OpenAI 配置说明
|
||||
> 需要VPN开启全局流量模式
|
||||
- **API Key**: [点击到官网申请](https://platform.openai.com/api-keys)
|
||||
- **Base Url**: 可以留空
|
||||
- **Model Name**: 填写**有权限**的模型,[点击查看模型列表](https://platform.openai.com/settings/organization/limits)
|
||||
"""
|
||||
|
||||
if llm_provider == "moonshot":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "moonshot-v1-8k"
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### Moonshot 配置说明
|
||||
- **API Key**: [点击到官网申请](https://platform.moonshot.cn/console/api-keys)
|
||||
- **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)
|
||||
"""
|
||||
if llm_provider == "oneapi":
|
||||
if not llm_model_name:
|
||||
llm_model_name = (
|
||||
"claude-3-5-sonnet-20240620" # 默认模型,可以根据需要调整
|
||||
)
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### OneAPI 配置说明
|
||||
- **API Key**: 填写您的 OneAPI 密钥
|
||||
- **Base Url**: 填写 OneAPI 的基础 URL
|
||||
- **Model Name**: 填写您要使用的模型名称,例如 claude-3-5-sonnet-20240620
|
||||
"""
|
||||
|
||||
if llm_provider == "qwen":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "qwen-max"
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### 通义千问Qwen 配置说明
|
||||
- **API Key**: [点击到官网申请](https://dashscope.console.aliyun.com/apiKey)
|
||||
- **Base Url**: 留空
|
||||
- **Model Name**: 比如 qwen-max,[点击查看模型列表](https://help.aliyun.com/zh/dashscope/developer-reference/model-introduction#3ef6d0bcf91wy)
|
||||
"""
|
||||
|
||||
if llm_provider == "g4f":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "gpt-3.5-turbo"
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### gpt4free 配置说明
|
||||
> [GitHub开源项目](https://github.com/xtekky/gpt4free),可以免费使用GPT模型,但是**稳定性较差**
|
||||
- **API Key**: 随便填写,比如 123
|
||||
- **Base Url**: 留空
|
||||
- **Model Name**: 比如 gpt-3.5-turbo,[点击查看模型列表](https://github.com/xtekky/gpt4free/blob/main/g4f/models.py#L308)
|
||||
"""
|
||||
if llm_provider == "azure":
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### Azure 配置说明
|
||||
> [点击查看如何部署模型](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)
|
||||
- **Base Url**: 留空
|
||||
- **Model Name**: 填写你实际的部署名
|
||||
"""
|
||||
|
||||
if llm_provider == "gemini":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "gemini-1.0-pro"
|
||||
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### Gemini 配置说明
|
||||
> 需要VPN开启全局流量模式
|
||||
- **API Key**: [点击到官网申请](https://ai.google.dev/)
|
||||
- **Base Url**: 留空
|
||||
- **Model Name**: 比如 gemini-1.0-pro
|
||||
"""
|
||||
|
||||
if llm_provider == "deepseek":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "deepseek-chat"
|
||||
if not llm_base_url:
|
||||
llm_base_url = "https://api.deepseek.com"
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### DeepSeek 配置说明
|
||||
- **API Key**: [点击到官网申请](https://platform.deepseek.com/api_keys)
|
||||
- **Base Url**: 固定为 https://api.deepseek.com
|
||||
- **Model Name**: 固定为 deepseek-chat
|
||||
"""
|
||||
|
||||
if llm_provider == "ernie":
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### 百度文心一言 配置说明
|
||||
- **API Key**: [点击到官网申请](https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application)
|
||||
- **Secret Key**: [点击到官网申请](https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application)
|
||||
- **Base Url**: 填写 **请求地址** [点击查看文档](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/jlil56u11#%E8%AF%B7%E6%B1%82%E8%AF%B4%E6%98%8E)
|
||||
"""
|
||||
|
||||
if tips and config.ui["language"] == "zh":
|
||||
st.warning(
|
||||
"中国用户建议使用 **DeepSeek** 或 **Moonshot** 作为大模型提供商\n- 国内可直接访问,不需要VPN \n- 注册就送额度,基本够用"
|
||||
)
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### OneAPI 配置说明
|
||||
- **API Key**: 填写您的 OneAPI 密钥
|
||||
- **Base Url**: 填写 OneAPI 的基础 URL
|
||||
- **Model Name**: 填写您要使用的模型名称,例如 claude-3-5-sonnet-20240620
|
||||
"""
|
||||
st.info(tips)
|
||||
|
||||
if llm_provider == "qwen":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "qwen-max"
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### 通义千问Qwen 配置说明
|
||||
- **API Key**: [点击到官网申请](https://dashscope.console.aliyun.com/apiKey)
|
||||
- **Base Url**: 留空
|
||||
- **Model Name**: 比如 qwen-max,[点击查看模型列表](https://help.aliyun.com/zh/dashscope/developer-reference/model-introduction#3ef6d0bcf91wy)
|
||||
"""
|
||||
|
||||
if llm_provider == "g4f":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "gpt-3.5-turbo"
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### gpt4free 配置说明
|
||||
> [GitHub开源项目](https://github.com/xtekky/gpt4free),可以免费使用GPT模型,但是**稳定性较差**
|
||||
- **API Key**: 随便填写,比如 123
|
||||
- **Base Url**: 留空
|
||||
- **Model Name**: 比如 gpt-3.5-turbo,[点击查看模型列表](https://github.com/xtekky/gpt4free/blob/main/g4f/models.py#L308)
|
||||
"""
|
||||
if llm_provider == "azure":
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### Azure 配置说明
|
||||
> [点击查看如何部署模型](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)
|
||||
- **Base Url**: 留空
|
||||
- **Model Name**: 填写你实际的部署名
|
||||
"""
|
||||
|
||||
if llm_provider == "gemini":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "gemini-1.0-pro"
|
||||
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### Gemini 配置说明
|
||||
> 需要VPN开启全局流量模式
|
||||
- **API Key**: [点击到官网申请](https://ai.google.dev/)
|
||||
- **Base Url**: 留空
|
||||
- **Model Name**: 比如 gemini-1.0-pro
|
||||
"""
|
||||
|
||||
if llm_provider == "deepseek":
|
||||
if not llm_model_name:
|
||||
llm_model_name = "deepseek-chat"
|
||||
if not llm_base_url:
|
||||
llm_base_url = "https://api.deepseek.com"
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### DeepSeek 配置说明
|
||||
- **API Key**: [点击到官网申请](https://platform.deepseek.com/api_keys)
|
||||
- **Base Url**: 固定为 https://api.deepseek.com
|
||||
- **Model Name**: 固定为 deepseek-chat
|
||||
"""
|
||||
|
||||
if llm_provider == "ernie":
|
||||
with llm_helper:
|
||||
tips = """
|
||||
##### 百度文心一言 配置说明
|
||||
- **API Key**: [点击到官网申请](https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application)
|
||||
- **Secret Key**: [点击到官网申请](https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application)
|
||||
- **Base Url**: 填写 **请求地址** [点击查看文档](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/jlil56u11#%E8%AF%B7%E6%B1%82%E8%AF%B4%E6%98%8E)
|
||||
"""
|
||||
|
||||
if tips and config.ui["language"] == "zh":
|
||||
st.warning(
|
||||
"中国用户建议使用 **DeepSeek** 或 **Moonshot** 作为大模型提供商\n- 国内可直接访问,不需要VPN \n- 注册就送额度,基本够用"
|
||||
st_llm_api_key = st.text_input(
|
||||
tr("API Key"), value=llm_api_key, type="password"
|
||||
)
|
||||
st.info(tips)
|
||||
st_llm_base_url = st.text_input(tr("Base Url"), value=llm_base_url)
|
||||
st_llm_model_name = ""
|
||||
if llm_provider != "ernie":
|
||||
st_llm_model_name = st.text_input(
|
||||
tr("Model Name"),
|
||||
value=llm_model_name,
|
||||
key=f"{llm_provider}_model_name_input",
|
||||
)
|
||||
if st_llm_model_name:
|
||||
config.app[f"{llm_provider}_model_name"] = st_llm_model_name
|
||||
else:
|
||||
st_llm_model_name = None
|
||||
|
||||
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_model_name = ""
|
||||
if llm_provider != "ernie":
|
||||
st_llm_model_name = st.text_input(
|
||||
tr("Model Name"),
|
||||
value=llm_model_name,
|
||||
key=f"{llm_provider}_model_name_input",
|
||||
)
|
||||
if st_llm_api_key:
|
||||
config.app[f"{llm_provider}_api_key"] = st_llm_api_key
|
||||
if st_llm_base_url:
|
||||
config.app[f"{llm_provider}_base_url"] = st_llm_base_url
|
||||
if st_llm_model_name:
|
||||
config.app[f"{llm_provider}_model_name"] = st_llm_model_name
|
||||
else:
|
||||
st_llm_model_name = None
|
||||
if llm_provider == "ernie":
|
||||
st_llm_secret_key = st.text_input(
|
||||
tr("Secret Key"), value=llm_secret_key, type="password"
|
||||
)
|
||||
config.app[f"{llm_provider}_secret_key"] = st_llm_secret_key
|
||||
|
||||
if st_llm_api_key:
|
||||
config.app[f"{llm_provider}_api_key"] = st_llm_api_key
|
||||
if st_llm_base_url:
|
||||
config.app[f"{llm_provider}_base_url"] = st_llm_base_url
|
||||
if st_llm_model_name:
|
||||
config.app[f"{llm_provider}_model_name"] = st_llm_model_name
|
||||
if llm_provider == "ernie":
|
||||
st_llm_secret_key = st.text_input(
|
||||
tr("Secret Key"), value=llm_secret_key, type="password"
|
||||
if llm_provider == "cloudflare":
|
||||
st_llm_account_id = st.text_input(
|
||||
tr("Account ID"), value=llm_account_id
|
||||
)
|
||||
if st_llm_account_id:
|
||||
config.app[f"{llm_provider}_account_id"] = st_llm_account_id
|
||||
|
||||
# 右侧面板 - API 密钥设置
|
||||
with right_config_panel:
|
||||
|
||||
def get_keys_from_config(cfg_key):
|
||||
api_keys = config.app.get(cfg_key, [])
|
||||
if isinstance(api_keys, str):
|
||||
api_keys = [api_keys]
|
||||
api_key = ", ".join(api_keys)
|
||||
return api_key
|
||||
|
||||
def save_keys_to_config(cfg_key, value):
|
||||
value = value.replace(" ", "")
|
||||
if value:
|
||||
config.app[cfg_key] = value.split(",")
|
||||
|
||||
st.markdown("##### " + tr("Video API Keys"))
|
||||
|
||||
# Pexels API Key
|
||||
pexels_api_key = get_keys_from_config("pexels_api_keys")
|
||||
st.markdown(
|
||||
f"**Pexels API Key** ([{tr('点击获取')}](https://www.pexels.com/api/documentation/))"
|
||||
)
|
||||
config.app[f"{llm_provider}_secret_key"] = st_llm_secret_key
|
||||
|
||||
if llm_provider == "cloudflare":
|
||||
st_llm_account_id = st.text_input(
|
||||
tr("Account ID"), value=llm_account_id
|
||||
st.markdown(
|
||||
f"<span style='color:#FF4B4B'>{tr('推荐使用')}</span>",
|
||||
unsafe_allow_html=True,
|
||||
)
|
||||
if st_llm_account_id:
|
||||
config.app[f"{llm_provider}_account_id"] = st_llm_account_id
|
||||
pexels_api_key = st.text_input(
|
||||
"Pexels API Key",
|
||||
value=pexels_api_key,
|
||||
type="password",
|
||||
key="pexels_api_key_input",
|
||||
label_visibility="collapsed",
|
||||
)
|
||||
save_keys_to_config("pexels_api_keys", pexels_api_key)
|
||||
|
||||
with right_config_panel:
|
||||
# Pixabay API Key
|
||||
pixabay_api_key = get_keys_from_config("pixabay_api_keys")
|
||||
st.markdown(
|
||||
f"**Pixabay API Key** ([{tr('点击获取')}](https://pixabay.com/api/docs/))"
|
||||
)
|
||||
st.markdown(
|
||||
f"<span style='color:#808080'>{tr('可以不用配置,如果 Pexels 无法使用,再选择Pixabay')}</span>",
|
||||
unsafe_allow_html=True,
|
||||
)
|
||||
pixabay_api_key = st.text_input(
|
||||
"Pixabay API Key",
|
||||
value=pixabay_api_key,
|
||||
type="password",
|
||||
key="pixabay_api_key_input",
|
||||
label_visibility="collapsed",
|
||||
)
|
||||
save_keys_to_config("pixabay_api_keys", pixabay_api_key)
|
||||
|
||||
def get_keys_from_config(cfg_key):
|
||||
api_keys = config.app.get(cfg_key, [])
|
||||
if isinstance(api_keys, str):
|
||||
api_keys = [api_keys]
|
||||
api_key = ", ".join(api_keys)
|
||||
return api_key
|
||||
|
||||
def save_keys_to_config(cfg_key, value):
|
||||
value = value.replace(" ", "")
|
||||
if value:
|
||||
config.app[cfg_key] = value.split(",")
|
||||
|
||||
pexels_api_key = get_keys_from_config("pexels_api_keys")
|
||||
pexels_api_key = st.text_input(
|
||||
tr("Pexels API Key"), value=pexels_api_key, type="password"
|
||||
)
|
||||
save_keys_to_config("pexels_api_keys", pexels_api_key)
|
||||
|
||||
pixabay_api_key = get_keys_from_config("pixabay_api_keys")
|
||||
pixabay_api_key = st.text_input(
|
||||
tr("Pixabay API Key"), value=pixabay_api_key, type="password"
|
||||
)
|
||||
save_keys_to_config("pixabay_api_keys", pixabay_api_key)
|
||||
|
||||
panel = st.columns(3)
|
||||
left_panel = panel[0]
|
||||
@ -443,7 +564,9 @@ with left_panel:
|
||||
with st.container(border=True):
|
||||
st.write(tr("Video Script Settings"))
|
||||
params.video_subject = st.text_input(
|
||||
tr("Video Subject"), value=st.session_state["video_subject"]
|
||||
tr("Video Subject"),
|
||||
value=st.session_state["video_subject"],
|
||||
key="video_subject_input",
|
||||
).strip()
|
||||
|
||||
video_languages = [
|
||||
@ -529,7 +652,6 @@ with middle_panel:
|
||||
config.app["video_source"] = params.video_source
|
||||
|
||||
if params.video_source == "local":
|
||||
_supported_types = FILE_TYPE_VIDEOS + FILE_TYPE_IMAGES
|
||||
uploaded_files = st.file_uploader(
|
||||
"Upload Local Files",
|
||||
type=["mp4", "mov", "avi", "flv", "mkv", "jpg", "jpeg", "png"],
|
||||
@ -664,10 +786,15 @@ with middle_panel:
|
||||
saved_azure_speech_region = config.azure.get("speech_region", "")
|
||||
saved_azure_speech_key = config.azure.get("speech_key", "")
|
||||
azure_speech_region = st.text_input(
|
||||
tr("Speech Region"), value=saved_azure_speech_region
|
||||
tr("Speech Region"),
|
||||
value=saved_azure_speech_region,
|
||||
key="azure_speech_region_input",
|
||||
)
|
||||
azure_speech_key = st.text_input(
|
||||
tr("Speech Key"), value=saved_azure_speech_key, type="password"
|
||||
tr("Speech Key"),
|
||||
value=saved_azure_speech_key,
|
||||
type="password",
|
||||
key="azure_speech_key_input",
|
||||
)
|
||||
config.azure["speech_region"] = azure_speech_region
|
||||
config.azure["speech_key"] = azure_speech_key
|
||||
@ -704,7 +831,9 @@ with middle_panel:
|
||||
|
||||
# Show or hide components based on the selection
|
||||
if params.bgm_type == "custom":
|
||||
custom_bgm_file = st.text_input(tr("Custom Background Music File"))
|
||||
custom_bgm_file = st.text_input(
|
||||
tr("Custom Background Music File"), key="custom_bgm_file_input"
|
||||
)
|
||||
if custom_bgm_file and os.path.exists(custom_bgm_file):
|
||||
params.bgm_file = custom_bgm_file
|
||||
# st.write(f":red[已选择自定义背景音乐]:**{custom_bgm_file}**")
|
||||
@ -744,7 +873,9 @@ with right_panel:
|
||||
|
||||
if params.subtitle_position == "custom":
|
||||
custom_position = st.text_input(
|
||||
tr("Custom Position (% from top)"), value="70.0"
|
||||
tr("Custom Position (% from top)"),
|
||||
value="70.0",
|
||||
key="custom_position_input",
|
||||
)
|
||||
try:
|
||||
params.custom_position = float(custom_position)
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
{
|
||||
"Language": "German",
|
||||
"Language": "Deutsch",
|
||||
"Translation": {
|
||||
"Login Required": "Anmeldung erforderlich",
|
||||
"Please login to access settings": "Bitte melden Sie sich an, um auf die Einstellungen zuzugreifen",
|
||||
"Username": "Benutzername",
|
||||
"Password": "Passwort",
|
||||
"Login": "Anmelden",
|
||||
"Login Error": "Anmeldefehler",
|
||||
"Incorrect username or password": "Falscher Benutzername oder Passwort",
|
||||
"Please enter your username and password": "Bitte geben Sie Ihren Benutzernamen und Ihr Passwort ein",
|
||||
"Video Script Settings": "**Drehbuch / Topic des Videos**",
|
||||
"Video Subject": "Worum soll es in dem Video gehen? (Geben Sie ein Keyword an, :red[Dank KI wird automatisch ein Drehbuch generieren])",
|
||||
"Script Language": "Welche Sprache soll zum Generieren von Drehbüchern verwendet werden? :red[KI generiert anhand dieses Begriffs das Drehbuch]",
|
||||
@ -10,7 +18,7 @@
|
||||
"Generate Video Keywords": "Klicken Sie, um KI zum Generieren zu verwenden [Video Keywords] basierend auf dem **Drehbuch**",
|
||||
"Please Enter the Video Subject": "Bitte geben Sie zuerst das Drehbuch an",
|
||||
"Generating Video Script and Keywords": "KI generiert ein Drehbuch und Schlüsselwörter...",
|
||||
"Generating Video Keywords": "AI is generating video keywords...",
|
||||
"Generating Video Keywords": "KI generiert Video-Schlüsselwörter...",
|
||||
"Video Keywords": "Video Schlüsselwörter (:blue[① Optional, KI generiert ② Verwende **, (Kommas)** zur Trennung der Wörter, in englischer Sprache])",
|
||||
"Video Settings": "**Video Einstellungen**",
|
||||
"Video Concat Mode": "Videoverkettungsmodus",
|
||||
@ -30,8 +38,8 @@
|
||||
"Number of Videos Generated Simultaneously": "Anzahl der parallel generierten Videos",
|
||||
"Audio Settings": "**Audio Einstellungen**",
|
||||
"Speech Synthesis": "Sprachausgabe",
|
||||
"Speech Region": "Region(:red[Required,[Get Region](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
|
||||
"Speech Key": "API Key(:red[Required,[Get API Key](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
|
||||
"Speech Region": "Region(:red[Erforderlich,[Region abrufen](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
|
||||
"Speech Key": "API-Schlüssel(:red[Erforderlich,[API-Schlüssel abrufen](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
|
||||
"Speech Volume": "Lautstärke der Sprachausgabe",
|
||||
"Speech Rate": "Lesegeschwindigkeit (1,0 bedeutet 1x)",
|
||||
"Male": "Männlich",
|
||||
@ -61,26 +69,31 @@
|
||||
"Video Generation Completed": "Video erfolgreich generiert",
|
||||
"Video Generation Failed": "Video Generierung fehlgeschlagen",
|
||||
"You can download the generated video from the following links": "Sie können das generierte Video über die folgenden Links herunterladen",
|
||||
"Basic Settings": "**Grunde Instellungen**",
|
||||
"Pexels API Key": "Pexels API Key ([Get API Key](https://www.pexels.com/api/))",
|
||||
"Pixabay API Key": "Pixabay API Key ([Get API Key](https://pixabay.com/api/docs/#api_search_videos))",
|
||||
"Language": "Language",
|
||||
"LLM Provider": "LLM Provider",
|
||||
"API Key": "API Key (:red[Required])",
|
||||
"Base Url": "Base Url",
|
||||
"Model Name": "Model Name",
|
||||
"Please Enter the LLM API Key": "Please Enter the **LLM API Key**",
|
||||
"Please Enter the Pexels API Key": "Please Enter the **Pexels API Key**",
|
||||
"Please Enter the Pixabay API Key": "Please Enter the **Pixabay API Key**",
|
||||
"Get Help": "If you need help, or have any questions, you can join discord for help: https://harryai.cc",
|
||||
"Video Source": "Video Source",
|
||||
"TikTok": "TikTok (TikTok support is coming soon)",
|
||||
"Bilibili": "Bilibili (Bilibili support is coming soon)",
|
||||
"Xiaohongshu": "Xiaohongshu (Xiaohongshu support is coming soon)",
|
||||
"Local file": "Local file",
|
||||
"Play Voice": "Play Voice",
|
||||
"Voice Example": "This is an example text for testing speech synthesis",
|
||||
"Synthesizing Voice": "Synthesizing voice, please wait...",
|
||||
"TTS Provider": "Select the voice synthesis provider"
|
||||
"Basic Settings": "**Grundeinstellungen** (:blue[Klicken zum Erweitern])",
|
||||
"Language": "Sprache",
|
||||
"Pexels API Key": "Pexels API-Schlüssel ([API-Schlüssel abrufen](https://www.pexels.com/api/))",
|
||||
"Pixabay API Key": "Pixabay API-Schlüssel ([API-Schlüssel abrufen](https://pixabay.com/api/docs/#api_search_videos))",
|
||||
"LLM Provider": "KI-Modellanbieter",
|
||||
"API Key": "API-Schlüssel (:red[Erforderlich])",
|
||||
"Base Url": "Basis-URL",
|
||||
"Account ID": "Konto-ID (Aus dem Cloudflare-Dashboard)",
|
||||
"Model Name": "Modellname",
|
||||
"Please Enter the LLM API Key": "Bitte geben Sie den **KI-Modell API-Schlüssel** ein",
|
||||
"Please Enter the Pexels API Key": "Bitte geben Sie den **Pexels API-Schlüssel** ein",
|
||||
"Please Enter the Pixabay API Key": "Bitte geben Sie den **Pixabay API-Schlüssel** ein",
|
||||
"Get Help": "Wenn Sie Hilfe benötigen oder Fragen haben, können Sie dem Discord beitreten: https://harryai.cc",
|
||||
"Video Source": "Videoquelle",
|
||||
"TikTok": "TikTok (TikTok-Unterstützung kommt bald)",
|
||||
"Bilibili": "Bilibili (Bilibili-Unterstützung kommt bald)",
|
||||
"Xiaohongshu": "Xiaohongshu (Xiaohongshu-Unterstützung kommt bald)",
|
||||
"Local file": "Lokale Datei",
|
||||
"Play Voice": "Sprachausgabe abspielen",
|
||||
"Voice Example": "Dies ist ein Beispieltext zum Testen der Sprachsynthese",
|
||||
"Synthesizing Voice": "Sprachsynthese läuft, bitte warten...",
|
||||
"TTS Provider": "Sprachsynthese-Anbieter auswählen",
|
||||
"Hide Log": "Protokoll ausblenden",
|
||||
"点击获取": "Klicken zum Abrufen",
|
||||
"推荐使用": "Empfohlen",
|
||||
"可以不用配置,如果 Pexels 无法使用,再选择Pixabay": "Kann uneingestellt bleiben. Wenn Pexels nicht funktioniert, wählen Sie Pixabay"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
{
|
||||
"Language": "English",
|
||||
"Translation": {
|
||||
"Login Required": "Login Required",
|
||||
"Please login to access settings": "Please login to access settings",
|
||||
"Username": "Username",
|
||||
"Password": "Password",
|
||||
"Login": "Login",
|
||||
"Login Error": "Login Error",
|
||||
"Incorrect username or password": "Incorrect username or password",
|
||||
"Please enter your username and password": "Please enter your username and password",
|
||||
"Video Script Settings": "**Video Script Settings**",
|
||||
"Video Subject": "Video Subject (Provide a keyword, :red[AI will automatically generate] video script)",
|
||||
"Script Language": "Language for Generating Video Script (AI will automatically output based on the language of your subject)",
|
||||
@ -16,7 +24,7 @@
|
||||
"Video Concat Mode": "Video Concatenation Mode",
|
||||
"Random": "Random Concatenation (Recommended)",
|
||||
"Sequential": "Sequential Concatenation",
|
||||
"Video Transition Mode": "Video Transition Mode",
|
||||
"Video Transition Mode": "Video Transition Mode",
|
||||
"None": "None",
|
||||
"Shuffle": "Shuffle",
|
||||
"FadeIn": "FadeIn",
|
||||
|
||||
@ -1,12 +1,20 @@
|
||||
{
|
||||
"Language": "Português Brasileiro",
|
||||
"Translation": {
|
||||
"Login Required": "Login Necessário",
|
||||
"Please login to access settings": "Por favor, faça login para acessar as configurações",
|
||||
"Username": "Nome de usuário",
|
||||
"Password": "Senha",
|
||||
"Login": "Entrar",
|
||||
"Login Error": "Erro de Login",
|
||||
"Incorrect username or password": "Nome de usuário ou senha incorretos",
|
||||
"Please enter your username and password": "Por favor, digite seu nome de usuário e senha",
|
||||
"Video Script Settings": "**Configurações do Roteiro do Vídeo**",
|
||||
"Video Subject": "Tema do Vídeo (Forneça uma palavra-chave, :red[a IA irá gerar automaticamente] o roteiro do vídeo)",
|
||||
"Script Language": "Idioma para Gerar o Roteiro do Vídeo (a IA irá gerar automaticamente com base no idioma do seu tema)",
|
||||
"Generate Video Script and Keywords": "Clique para usar a IA para gerar o [Roteiro do Vídeo] e as [Palavras-chave do Vídeo] com base no **tema**",
|
||||
"Auto Detect": "Detectar Automaticamente",
|
||||
"Video Script": "Roteiro do Vídeo (:blue[① Opcional, gerado pela IA ② Pontuação adequada ajuda na geração de legendas])",
|
||||
"Video Script": "Roteiro do Vídeo (:blue[① Opcional, gerado pela IA ② Pontuação adequada ajuda na geração de legendas])",
|
||||
"Generate Video Keywords": "Clique para usar a IA para gerar [Palavras-chave do Vídeo] com base no **roteiro**",
|
||||
"Please Enter the Video Subject": "Por favor, insira o Roteiro do Vídeo primeiro",
|
||||
"Generating Video Script and Keywords": "A IA está gerando o roteiro do vídeo e as palavras-chave...",
|
||||
@ -61,10 +69,10 @@
|
||||
"Video Generation Completed": "Geração do Vídeo Concluída",
|
||||
"Video Generation Failed": "Falha na Geração do Vídeo",
|
||||
"You can download the generated video from the following links": "Você pode baixar o vídeo gerado a partir dos seguintes links",
|
||||
"Pexels API Key": "Chave da API do Pexels ([Obter Chave da API](https://www.pexels.com/api/))",
|
||||
"Pixabay API Key": "Chave da API do Pixabay ([Obter Chave da API](https://pixabay.com/api/docs/#api_search_videos))",
|
||||
"Basic Settings": "**Configurações Básicas** (:blue[Clique para expandir])",
|
||||
"Language": "Idioma",
|
||||
"Pexels API Key": "Chave da API do Pexels ([Obter Chave da API](https://www.pexels.com/api/))",
|
||||
"Pixabay API Key": "Chave da API do Pixabay ([Obter Chave da API](https://pixabay.com/api/docs/#api_search_videos))",
|
||||
"LLM Provider": "Provedor LLM",
|
||||
"API Key": "Chave da API (:red[Obrigatório])",
|
||||
"Base Url": "URL Base",
|
||||
@ -83,6 +91,9 @@
|
||||
"Voice Example": "Este é um exemplo de texto para testar a síntese de fala",
|
||||
"Synthesizing Voice": "Sintetizando voz, por favor aguarde...",
|
||||
"TTS Provider": "Selecione o provedor de síntese de voz",
|
||||
"Hide Log": "Ocultar Log"
|
||||
"Hide Log": "Ocultar Log",
|
||||
"点击获取": "Clique para obter",
|
||||
"推荐使用": "Recomendado",
|
||||
"可以不用配置,如果 Pexels 无法使用,再选择Pixabay": "Pode não ser configurado, se o Pexels não estiver disponível, escolha o Pixabay"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
{
|
||||
"Language": "Tiếng Việt",
|
||||
"Translation": {
|
||||
"Login Required": "Yêu cầu đăng nhập",
|
||||
"Please login to access settings": "Vui lòng đăng nhập để truy cập cài đặt",
|
||||
"Username": "Tên đăng nhập",
|
||||
"Password": "Mật khẩu",
|
||||
"Login": "Đăng nhập",
|
||||
"Login Error": "Lỗi đăng nhập",
|
||||
"Incorrect username or password": "Tên đăng nhập hoặc mật khẩu không chính xác",
|
||||
"Please enter your username and password": "Vui lòng nhập tên đăng nhập và mật khẩu của bạn",
|
||||
"Video Script Settings": "**Cài Đặt Kịch Bản Video**",
|
||||
"Video Subject": "Chủ Đề Video (Cung cấp một từ khóa, :red[AI sẽ tự động tạo ra] kịch bản video)",
|
||||
"Script Language": "Ngôn Ngữ cho Việc Tạo Kịch Bản Video (AI sẽ tự động xuất ra dựa trên ngôn ngữ của chủ đề của bạn)",
|
||||
@ -61,10 +69,10 @@
|
||||
"Video Generation Completed": "Hoàn Tất Tạo Video",
|
||||
"Video Generation Failed": "Tạo Video Thất Bại",
|
||||
"You can download the generated video from the following links": "Bạn có thể tải video được tạo ra từ các liên kết sau",
|
||||
"Pexels API Key": "Khóa API Pexels ([Lấy Khóa API](https://www.pexels.com/api/))",
|
||||
"Pixabay API Key": "Pixabay API Key ([Get API Key](https://pixabay.com/api/docs/#api_search_videos))",
|
||||
"Basic Settings": "**Cài Đặt Cơ Bản** (:blue[Nhấp để mở rộng])",
|
||||
"Language": "Ngôn Ngữ",
|
||||
"Pexels API Key": "Khóa API Pexels ([Lấy Khóa API](https://www.pexels.com/api/))",
|
||||
"Pixabay API Key": "Khóa API Pixabay ([Lấy Khóa API](https://pixabay.com/api/docs/#api_search_videos))",
|
||||
"LLM Provider": "Nhà Cung Cấp LLM",
|
||||
"API Key": "Khóa API (:red[Bắt Buộc])",
|
||||
"Base Url": "Url Cơ Bản",
|
||||
@ -72,16 +80,20 @@
|
||||
"Model Name": "Tên Mô Hình",
|
||||
"Please Enter the LLM API Key": "Vui lòng Nhập **Khóa API LLM**",
|
||||
"Please Enter the Pexels API Key": "Vui lòng Nhập **Khóa API Pexels**",
|
||||
"Please Enter the Pixabay API Key": "Vui lòng Nhập **Pixabay API Key**",
|
||||
"Please Enter the Pixabay API Key": "Vui lòng Nhập **Khóa API Pixabay**",
|
||||
"Get Help": "Nếu bạn cần giúp đỡ hoặc có bất kỳ câu hỏi nào, bạn có thể tham gia discord để được giúp đỡ: https://harryai.cc",
|
||||
"Video Source": "Video Source",
|
||||
"TikTok": "TikTok (TikTok support is coming soon)",
|
||||
"Bilibili": "Bilibili (Bilibili support is coming soon)",
|
||||
"Xiaohongshu": "Xiaohongshu (Xiaohongshu support is coming soon)",
|
||||
"Local file": "Local file",
|
||||
"Play Voice": "Play Voice",
|
||||
"Voice Example": "This is an example text for testing speech synthesis",
|
||||
"Synthesizing Voice": "Synthesizing voice, please wait...",
|
||||
"TTS Provider": "Select the voice synthesis provider"
|
||||
"Video Source": "Nguồn Video",
|
||||
"TikTok": "TikTok (Hỗ trợ TikTok sắp ra mắt)",
|
||||
"Bilibili": "Bilibili (Hỗ trợ Bilibili sắp ra mắt)",
|
||||
"Xiaohongshu": "Xiaohongshu (Hỗ trợ Xiaohongshu sắp ra mắt)",
|
||||
"Local file": "Tệp cục bộ",
|
||||
"Play Voice": "Phát Giọng Nói",
|
||||
"Voice Example": "Đây là văn bản mẫu để kiểm tra tổng hợp giọng nói",
|
||||
"Synthesizing Voice": "Đang tổng hợp giọng nói, vui lòng đợi...",
|
||||
"TTS Provider": "Chọn nhà cung cấp tổng hợp giọng nói",
|
||||
"Hide Log": "Ẩn Nhật Ký",
|
||||
"点击获取": "Nhấp để lấy",
|
||||
"推荐使用": "Được khuyến nghị",
|
||||
"可以不用配置,如果 Pexels 无法使用,再选择Pixabay": "Có thể không cần cấu hình, nếu Pexels không khả dụng, hãy chọn Pixabay"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
{
|
||||
"Language": "简体中文",
|
||||
"Translation": {
|
||||
"Login Required": "需要登录",
|
||||
"Please login to access settings": "请登录后访问配置设置",
|
||||
"Username": "用户名",
|
||||
"Password": "密码",
|
||||
"Login": "登录",
|
||||
"Login Error": "登录错误",
|
||||
"Incorrect username or password": "用户名或密码不正确",
|
||||
"Please enter your username and password": "请输入用户名和密码",
|
||||
"Video Script Settings": "**文案设置**",
|
||||
"Video Subject": "视频主题(给定一个关键词,:red[AI自动生成]视频文案)",
|
||||
"Script Language": "生成视频脚本的语言(一般情况AI会自动根据你输入的主题语言输出)",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user