Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Add prompt model download notice for multi-part videos

Bowen Xuedae8a954ac10
diff --git a/web/prompt_enhance.js b/web/prompt_enhance.js
index 2c46e33..4fd9341 100644
--- a/web/prompt_enhance.js
+++ b/web/prompt_enhance.js
@@ -97,6 +97,7 @@ export function createPromptEnhancer({node, input, editor, api, context, setText
meter.append(fill); status.append(statusText, meter, report);
// One place sets what the status line says and how it looks.
function show(text, state = '', fraction = null) {
+ if (downloadOnly) { publishModel({text: text || ''}); return; }
statusText.textContent = text || '';
status.dataset.state = text ? state : '';
report.hidden = !text || state !== 'error';
@@ -114,6 +115,26 @@ export function createPromptEnhancer({node, input, editor, api, context, setText
install.append(detail, actions);
bar.append(label, tabs, redo, cancel); element.append(bar, editor || input, status, install);
let disposed = false, token = '', job = '', running = null, consent = null, cancelling = false, waiting = false, replacing = false;
+ let downloadOnly = false, modelReading = null;
+ const modelState = {info: null, text: '', busy: false}, modelListeners = new Set();
+ function publishModel(change) {
+ Object.assign(modelState, change);
+ if (!disposed) for (const listener of modelListeners) listener(modelState);
+ }
+ // Share status with the length notice, including installs started by enhancement.
+ function readModel() {
+ if (modelReading) return modelReading;
+ modelReading = (async () => {
+ const reply = await api.fetchApi('/freevideo/prompt-vlm');
+ const info = await reply.json();
+ if (!reply.ok) throw new Error(info.error || 'request_failed');
+ token = info.token;
+ if (info.ram_bytes) ramBytes = info.ram_bytes;
+ publishModel({info});
+ return info;
+ })().catch(error => { publishModel({info: null}); throw error; }).finally(() => { modelReading = null; });
+ return modelReading;
+ }
const prestart = promptPrestart(api, node.id, () => versions.value.enabled, () => !disposed && !input.disabled);
const onFocus = () => { if (versions.value.enabled) void prestart.request(); };
input.addEventListener('focus', onFocus);
@@ -225,12 +246,11 @@ export function createPromptEnhancer({node, input, editor, api, context, setText
}
if (row.phase === 'complete') return row;
if (row.phase === 'failed') throw Object.assign(new Error(row.error || 'rewrite_failed'), {ramBytes: row.diagnostics?.ram_required_bytes});
- if (row.phase === 'cancelled') throw new Error('cancelled');
+ if (row.phase === 'cancelled') throw new Error(action === 'install' ? 'download_failed' : 'cancelled');
if (disposed) throw new Error('cancelled');
if (row.phase === 'download') {
- const fraction = (row.done || 0) / (row.total || 1), gib = value => (value / 2 ** 30).toFixed(1);
- show(t(`Downloading the model · ${gib(row.done || 0)} / ${gib(row.total || 0)} GiB`, `正在下载模型 · ${gib(row.done || 0)} / ${gib(row.total || 0)} GiB`), 'progress', fraction);
- } else {
+ showDownload(row.done || 0, row.total || 0);
+ } else if (action !== 'install') {
// The ellipsis says "still going" until the seconds start counting.
const [en, zh] = row.phase === 'rewriting' ? ['Enhancing the prompt', '正在改写提示词'] : ['Preparing enhancement', '正在准备提示词增强'];
const s = elapsed(), m = Math.floor(s / 60), r = s % 60;
@@ -245,6 +265,46 @@ export function createPromptEnhancer({node, input, editor, api, context, setText
throw error;
} finally { job = ''; }
}
+ function showDownload(done, total) {
+ const size = value => (value / 2 ** 30).toFixed(1);
+ const text = t(`Downloading the model · ${size(done)} / ${size(total)} GiB`, `正在下载模型 · ${size(done)} / ${size(total)} GiB`);
+ publishModel({text}); show(text, 'progress', done / (total || 1));
+ }
+ async function installModel(info) {
+ if (info.ready) return true;
+ const model = String(info.model || 'Qwen/Qwen3-VL-4B-Instruct').split('/').pop().replace(/-Instruct$/, '');
+ detail.textContent = t(`Local model ${model} · ${(info.bytes / 2 ** 30).toFixed(1)} GiB download · needs ${gib(ramBytes)} GiB free RAM. Your prompt and images stay on this computer.`,
+ `本地模型 ${model} · 下载 ${(info.bytes / 2 ** 30).toFixed(1)} GiB · 需 ${gib(ramBytes)} GiB 可用内存。提示词和图片只在本机处理。`);
+ agree.textContent = downloadOnly ? t('Download', '下载') : t('Download and enable', '下载并启用');
+ install.hidden = false; render();
+ if (downloadOnly) install.scrollIntoView({block: 'nearest'});
+ const accepted = await new Promise(resolve => { consent = resolve; agree.onclick = () => resolve(true); decline.onclick = () => resolve(false); });
+ consent = null; install.hidden = true; render();
+ if (!accepted || disposed || cancelling) return false;
+ publishModel({busy: true}); showDownload(0, info.bytes || 0);
+ try {
+ await poll('install', {accept_download: true});
+ // A complete install is already authoritative; refresh metadata as well.
+ publishModel({info: {...info, ready: true}, text: ''});
+ await readModel().catch(() => {});
+ } catch (error) {
+ publishModel({text: errorText(error)});
+ throw error;
+ } finally { publishModel({busy: false}); }
+ return true;
+ }
+ function downloadModel() {
+ if (running || disposed) return;
+ downloadOnly = true; cancelling = false;
+ running = Promise.resolve().then(async () => {
+ const info = await readModel();
+ if (!disposed && !cancelling) await installModel(info);
+ }).catch(error => { if (!disposed) show(errorText(error)); }).finally(() => {
+ running = null; downloadOnly = false; cancelling = false; install.hidden = true; render();
+ });
+ render();
+ return running;
+ }
async function enhance() {
if (running) return running;
if (!versions.value.original.trim()) {
@@ -256,25 +316,12 @@ export function createPromptEnhancer({node, input, editor, api, context, setText
if (disposed || cancelling) throw new Error('cancelled');
versions.value.useOriginal = false;
const scene = context(), key = versions.key(scene), original = versions.value.original, edits = versions.value.edits;
- const reply = await api.fetchApi('/freevideo/prompt-vlm');
- const info = await reply.json();
+ const info = await readModel();
if (disposed || cancelling) throw new Error('cancelled');
- if (!reply.ok) throw new Error(info.error);
- token = info.token;
- if (info.ram_bytes) ramBytes = info.ram_bytes;
- if (!info.ready) {
- const model = String(info.model || 'Qwen/Qwen3-VL-4B-Instruct').split('/').pop().replace(/-Instruct$/, '');
- detail.textContent = t(`Local model ${model} · ${(info.bytes / 2 ** 30).toFixed(1)} GiB download · needs ${gib(ramBytes)} GiB free RAM. Your prompt and images stay on this computer.`,
- `本地模型 ${model} · 下载 ${(info.bytes / 2 ** 30).toFixed(1)} GiB · 需 ${gib(ramBytes)} GiB 可用内存。提示词和图片只在本机处理。`);
- install.hidden = false; render();
- const accepted = await new Promise(resolve => { consent = resolve; agree.onclick = () => resolve(true); decline.onclick = () => resolve(false); });
- consent = null; install.hidden = true; render();
- if (!accepted || disposed || cancelling) {
- versions.value.enabled = false;
- versions.select('original'); apply();
- throw new Error('cancelled');
- }
- await poll('install', {accept_download: true});
+ if (!await installModel(info)) {
+ versions.value.enabled = false;
+ versions.select('original'); apply();
+ throw new Error('cancelled');
}
const result = await poll('rewrite', {text: prepare(original), ...scene});
if (disposed || cancelling) throw new Error('cancelled');
@@ -300,7 +347,10 @@ export function createPromptEnhancer({node, input, editor, api, context, setText
versions.value.selected = 'original'; apply();
show(t(`Generated with the original prompt. ${fallbackText(error)}`, `已用原文生成。${fallbackText(error)}`), 'note');
}
- return {element, async beforeGenerate() {
+ return {element, model: {read: readModel, download: downloadModel, subscribe(listener) {
+ modelListeners.add(listener); listener(modelState);
+ return () => modelListeners.delete(listener);
+ }}, async beforeGenerate() {
if (running) {
try { await running; }
catch (error) {
@@ -318,7 +368,7 @@ export function createPromptEnhancer({node, input, editor, api, context, setText
useOriginal(error);
}
}, sync() { if (input.value !== versions.text()) changed(); }, dispose() {
- disposed = true; prestart.dispose(); cancelJob().catch(() => {}); input.removeEventListener('input', changed);
+ disposed = true; modelListeners.clear(); prestart.dispose(); cancelJob().catch(() => {}); input.removeEventListener('input', changed);
input.removeEventListener('beforeinput', replace);
input.removeEventListener('focus', onFocus);
}};
diff --git a/web/studio.css b/web/studio.css
index 91a98ee..1b2c3d5 100644
--- a/web/studio.css
+++ b/web/studio.css
@@ -35,6 +35,9 @@
.fv-studio .fv-length-link{display:inline;min-height:0;padding:0;border:0;border-radius:0;background:transparent;color:var(--fv-accent);font:inherit;vertical-align:baseline;text-decoration:underline;text-underline-offset:3px;white-space:nowrap}
.fv-studio .fv-length-link:hover{background:transparent;color:var(--fv-ink)}
.fv-studio .fv-length-link:focus-visible{outline:2px solid var(--fv-accent);outline-offset:3px}
+.fv-studio .fv-length-model{margin:12px 0;line-height:1.6}
+.fv-studio .fv-length-model .fv-quiet{min-height:28px;padding:3px 8px;margin-left:4px;font:inherit;white-space:nowrap}
+@media(max-width:480px){.fv-studio .fv-length-model .fv-quiet{display:flex;width:max-content;margin:6px 0 0}}
.fv-studio .fv-resolution-select{position:relative;min-width:0}
.fv-studio .fv-resolution-select select{appearance:none;-webkit-appearance:none;color:transparent;padding-right:36px}
.fv-studio .fv-resolution-select option{color:var(--fv-ink)}
diff --git a/web/studio.js b/web/studio.js
index 047afe8..5395472 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -1006,7 +1006,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
};
}
advanced.append(custom);
- lengthControl = createStudioLength({api, node, seconds, advanced, fields, t, field,
+ lengthControl = createStudioLength({api, node, seconds, advanced, fields, t, field, promptModel: enhancer.model,
setSeconds: seconds => set(node, 'seconds', seconds), onChange: () => { if (runButtonReady) { updateRunButton(); showEffortEstimate(); updateDuration(); } },
onEditor: toEditor, onAutopilot: toAutopilot, autopilot: !autopilotTab.hidden});
cleanup.push(() => lengthControl.dispose());
diff --git a/web/studio_length.js b/web/studio_length.js
index bc72c78..dfd0b41 100644
--- a/web/studio_length.js
+++ b/web/studio_length.js
@@ -28,7 +28,7 @@ export async function readLengthCapability(api, context, signal, onReply = () =>
// onEditor and onAutopilot are the creation panel's own view-switch actions; autopilot says whether that tab shows.
export function createStudioLength({api, node, seconds, advanced, fields, t, field, setSeconds,
onChange = () => {}, capability = readLengthCapability, delay = 220, capabilityTimeout = 10000,
- onEditor = () => {}, onAutopilot = () => {}, autopilot = false}) {
+ onEditor = () => {}, onAutopilot = () => {}, autopilot = false, promptModel = null}) {
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text) e.textContent = text; return e; };
const controls = el('div', 'fv-length-controls'); controls.style.marginTop = '14px';
const single = el('input'); single.type = 'checkbox'; single.dataset.fvLength = 'single';
@@ -64,6 +64,13 @@ export function createStudioLength({api, node, seconds, advanced, fields, t, fie
: hint.replaceChildren(t('Each run makes one continuous shot, split into up to 8 parts when longer. ', '每次生成一个连续镜头,较长时自动分段,最多 8 段。'), ...storyboard());
writeHint();
fields.after(hint);
+ const modelNotice = el('div', 'fv-muted fv-length-model'); modelNotice.hidden = true; modelNotice.setAttribute('role', 'status');
+ const modelText = el('span');
+ const download = el('button', 'fv-quiet', t('Download prompt model', '下载提示词模型')); download.type = 'button';
+ modelNotice.append(modelText, download); hint.after(modelNotice);
+ download.onclick = () => { void promptModel?.download(); };
+ let modelState = {}, modelChecked = false;
+
let limits = null, planLimits = null, contextKey = '', revision = 0, timer = null, request = null, capabilityRequest = null, capabilityRevision = 0;
let capabilityState = 'idle', waiting = false, waitingTimer = null, timeoutTimer = null, submitted = false;
let plan = null, error = null, absent = false, disposed = false, pending = null, edited = false, blockEdited = false, plannedSeconds = null;
@@ -77,6 +84,20 @@ export function createStudioLength({api, node, seconds, advanced, fields, t, fie
blockSeconds: blockEdited || Object.hasOwn(node.properties || {}, LENGTH_PROPERTIES.block) ? Number(block.value)
: !planLimits && total() > 15 && total() <= 30 ? defaultBlockSeconds(null) : null};
}
+ function paintModel() {
+ const multiple = !absent && !error && plan?.count >= 2;
+ modelNotice.hidden = !multiple || modelState.info?.ready !== false;
+ modelText.textContent = modelState.text || t('The prompt model is not installed, so the description will be split across the parts by sentence.', '未安装提示词模型,描述将按句子顺序分到各段。');
+ download.hidden = Boolean(modelState.busy); download.disabled = Boolean(modelState.busy);
+ // Pending plans do not reset the check on every keystroke. A known single part does.
+ if (plan?.count === 1 || (!plan && !effectiveSingle() && total() <= singleLimitSeconds(planLimits?.maximum)
+ && !Object.hasOwn(node.properties || {}, LENGTH_PROPERTIES.block))) modelChecked = false;
+ if (multiple && !modelChecked && promptModel) {
+ modelChecked = true;
+ promptModel.read().catch(() => {});
+ }
+ }
+ const unsubscribeModel = promptModel?.subscribe(state => { modelState = state; if (!disposed) paintModel(); });
function paint() {
const maximum = planLimits?.maximum, forcedMaximum = planLimits?.singleMaximum;
const clamped = positive(maximum) && node.properties?.[LENGTH_PROPERTIES.block] > maximum;
@@ -103,6 +124,7 @@ export function createStudioLength({api, node, seconds, advanced, fields, t, fie
if (error === 'too_long') note.replaceChildren(TOO_LONG(), ...storyboard());
else note.textContent = error ? errorMessage(error) : '';
if (error === 'other') note.append(issueButton(t, () => ({where: ['Video length planning', '视频分段规划'], message: errorMessage('other')})));
+ paintModel();
note.style.margin = noParts && error === 'continuation_unavailable' ? '12px 0' : ''; // as spaced as the line it replaces
}
function errorMessage(kind) {
@@ -215,6 +237,6 @@ export function createStudioLength({api, node, seconds, advanced, fields, t, fie
catch { settle(null); }
})();
},
- dispose() { disposed = true; clearTimeout(timer); clearTimeout(waitingTimer); clearTimeout(timeoutTimer); request?.abort(); capabilityRequest?.abort(); seconds.removeEventListener('input', input); },
+ dispose() { disposed = true; unsubscribeModel?.(); clearTimeout(timer); clearTimeout(waitingTimer); clearTimeout(timeoutTimer); request?.abort(); capabilityRequest?.abort(); seconds.removeEventListener('input', input); },
};
}