Default MoneyPrinter videos to BoosAPI route

This commit is contained in:
boos
2026-06-03 11:03:04 +08:00
parent 68ae9acb27
commit c316a78511
2 changed files with 52 additions and 109 deletions
+29 -78
View File
@@ -146,36 +146,6 @@ function templateLabel(workflow: WorkflowSummary) {
return '私有工作流';
}
function generatedComfyPromptFromForm(model: string, ratio: string, resolution: string, duration: number) {
return {
'1': {
class_type: 'BoosAPITextToVideo',
inputs: {
model,
prompt: '',
ratio,
resolution,
duration,
},
},
'2': {
class_type: 'output.preview_video',
inputs: {
video: ['1', 0],
},
},
};
}
function generatedComfyMapping() {
return {
prompt: { nodeId: '1', field: 'prompt' },
ratio: { nodeId: '1', field: 'ratio' },
resolution: { nodeId: '1', field: 'resolution' },
duration: { nodeId: '1', field: 'duration' },
};
}
export default function MoneyPrinter() {
const location = useLocation();
const audience: SessionAudience = location.pathname.startsWith('/user/') ? 'user' : 'admin';
@@ -184,7 +154,7 @@ export default function MoneyPrinter() {
const [topic, setTopic] = useState('帮我生成一个 30 秒的 AI 应用平台 BossAI 商品介绍短视频');
const [scriptModel, setScriptModel] = useState('gpt-5.4');
const [videoModel, setVideoModel] = useState('seedance-1-0-lite-t2v');
const [videoBackend, setVideoBackend] = useState<'comfy' | 'boosapi'>('comfy');
const [videoBackend, setVideoBackend] = useState<'boosapi' | 'comfy'>('boosapi');
const [style, setStyle] = useState(STYLE_PRESETS[0]);
const [audienceText, setAudienceText] = useState('AI 工具用户、内容创作者、企业运营');
const [duration, setDuration] = useState(30);
@@ -226,12 +196,6 @@ export default function MoneyPrinter() {
setComfyNodeMapping(JSON.stringify(mapping || inferMappingFromPrompt(prompt), null, 2));
}, [selectedWorkflow?.publicId, videoBackend]);
useEffect(() => {
if (videoBackend !== 'comfy' || useAdvancedComfy) return;
setComfyPrompt(JSON.stringify(generatedComfyPromptFromForm(videoModel.trim(), ratio, resolution, duration), null, 2));
setComfyNodeMapping(JSON.stringify(generatedComfyMapping(), null, 2));
}, [videoBackend, useAdvancedComfy, videoModel, ratio, resolution, duration]);
useEffect(() => {
if (!jobs.some((job) => !terminal(job.status))) return;
const timer = window.setInterval(() => {
@@ -260,7 +224,7 @@ export default function MoneyPrinter() {
requirements,
language: '中文',
...(videoBackend === 'comfy' ? {
templateId: useAdvancedComfy ? templateId || undefined : undefined,
templateId: templateId || undefined,
comfyPrompt: comfyPrompt.trim() ? JSON.parse(comfyPrompt) : undefined,
comfyNodeMapping: comfyNodeMapping.trim() ? JSON.parse(comfyNodeMapping) : undefined,
} : {}),
@@ -336,10 +300,10 @@ export default function MoneyPrinter() {
<input value={scriptModel} onChange={(event) => setScriptModel(event.target.value)} />
</label>
<label className="money-printer-field">
<span>视频后端</span>
<select value={videoBackend} onChange={(event) => setVideoBackend(event.target.value as 'comfy' | 'boosapi')}>
<option value="comfy">Comfy API</option>
<span>视频后端</span>
<select value={videoBackend} onChange={(event) => setVideoBackend(event.target.value as 'comfy' | 'boosapi')}>
<option value="boosapi">BoosAPI /v1/videos</option>
<option value="comfy">Comfy API 模板</option>
</select>
</label>
<label className="money-printer-field">
@@ -390,47 +354,34 @@ export default function MoneyPrinter() {
<div className="money-printer-section-head">
<div>
<h2>Comfy API 工作流</h2>
<p>{useAdvancedComfy ? '使用保存过的工作流模板,会自动带入 Comfy API prompt 和节点映射。' : '已根据上方表单自动生成 Comfy prompt,生成时会注入 AI 改写后的视频提示词。'}</p>
<p>请选择真实 Comfy/Cloud 支持的视频工作流模板。系统只注入提示词、画幅、分辨率和时长,不再提交 BoosAPI 自定义节点。</p>
</div>
<button type="button" className="btn btn-ghost" onClick={() => setUseAdvancedComfy((value) => !value)}>
{useAdvancedComfy ? '使用自动生成' : '高级模板'}
</button>
</div>
{useAdvancedComfy && (
<>
<label className="money-printer-field">
<span>工作流模板</span>
<select value={templateId} onChange={(event) => setTemplateId(event.target.value)}>
<option value="">请选择模板</option>
{workflows.map((workflow) => (
<option key={workflow.publicId} value={workflow.publicId}>
{workflow.name} · {templateLabel(workflow)}
</option>
))}
</select>
</label>
{selectedWorkflow && (
<div className="money-printer-template-meta">
<strong>{selectedWorkflow.name}</strong>
<span>{mappingFromGraph(selectedWorkflow.graph) ? '已带节点映射' : '这个模板没有内置节点映射,系统会尝试自动推断。'}</span>
</div>
)}
<label className="money-printer-field">
<span>Comfy prompt JSON</span>
<textarea value={comfyPrompt} onChange={(event) => setComfyPrompt(event.target.value)} rows={7} placeholder='{"12":{"class_type":"...","inputs":{...}}}' />
</label>
<label className="money-printer-field">
<span>节点映射 JSON</span>
<textarea value={comfyNodeMapping} onChange={(event) => setComfyNodeMapping(event.target.value)} rows={7} />
</label>
</>
)}
{!useAdvancedComfy && (
<label className="money-printer-field">
<span>工作流模板</span>
<select value={templateId} onChange={(event) => setTemplateId(event.target.value)}>
<option value="">请选择模板</option>
{workflows.map((workflow) => (
<option key={workflow.publicId} value={workflow.publicId}>
{workflow.name} · {templateLabel(workflow)}
</option>
))}
</select>
</label>
{selectedWorkflow ? (
<div className="money-printer-template-meta">
<strong>自动生成 Comfy prompt</strong>
<span>模型 {videoModel || '未填写'} / {ratio} / {resolution} / {duration} 秒</span>
<strong>{selectedWorkflow.name}</strong>
<span>{mappingFromGraph(selectedWorkflow.graph) ? '已带节点映射' : '这个模板没有内置节点映射,系统会尝试自动推断。'}</span>
</div>
)}
) : null}
<label className="money-printer-field">
<span>Comfy prompt JSON</span>
<textarea value={comfyPrompt} onChange={(event) => setComfyPrompt(event.target.value)} rows={7} placeholder='{"12":{"class_type":"...","inputs":{...}}}' />
</label>
<label className="money-printer-field">
<span>节点映射 JSON</span>
<textarea value={comfyNodeMapping} onChange={(event) => setComfyNodeMapping(event.target.value)} rows={7} />
</label>
</div>
)}
</section>