Skip to content

🎬 火宝短剧 - 基于AI的一站式短剧生成平台 《一句话生成完整短剧,从剧本到成片全自动化》 Huobao Drama - An AI-Powered End-to-End Short Drama Generator "One Sentence to Complete Drama: Fully Automated from Script to Final Video"

TypeScript

修改配置相关

Connor9970451aba87
diff --git a/backend/src/routes/aiConfigs.ts b/backend/src/routes/aiConfigs.ts
index ee420c5..13a7ca9 100644
--- a/backend/src/routes/aiConfigs.ts
+++ b/backend/src/routes/aiConfigs.ts
@@ -8,6 +8,23 @@ import { redactUrl, logTaskError, logTaskProgress, logTaskSuccess } from '../uti
const app = new Hono()
+const HUOBAO_PRESET_SERVICES = [
+ { serviceType: 'text', label: '文本', provider: 'chatfire', baseUrl: 'https://api.chatfire.site', model: 'gemini-3-pro-preview', priority: 100 },
+ { serviceType: 'image', label: '图片', provider: 'gemini', baseUrl: 'https://api.chatfire.site', model: 'gemini-3-pro-image-preview', priority: 99 },
+ { serviceType: 'video', label: '视频', provider: 'volcengine', baseUrl: 'https://api.chatfire.site/volcengine', model: 'doubao-seedance-1-5-pro-251215', priority: 98 },
+ { serviceType: 'audio', label: '音频', provider: 'minimax', baseUrl: 'https://api.chatfire.site/minimax', model: 'speech-2.8-hd', priority: 97 },
+] as const
+
+const HUOBAO_AGENT_DEFAULTS = [
+ { agentType: 'script_rewriter', name: '剧本改写' },
+ { agentType: 'extractor', name: '角色场景提取' },
+ { agentType: 'storyboard_breaker', name: '分镜拆解' },
+ { agentType: 'voice_assigner', name: '音色分配' },
+ { agentType: 'grid_prompt_generator', name: '图片提示词生成' },
+] as const
+
+const HUOBAO_AGENT_MODEL = 'gemini-3-pro-preview'
+
function bearerHeaders(apiKey?: string, withJson = false) {
const headers: Record<string, string> = {}
if (apiKey) headers.Authorization = `Bearer ${apiKey}`
@@ -150,6 +167,86 @@ app.post('/', async (c) => {
})
})
+// POST /ai-configs/huobao-preset
+app.post('/huobao-preset', async (c) => {
+ const body = await c.req.json()
+ const apiKey = String(body.api_key || '').trim()
+ if (!apiKey) return badRequest(c, 'api_key is required')
+
+ const ts = now()
+
+ for (const preset of HUOBAO_PRESET_SERVICES) {
+ const [existing] = db.select().from(schema.aiServiceConfigs).where(eq(schema.aiServiceConfigs.serviceType, preset.serviceType)).all()
+ .filter(row => row.provider === preset.provider)
+
+ const values = {
+ serviceType: preset.serviceType,
+ provider: preset.provider,
+ name: `火宝默认${preset.label}服务`,
+ baseUrl: preset.baseUrl,
+ apiKey,
+ model: JSON.stringify([preset.model]),
+ priority: preset.priority,
+ isActive: true,
+ updatedAt: ts,
+ }
+
+ if (existing) {
+ db.update(schema.aiServiceConfigs).set(values).where(eq(schema.aiServiceConfigs.id, existing.id)).run()
+ } else {
+ db.insert(schema.aiServiceConfigs).values({
+ ...values,
+ createdAt: ts,
+ }).run()
+ }
+ }
+
+ for (const agent of HUOBAO_AGENT_DEFAULTS) {
+ const [existing] = db.select().from(schema.agentConfigs).where(eq(schema.agentConfigs.agentType, agent.agentType)).all()
+ const values = {
+ name: agent.name,
+ model: HUOBAO_AGENT_MODEL,
+ isActive: true,
+ updatedAt: ts,
+ }
+
+ if (existing) {
+ db.update(schema.agentConfigs).set(values).where(eq(schema.agentConfigs.id, existing.id)).run()
+ } else {
+ db.insert(schema.agentConfigs).values({
+ agentType: agent.agentType,
+ description: '',
+ model: HUOBAO_AGENT_MODEL,
+ name: agent.name,
+ systemPrompt: '',
+ temperature: 0.7,
+ maxTokens: 4096,
+ maxIterations: 10,
+ isActive: true,
+ createdAt: ts,
+ updatedAt: ts,
+ }).run()
+ }
+ }
+
+ const configs = db.select().from(schema.aiServiceConfigs).all().map(row => ({
+ ...toSnakeCase(row),
+ model: row.model ? JSON.parse(row.model) : [],
+ }))
+ const agents = db.select().from(schema.agentConfigs).all().map(row => toSnakeCase(row))
+
+ logTaskSuccess('AIConfig', 'huobao-preset-applied', {
+ serviceCount: HUOBAO_PRESET_SERVICES.length,
+ agentCount: HUOBAO_AGENT_DEFAULTS.length,
+ })
+
+ return success(c, {
+ configs,
+ agents,
+ agent_model: HUOBAO_AGENT_MODEL,
+ })
+})
+
// POST /ai-configs/test
app.post('/test', async (c) => {
const body = await c.req.json()
diff --git a/frontend/app/composables/useApi.ts b/frontend/app/composables/useApi.ts
index 22ad73c..f97d063 100644
--- a/frontend/app/composables/useApi.ts
+++ b/frontend/app/composables/useApi.ts
@@ -104,6 +104,7 @@ export const aiConfigAPI = {
update: (id: number, d: any) => api.put(`/ai-configs/${id}`, d),
del: (id: number) => api.del(`/ai-configs/${id}`),
test: (d: any) => api.post('/ai-configs/test', d),
+ huobaoPreset: (apiKey: string) => api.post('/ai-configs/huobao-preset', { api_key: apiKey }),
}
export const agentConfigAPI = {
diff --git a/frontend/app/pages/settings.vue b/frontend/app/pages/settings.vue
index 6250a45..9f320d3 100644
--- a/frontend/app/pages/settings.vue
+++ b/frontend/app/pages/settings.vue
@@ -337,7 +337,7 @@
<div>
<div class="setup-kicker">Huobao Preset</div>
<h2 class="modal-title">火宝一键配置</h2>
- <div class="modal-note">按火宝推荐链路自动创建或更新 4 条配置:文本 / 图片 / 视频 / 音频。</div>
+ <div class="modal-note">按火宝推荐链路自动创建或更新 4 条服务配置,并同时初始化 5 个 Agent 的默认模型。</div>
</div>
<span class="tag tag-success">推荐</span>
</div>
@@ -454,7 +454,6 @@ const huobaoPresetCards = [
{ serviceType: 'video', label: '视频', provider: 'volcengine', baseUrl: 'https://api.chatfire.site/volcengine', model: 'doubao-seedance-1-5-pro-251215', priority: 98 },
{ serviceType: 'audio', label: '音频', provider: 'minimax', baseUrl: 'https://api.chatfire.site/minimax', model: 'speech-2.8-hd', priority: 97 },
]
-const huobaoAgentModel = 'gemini-3-pro-preview'
const endpointPrefixes = {
chatfire: '/v1',
openai: '/v1',
@@ -561,35 +560,7 @@ async function applyHuobaoPreset() {
return
}
try {
- for (const preset of huobaoPresetCards) {
- const existing = cfgs.value.find(c => c.service_type === preset.serviceType && c.provider === preset.provider)
- const payload = {
- service_type: preset.serviceType,
- provider: preset.provider,
- name: `火宝默认${preset.label}服务`,
- api_key: huobaoForm.apiKey,
- base_url: preset.baseUrl,
- model: [preset.model],
- priority: preset.priority,
- is_active: true,
- }
- if (existing) await aiConfigAPI.update(existing.id, payload)
- else await aiConfigAPI.create(payload)
- }
- for (const agent of agentDefs) {
- const existing = agentCfgs.value.find(c => c.agent_type === agent.type)
- const payload = {
- agent_type: agent.type,
- name: agent.label,
- model: huobaoAgentModel,
- temperature: existing?.temperature ?? 0.7,
- max_tokens: existing?.max_tokens ?? 4096,
- system_prompt: existing?.system_prompt || defaultPrompts[agent.type] || '',
- is_active: true,
- }
- if (existing) await agentConfigAPI.update(existing.id, payload)
- else await agentConfigAPI.create(payload)
- }
+ await aiConfigAPI.huobaoPreset(huobaoForm.apiKey)
await loadCfgs()
await loadAgents()
presetDialog.value = false