feat: AI生图提示词翻译成英文后再发往上流(img2img 全链路 + 视频/设置改动)

This commit is contained in:
jinghui committed 2026-11-19 08:30:20 +08:00
1 parent 76d9d45770
commit b6e0c475d3
9 files changed
+1169 -34

No files matched your search

+64 -1
View File
@@ -30,6 +30,16 @@ const DEFAULTS = {
apiKey: '',
model: ''
}
},
// AI 视频:一句话/文本/网页/文档 → 带字幕配音的成片
// provider='inherit' 复用上面的 AI 生图配置;'custom' 用下面自定义的文本模型
videoai: {
provider: 'inherit',
custom: {
url: '',
model: '',
apiKey: ''
}
}
};
@@ -64,6 +74,14 @@ function getSettings() {
apiKey: (data.imagegen && data.imagegen.custom && data.imagegen.custom.apiKey) || '',
model: (data.imagegen && data.imagegen.custom && data.imagegen.custom.model) || ''
}
},
videoai: {
provider: (data.videoai && data.videoai.provider) === 'custom' ? 'custom' : 'inherit',
custom: {
url: (data.videoai && data.videoai.custom && data.videoai.custom.url) || '',
model: (data.videoai && data.videoai.custom && data.videoai.custom.model) || '',
apiKey: (data.videoai && data.videoai.custom && data.videoai.custom.apiKey) || ''
}
}
};
} catch (e) {
@@ -108,6 +126,19 @@ function saveSettings(settings) {
}
}
}
if (settings.videoai) {
const va = settings.videoai;
if (va.provider === 'custom' || va.provider === 'inherit') merged.videoai.provider = va.provider;
if (va.custom) {
if (typeof va.custom.url === 'string') merged.videoai.custom.url = va.custom.url.trim();
if (typeof va.custom.model === 'string') merged.videoai.custom.model = va.custom.model.trim();
const vk = va.custom.apiKey;
// 空串/掩码 = 保持原密钥
if (typeof vk === 'string' && vk.trim() && !vk.includes('***')) {
merged.videoai.custom.apiKey = vk.trim();
}
}
}
fs.writeFileSync(p, JSON.stringify(merged, null, 2));
return merged;
}
@@ -119,4 +150,36 @@ function maskKey(key) {
return `${key.slice(0, 4)}***${key.slice(-4)}`;
}
module.exports = { getSettings, saveSettings, maskKey, settingsPath };
/**
* 解析 AI 视频使用的文本大模型配置
* - 设置-AI 视频里选了「自定义」且填了地址 → 用自定义
* - 否则复用 AI 生图配置(内置 NewAPI / 自定义提供商)
* 普通文本模型(chat/completions)即可,全流程由后端写分镜、TTS 配音、合成字幕。
*/
function resolveVideoGen(settings) {
const s = settings || getSettings();
const va = (s && s.videoai) || {};
const ig = (s && s.imagegen) || {};
const defModel = process.env.NEWAPI_TEXT_MODEL || 'mimo-v2.6-flash';
if (va.provider === 'custom' && va.custom && va.custom.url) {
return {
url: String(va.custom.url).replace(/\/+$/, ''),
model: va.custom.model || defModel,
apiKey: va.custom.apiKey || process.env.NEWAPI_KEY || ''
};
}
if (ig.provider === 'custom' && ig.custom) {
return {
url: String(ig.custom.url || '').replace(/\/+$/, ''),
model: ig.custom.model || defModel,
apiKey: ig.custom.apiKey || process.env.NEWAPI_KEY || ''
};
}
return {
url: String((ig.newapi && ig.newapi.url) || 'http://192.168.68.19:3099/v1').replace(/\/+$/, ''),
model: defModel,
apiKey: ((ig.newapi && ig.newapi.apiKey) || process.env.NEWAPI_KEY || '')
};
}
module.exports = { getSettings, saveSettings, maskKey, settingsPath, resolveVideoGen };