Use Comfy API for MoneyPrinter video generation

This commit is contained in:
boos
2026-06-02 16:47:48 +08:00
parent b29c7ffa7a
commit 1293ebae68
3 changed files with 505 additions and 43 deletions
+37
View File
@@ -49,12 +49,15 @@ 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 [style, setStyle] = useState(STYLE_PRESETS[0]);
const [audienceText, setAudienceText] = useState('AI 工具用户、内容创作者、企业运营');
const [duration, setDuration] = useState(30);
const [ratio, setRatio] = useState('9:16');
const [resolution, setResolution] = useState('1080p');
const [requirements, setRequirements] = useState('画面要有科技感,突出统一网关、多模型、多模态和工作流能力。');
const [comfyPrompt, setComfyPrompt] = useState('');
const [comfyNodeMapping, setComfyNodeMapping] = useState('{\n "prompt": { "nodeId": "", "field": "prompt" },\n "negativePrompt": { "nodeId": "", "field": "text" },\n "ratio": { "nodeId": "", "field": "ratio" },\n "resolution": { "nodeId": "", "field": "resolution" },\n "duration": { "nodeId": "", "field": "duration" }\n}');
const [jobs, setJobs] = useState<MoneyPrinterJob[]>([]);
const [submitting, setSubmitting] = useState(false);
const [error, setError] = useState('');
@@ -86,6 +89,7 @@ export default function MoneyPrinter() {
const payload = await client.createMoneyPrinterJob({
topic: topic.trim(),
scriptModel: scriptModel.trim(),
videoBackend,
videoModel: videoModel.trim(),
style,
audience: audienceText,
@@ -94,6 +98,10 @@ export default function MoneyPrinter() {
resolution,
requirements,
language: '中文',
...(videoBackend === 'comfy' ? {
comfyPrompt: comfyPrompt.trim() ? JSON.parse(comfyPrompt) : undefined,
comfyNodeMapping: comfyNodeMapping.trim() ? JSON.parse(comfyNodeMapping) : undefined,
} : {}),
});
setJobs((prev) => [payload.job, ...prev.filter((item) => item.id !== payload.job.id)]);
} catch (err: any) {
@@ -117,6 +125,7 @@ export default function MoneyPrinter() {
const request = job.result?.request || {};
setTopic(request.topic || job.result?.topic || topic);
setScriptModel(request.scriptModel || scriptModel);
setVideoBackend(request.videoBackend || videoBackend);
setVideoModel(request.videoModel || request.model || videoModel);
setStyle(request.style || style);
setAudienceText(request.audience || audienceText);
@@ -124,6 +133,8 @@ export default function MoneyPrinter() {
setRatio(request.ratio || ratio);
setResolution(request.resolution || resolution);
setRequirements(request.requirements || requirements);
setComfyPrompt(request.comfyPrompt ? JSON.stringify(request.comfyPrompt, null, 2) : comfyPrompt);
setComfyNodeMapping(request.comfyNodeMapping ? JSON.stringify(request.comfyNodeMapping, null, 2) : comfyNodeMapping);
};
return (
@@ -160,6 +171,13 @@ export default function MoneyPrinter() {
<span>脚本模型</span>
<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>
<option value="boosapi">BoosAPI /v1/videos</option>
</select>
</label>
<label className="money-printer-field">
<span>视频模型</span>
<input value={videoModel} onChange={(event) => setVideoModel(event.target.value)} />
@@ -202,6 +220,25 @@ export default function MoneyPrinter() {
<span>额外要求</span>
<textarea value={requirements} onChange={(event) => setRequirements(event.target.value)} rows={4} />
</label>
{videoBackend === 'comfy' && (
<div className="money-printer-comfy-box">
<div className="money-printer-section-head">
<div>
<h2>Comfy API 工作流</h2>
<p>粘贴 Comfy API prompt JSON,并填写要注入视频提示词等参数的节点映射。</p>
</div>
</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>
</div>
)}
</section>
<section className="money-printer-panel">