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.
Prompt enhancement retries missing media and names the fallback reason
Bowen Xue603911d6b08f
diff --git a/freevideo_engine/prompt_vlm/rules.py b/freevideo_engine/prompt_vlm/rules.pyindex 8d4e8a6..1f36d93 100644--- a/freevideo_engine/prompt_vlm/rules.py+++ b/freevideo_engine/prompt_vlm/rules.py@@ -143,6 +143,7 @@ class InvalidOutput(ValueError):indices = {int(i) for i in re.findall(r'<Picture (\d+)>', draft)}self.details = dict(condition=condition, output_characters=len(draft),missing_pictures=sorted(i for i in pictures if f'<Picture {i}>' not in draft),+ missing_references=[each for each in required if each not in draft],out_of_range_pictures=sorted(i for i in indices if i not in pictures),retried=False)diff --git a/freevideo_engine/prompt_vlm/service.py b/freevideo_engine/prompt_vlm/service.pyindex 4e8fc64..b8f6bee 100644--- a/freevideo_engine/prompt_vlm/service.py+++ b/freevideo_engine/prompt_vlm/service.py@@ -434,7 +434,7 @@ class Service:self.progress(dict(phase='cancelled'))self.result_expires = time.monotonic() + 600# Allowlisted metadata only, never original/rewritten text or input paths.- # Output rejections contain condition IDs, character counts, picture numbers and retry flags only.+ # Output rejections contain condition IDs, counts, typed media labels and retry flags only.report = {key: item for key, item in self.state.items()if key in ('phase', 'error', 'exception', 'error_details', 'timings', 'diagnostics','resources', 'cleanup', 'worker_returncode', 'output_rejection')}@@ -609,7 +609,8 @@ class Service:rules.validate_output(result.get('text'), value)except rules.InvalidOutput as error:stats = result.get('diagnostics') or {}- error.details['retried'] = bool(stats.get('picture_retry') or stats.get('dialogue_retry'))+ error.details['retried'] = bool(stats.get('media_retry') or stats.get('picture_retry')+ or stats.get('dialogue_retry'))self.progress(dict(diagnostics=stats))raiseself.progress(dict(result, worker_returncode=child.returncode))diff --git a/freevideo_engine/prompt_vlm/worker.py b/freevideo_engine/prompt_vlm/worker.pyindex 0b6f97e..3d8bfbe 100644--- a/freevideo_engine/prompt_vlm/worker.py+++ b/freevideo_engine/prompt_vlm/worker.py@@ -420,19 +420,19 @@ def rewrite(folder, value, stats):text = processor.decode(ids, skip_special_tokens=True)missing = missing_lines(text, value['text'])rewritten, rejected = None, None- pictures = []+ references = []try:rewritten = validate_rewrite(text, value, stats)except InvalidOutput as error:rejected = errorif error.details['condition'] == 'missing_picture_reference':- pictures = error.details['missing_pictures']- if missing or pictures:+ references = error.details['missing_references']+ if missing or references:# Both corrections share one turn and the existing context/cache allowance.correction = ''- if pictures:- labels = ', '.join(f'<Picture {i}>' for i in pictures)- correction = (f'Your rewrite omitted these required image references: {labels}. '+ if references:+ labels = ', '.join(references)+ correction = (f'Your rewrite omitted these required media references: {labels}. ''Preserve all existing content and add each missing reference where it belongs. ''Return the complete prompt in the same required section format.\n')if missing:@@ -445,24 +445,28 @@ def rewrite(folder, value, stats):stats.update(retry_output_tokens=len(again), rewrite_seconds=time.monotonic() - loaded)if missing:stats['dialogue_retry'] = True- if pictures:- stats['picture_retry'] = True+ if references:+ stats['media_retry'] = True+ if any(each.startswith('<Picture ') for each in references):+ stats['picture_retry'] = True # Retain the existing image diagnostic.try:candidate = validate_rewrite(second, value, stats, retried=True)- if pictures and len(again) >= 1800:+ if references and len(again) >= 1800:error = InvalidOutput('output_token_limit', second, value)error.details['retried'] = Truestats['output_rejections'].append(error.details)raise error- if len(again) < 1800 and (pictures or len(missing_lines(second, value['text'])) < len(missing)):+ if len(again) < 1800 and (references or len(missing_lines(second, value['text'])) < len(missing)):rewritten = candidateexcept InvalidOutput:- if pictures:+ if references:raise- elif pictures:- stats['picture_retry_skipped'] = stats.get('dialogue_retry_skipped', 'context_length')+ elif references:+ stats['media_retry_skipped'] = stats.get('dialogue_retry_skipped', 'context_length')+ if any(each.startswith('<Picture ') for each in references):+ stats['picture_retry_skipped'] = stats['media_retry_skipped']if rewritten is None:- rejected.details = dict(rejected.details, retried=bool(stats.get('picture_retry') or stats.get('dialogue_retry')))+ rejected.details = dict(rejected.details, retried=bool(stats.get('media_retry') or stats.get('dialogue_retry')))raise rejectedstats['stage'] = 'complete'emit(phase='complete', text=rewritten, diagnostics=dict(stats))diff --git a/web/prompt_enhance.js b/web/prompt_enhance.jsindex a12259a..2c46e33 100644--- a/web/prompt_enhance.js+++ b/web/prompt_enhance.js@@ -121,6 +121,8 @@ export function createPromptEnhancer({node, input, editor, api, context, setText// Available RAM the model needs; the server knows the usual case for this card.let ramBytes = 11 * 2 ** 30;const gib = value => String(Math.round(value / 2 ** 30));+ // Unknown codes keep the server's own reason, without paths, so the user can quote it.+ const reasonOf = error => String(error?.message || '').replace(/[A-Za-z]:[\\/][^\s'"]*|\/[^\s'"]+\/[^\s'"]*/g, '').replace(/\s+/g, ' ').trim().slice(0, 120);const errorText = error => ({busy: t('Finish the current queue before enhancing this prompt.', '请等待当前队列完成后再改写。'),prompt_required: t('Type a prompt first; enhancement rewrites it before generating.', '请先输入提示词,生成前会自动改写。'),@@ -142,7 +144,25 @@ export function createPromptEnhancer({node, input, editor, api, context, setTextstale: t('The prompt or references changed. Rewrite again for the new scene.', '原文或素材已改变,请按新内容重新改写。'),cancelled: t('Cancelled. Your original prompt is retained.', '已取消,原文已保留。'),worker_cleanup_failed: t('The rewrite process could not close. Restart FreeVideo before generating.', '改写进程未能退出,请重启 FreeVideo 后再生成。'),- }[error?.message] || t('Could not enhance the prompt. Retry or switch enhancement off to use the original.', '暂时无法改写,请重试,或关闭增强使用原文。'));+ }[error?.message] || t(`Could not enhance the prompt${reasonOf(error) ? `: ${reasonOf(error)}` : ''}. Retry or switch enhancement off to use the original.`,+ `暂时无法改写${reasonOf(error) ? `。原因:${reasonOf(error)}。` : ','}请重试,或关闭增强使用原文。`));+ // After falling back the original is already in use, so only the reason and the next useful step are shown.+ const fallbackText = error => ({+ busy: t('The prompt cannot be rewritten while the queue is running.', '队列未完成时不能改写。'),+ setup_required: t('Rewriting is available after FreeVideo installation is complete.', 'FreeVideo 安装完成后才能改写。'),+ model_missing: t('Rewriting needs the optional model. Download it to enable rewriting.', '改写需要可选模型,下载后可用。'),+ download_failed: t('The optional model download paused. Retry to resume.', '可选模型下载已暂停,重试可继续下载。'),+ disk_space: t('Not enough disk space for the optional model.', '磁盘空间不足,无法安装可选模型。'),+ ram_space: t(`The rewrite model needs about ${gib(error?.ramBytes || ramBytes)} GiB of available RAM to load.`, `改写模型加载需约 ${gib(error?.ramBytes || ramBytes)} GiB 可用内存。`),+ invalid_prompt: t('Rewriting supports prompts of up to 12,000 characters.', '改写只支持不超过 12,000 字符的提示词。'),+ invalid_output: t('The rewrite was incomplete.', '改写结果不完整。'),+ context_length: t('The scene is too long for the rewrite model.', '内容超出改写模型容量。'),+ out_of_memory: t('Not enough memory to rewrite. Close other GPU apps before rewriting again.', '改写时内存不足,关闭其他显卡程序后可再改写。'),+ timeout: t('Rewriting took too long.', '改写超时。'),+ unsupported_media: errorText(error), too_many_images: errorText(error), stale: errorText(error),+ connected_media: errorText(error), audio_media: errorText(error), unreadable_video: errorText(error),+ worker_cleanup_failed: errorText(error),+ }[error?.message] || (reasonOf(error) ? t(`The rewrite failed: ${reasonOf(error)}.`, `改写失败,原因:${reasonOf(error)}。`) : t('The rewrite failed.', '改写失败。')));function save(changed = true) {node.properties ||= {};node.properties.freevideo_prompt_versions = {...versions.value};@@ -278,7 +298,7 @@ export function createPromptEnhancer({node, input, editor, api, context, setTextfunction useOriginal(error) {console.warn('FreeVideo prompt rewrite failed; using the original prompt.', error?.message);versions.value.selected = 'original'; apply();- show(t('Could not enhance; generated with the original.', '没能改写,已用原文生成。'), 'note');+ show(t(`Generated with the original prompt. ${fallbackText(error)}`, `已用原文生成。${fallbackText(error)}`), 'note');}return {element, async beforeGenerate() {if (running) {