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.

Launcher: a missing prompt model list no longer fails the whole page

Bowen Xue0848a94d7e1e
diff --git a/freevideo_engine/launcher/Main.qml b/freevideo_engine/launcher/Main.qml
index 43ced31..8f72418 100644
--- a/freevideo_engine/launcher/Main.qml
+++ b/freevideo_engine/launcher/Main.qml
@@ -675,7 +675,7 @@ ApplicationWindow {
}
RowLayout {
objectName: "promptModelRow"
- visible: !!s.prompt_model && !s.prompt_model.ready && !s.prompt_model.checking
+ visible: !!s.prompt_model && !s.prompt_model.ready && !s.prompt_model.checking && !s.prompt_model.unavailable
Layout.fillWidth: true; spacing: 14
FCheck {
objectName: "promptModelSwitch"; Layout.fillWidth: true
diff --git a/freevideo_engine/launcher_session.py b/freevideo_engine/launcher_session.py
index 311d1b3..3d7b718 100644
--- a/freevideo_engine/launcher_session.py
+++ b/freevideo_engine/launcher_session.py
@@ -822,7 +822,8 @@ class Session:
if self.form['prompt_model'] and self.installation_engine() and self.controller.state.get('status') == 'open' \
and not self.controller.busy and not (self.prompt_installer and self.prompt_installer.busy):
from .prompt_vlm import assets
- if not assets.ready(self._image_location()[1]):
+ # Without its model list the download cannot start; the tick stays for a later start.
+ if assets.available() and not assets.ready(self._image_location()[1]):
self.prompt_model_action('install')
if self.prompt_installer and self.prompt_installer.busy or assets.ready(self._image_location()[1]):
self.form['prompt_model'] = False
@@ -854,7 +855,7 @@ class Session:
if self.prompt_installer and self.prompt_installer.busy:
return
from .prompt_vlm import assets
- if assets.checking(engine):
+ if assets.checking(engine) or not assets.available():
return
if not (self.prompt_installer and self.prompt_installer.root == engine):
self.prompt_installer = prompt_installer.Installer(engine, busy=self.generating)
@@ -863,7 +864,13 @@ class Session:
def prompt_model_view(self):
"""The prompt model as a row of the download card and as the suggestion on the home page."""
from .prompt_vlm import assets
- spec = assets.catalog()
+ try:
+ spec = assets.catalog()
+ except (OSError, ValueError):
+ # Without its model list the row can neither be described nor offered, but
+ # a missing resource must not take the whole launcher page down with it.
+ return dict(ready=False, checking=False, unavailable=True, total_bytes=0, enough_disk=True, busy=False,
+ install={}, failure='', downloaded_bytes=0, title=self.t(*NAMES['text']), suggest=False)
total = sum(row['bytes'] for row in spec['files'])
engine = self._image_location()[1] if self.installation_engine() else None
ready = bool(engine) and assets.ready(engine)
diff --git a/freevideo_engine/prompt_vlm/assets.py b/freevideo_engine/prompt_vlm/assets.py
index a2f3177..185e36d 100644
--- a/freevideo_engine/prompt_vlm/assets.py
+++ b/freevideo_engine/prompt_vlm/assets.py
@@ -2,6 +2,7 @@
import json
from pathlib import Path
import shutil
+import sys
import threading
from .. import disk_space
@@ -9,7 +10,31 @@ FAMILY = 'image-models'
def catalog():
- return json.loads(Path(__file__).with_name('model.json').read_text(encoding='utf-8'))
+ """The model list shipped beside this file.
+
+ A frozen launcher also carries the engine source; its copy answers when the
+ unpacked one is gone (a cleaned temporary folder, antivirus, an interrupted
+ unpack). Nothing is remembered, so a restored file is used at once."""
+ name = 'model.json'
+ paths = [Path(__file__).with_name(name)]
+ bundle = getattr(sys, '_MEIPASS', None)
+ if bundle:
+ paths.append(Path(bundle) / 'engine-source' / 'freevideo_engine' / 'prompt_vlm' / name)
+ for path in paths:
+ try:
+ return json.loads(path.read_text(encoding='utf-8'))
+ except (OSError, ValueError) as error:
+ missing = error
+ raise missing
+
+
+def available():
+ """False while the model list cannot be read; nothing can be described or offered then."""
+ try:
+ catalog()
+ except (OSError, ValueError):
+ return False
+ return True
def directory(root):
@@ -38,8 +63,8 @@ _RUNNING = set()
def _state(root, wait):
- spec, folder = catalog(), directory(root)
try:
+ spec, folder = catalog(), directory(root)
receipt = json.loads((folder / 'verified.json').read_text(encoding='utf-8'))
if receipt.get('revision') != spec['revision']:
return False
@@ -73,8 +98,8 @@ def checking(root):
A cheap look at the same file identity ready() uses, for a page that must not
call the model missing, or offer its download, in the meantime."""
- spec, folder = catalog(), directory(root)
try:
+ spec, folder = catalog(), directory(root)
receipt = json.loads((folder / 'verified.json').read_text(encoding='utf-8'))
if receipt.get('revision') != spec['revision']:
return False
diff --git a/freevideo_engine/prompt_vlm/service.py b/freevideo_engine/prompt_vlm/service.py
index 918eb59..4e8fc64 100644
--- a/freevideo_engine/prompt_vlm/service.py
+++ b/freevideo_engine/prompt_vlm/service.py
@@ -221,7 +221,10 @@ class Service:
def info(self, wait=True):
"""wait=False answers from the cheap check, for callers on an event loop or UI thread."""
root, machine = self.installation()
- spec = assets.catalog()
+ try:
+ spec = assets.catalog()
+ except (OSError, ValueError):
+ return dict(ready=False, model='', license='', bytes=0, busy=self.busy(), ram_bytes=self.ram_bytes(machine))
return dict(ready=assets.settle(root) if wait else assets.ready(root), model=spec['repo'], license=spec['license'],
bytes=sum(row['bytes'] for row in spec['files']), busy=self.busy(),
ram_bytes=self.ram_bytes(machine))
@@ -435,7 +438,10 @@ class Service:
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')}
- spec = assets.catalog()
+ try:
+ spec = assets.catalog()
+ except (OSError, ValueError):
+ spec = dict(repo='', revision='')
report.update(schema='freevideo.prompt-vlm', schema_version=2, action=action,
created_epoch=time.time(), report_id=uuid.uuid4().hex,
elapsed_seconds=time.monotonic() - started, model=spec['repo'],
diff --git a/freevideo_engine/request_assets.py b/freevideo_engine/request_assets.py
index 85136b1..dcddb4f 100644
--- a/freevideo_engine/request_assets.py
+++ b/freevideo_engine/request_assets.py
@@ -61,7 +61,11 @@ def _prompt_vlm(root):
from .prompt_vlm import assets
if assets.settle(root):
return []
- spec = assets.catalog()
+ try:
+ spec = assets.catalog()
+ except (OSError, ValueError):
+ # Nothing to download from, so the request is not ready for the rewrite step.
+ return [dict(id='prompt-vlm', kind='prompt-vlm', files=0, bytes=0, source='', action='unavailable')]
return [dict(id='prompt-vlm', kind='prompt-vlm', files=len(spec['files']),
bytes=sum(row['bytes'] for row in spec['files']), source='', action='consent')]
@@ -75,7 +79,8 @@ def inspect(root, machine, request, *, lora_names=None):
lora_names: the LoRA files that exist; None skips the LoRA check.
Every item: id, kind, files, bytes, source (id of the source tried first,
'' when not applicable) and action: 'auto' is fetched when Generate starts,
- 'consent' asks first, 'manual' means the user adds the file.
+ 'consent' asks first, 'manual' means the user adds the file, 'unavailable' means
+ the item's own list of files cannot be read, so it cannot be fetched at all.
"""
root = Path(root)
sampled, items = _sampling(root, machine, request)
diff --git a/web/request_assets.js b/web/request_assets.js
index 8aa02df..8bae5c0 100644
--- a/web/request_assets.js
+++ b/web/request_assets.js
@@ -56,6 +56,7 @@ export function createRequestAssets({t, api, request, onError = () => {}}) {
const wait = timeAfter(Object.values(bytes).reduce((sum, n) => sum + n, 0), rate, t);
if (parts.length) rows.push(t(`Downloads before generating: ${parts.join(', ')}${wait}`, `生成前会先下载:${parts.join('、')}${wait}`));
for (const item of items) {
+ if (item.action === 'unavailable') continue;
if (item.kind === 'prompt-vlm') {
const wait = timeAfter(item.bytes, rate, t);
rows.push(t(`First prompt rewrite downloads ${size(item.bytes)}${wait}`, `首次改写提示词会先下载 ${size(item.bytes)}${wait}`));