mirror of
https://github.com/linyqh/NarratoAI.git
synced 2025-12-15 06:19:13 +00:00
refactor(app): 调整脚本生成器默认参数并移除未使用的代码
- 移除了 script_generator.py 中的多余参数 'enable_search' - 删除了 webui.sh 脚本,可能是因为不再需要或已改为其他方式实现 - 新增了 test_gemini.py 测试文件,用于测试 Gemini 模型
This commit is contained in:
parent
d10a84caca
commit
94b983a545
11
app/test/test_gemini.py
Normal file
11
app/test/test_gemini.py
Normal file
@ -0,0 +1,11 @@
|
||||
import google.generativeai as genai
|
||||
from app.config import config
|
||||
import os
|
||||
|
||||
os.environ["HTTP_PROXY"] = config.proxy.get("http")
|
||||
os.environ["HTTPS_PROXY"] = config.proxy.get("https")
|
||||
|
||||
genai.configure(api_key=config.app.get("vision_gemini_api_key"))
|
||||
model = genai.GenerativeModel("gemini-1.5-flash")
|
||||
response = model.generate_content("Explain how AI works")
|
||||
print(response.text)
|
||||
@ -179,8 +179,7 @@ class QwenGenerator(BaseGenerator):
|
||||
self.default_params = {
|
||||
**self.default_params,
|
||||
"stream": False,
|
||||
"user": "script_generator",
|
||||
"enable_search": True
|
||||
"user": "script_generator"
|
||||
}
|
||||
|
||||
def _generate(self, messages: list, params: dict) -> any:
|
||||
|
||||
67
webui.sh
67
webui.sh
@ -1,67 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 从环境变量中加载VPN代理的配置URL
|
||||
vpn_proxy_url="$VPN_PROXY_URL"
|
||||
# 检查是否成功加载
|
||||
if [ -z "$vpn_proxy_url" ]; then
|
||||
echo "VPN代理配置URL未设置,请检查环境变量VPN_PROXY_URL"
|
||||
exit 1
|
||||
fi
|
||||
# 使用VPN代理进行一些操作,比如通过代理下载文件
|
||||
export http_proxy="$vpn_proxy_url"
|
||||
export https_proxy="$vpn_proxy_url"
|
||||
# 创建链接和路径的数组
|
||||
declare -A urls_paths=(
|
||||
["https://zenodo.org/records/13293144/files/MicrosoftYaHeiBold.ttc"]="./resource/fonts"
|
||||
["https://zenodo.org/records/13293144/files/MicrosoftYaHeiNormal.ttc"]="./resource/fonts"
|
||||
["https://zenodo.org/records/13293144/files/STHeitiLight.ttc"]="./resource/fonts"
|
||||
["https://zenodo.org/records/13293144/files/STHeitiMedium.ttc"]="./resource/fonts"
|
||||
["https://zenodo.org/records/13293144/files/UTM%20Kabel%20KT.ttf"]="./resource/fonts"
|
||||
["https://zenodo.org/records/13293129/files/demo.mp4"]="./resource/videos"
|
||||
["https://zenodo.org/records/13293150/files/output000.mp3"]="./resource/songs"
|
||||
["https://zenodo.org/records/13293150/files/output001.mp3"]="./resource/songs"
|
||||
["https://zenodo.org/records/13293150/files/output002.mp3"]="./resource/songs"
|
||||
["https://zenodo.org/records/13293150/files/output003.mp3"]="./resource/songs"
|
||||
["https://zenodo.org/records/13293150/files/output004.mp3"]="./resource/songs"
|
||||
["https://zenodo.org/records/13293150/files/output005.mp3"]="./resource/songs"
|
||||
["https://zenodo.org/records/13293150/files/output006.mp3"]="./resource/songs"
|
||||
["https://zenodo.org/records/13293150/files/output007.mp3"]="./resource/songs"
|
||||
["https://zenodo.org/records/13293150/files/output008.mp3"]="./resource/songs"
|
||||
["https://zenodo.org/records/13293150/files/output009.mp3"]="./resource/songs"
|
||||
["https://zenodo.org/records/13293150/files/output010.mp3"]="./resource/songs"
|
||||
# 添加更多链接及其对应的路径
|
||||
)
|
||||
# 循环下载所有文件并保存到指定路径
|
||||
for url in "${!urls_paths[@]}"; do
|
||||
output_dir="${urls_paths[$url]}"
|
||||
mkdir -p "$output_dir" # 创建目录(如果不存在)
|
||||
|
||||
# 提取文件名
|
||||
filename=$(basename "$url")
|
||||
|
||||
# 下载文件,避免重复下载
|
||||
wget -P "$output_dir" -nc "$url" || {
|
||||
echo "下载失败: $url" >&2
|
||||
}
|
||||
done
|
||||
|
||||
# 安装 git lfs 并下载模型到指定目录
|
||||
git lfs install
|
||||
mkdir -p /NarratoAI/app/models
|
||||
cd /NarratoAI/app/models
|
||||
if [ ! -d "faster-whisper-large-v2" ] || [ -z "$(ls -A faster-whisper-large-v2)" ]; then
|
||||
if git clone https://huggingface.co/guillaumekln/faster-whisper-large-v2; then
|
||||
echo "下载faster-whisper-large-v2成功"
|
||||
else
|
||||
echo "下载faster-whisper-large-v2失败" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "faster-whisper-large-v2 已存在,跳过下载"
|
||||
fi
|
||||
|
||||
# 等待所有后台任务完成
|
||||
wait
|
||||
echo "所有文件已成功下载到指定目录"
|
||||
cd /NarratoAI/
|
||||
streamlit run webui.py --browser.serverAddress="0.0.0.0" --server.enableCORS=True --server.maxUploadSize=2048 --browser.gatherUsageStats=False
|
||||
Loading…
x
Reference in New Issue
Block a user