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.

Keep a rejected entry explained until that field is accepted

Bowen Xuea6fbe5e4414a
diff --git a/freevideo_engine/hf_auth.py b/freevideo_engine/hf_auth.py
index 0b43569..42d5c3b 100644
--- a/freevideo_engine/hf_auth.py
+++ b/freevideo_engine/hf_auth.py
@@ -8,14 +8,28 @@ HELP_EN = ('Optional: add a Hugging Face read token to use your account’s down
'Kept for this session only. You can continue without it.')
HELP_ZH = ('可选:填写 Hugging Face 读取 Token,使用账号下载额度,减少匿名限流。'
'可能更快,但不保证提速。仅本次打开有效,不填写也能继续。')
+ERROR_EN = 'Enter a token that begins with hf_ and contains only letters and digits, or leave the field empty.'
+ERROR_ZH = '令牌应以 hf_ 开头,只含英文字母和数字;也可留空。'
-def validate(value):
+def clean(value):
+ """Remove surrounding whitespace, paired quotes and an HF_TOKEN= prefix."""
if not isinstance(value, str):
- raise ValueError('Enter a Hugging Face token beginning with hf_, or leave it empty.')
+ raise ValueError(ERROR_EN)
value = value.strip()
+ if len(value) >= 2 and value[0] in ('"', "'") and value[-1] == value[0]:
+ value = value[1:-1].strip()
+ if value[:9].upper() == 'HF_TOKEN=':
+ value = value[9:].strip()
+ if len(value) >= 2 and value[0] in ('"', "'") and value[-1] == value[0]:
+ value = value[1:-1].strip()
+ return value
+
+
+def validate(value):
+ value = clean(value)
if value and not re.fullmatch(r'hf_[A-Za-z0-9]{1,4093}', value):
- raise ValueError('Enter a Hugging Face token beginning with hf_, or leave it empty.')
+ raise ValueError(ERROR_EN)
return value
diff --git a/freevideo_engine/launcher/Main.qml b/freevideo_engine/launcher/Main.qml
index 49a6e8c..60d998e 100644
--- a/freevideo_engine/launcher/Main.qml
+++ b/freevideo_engine/launcher/Main.qml
@@ -1208,6 +1208,7 @@ ApplicationWindow {
FGroup {
Layout.fillWidth: true; title: t("Hugging Face token · optional", "Hugging Face 令牌 · 可选")
FField { Layout.fillWidth: true; echoMode: TextInput.Password; placeholderText: s.token_set ? t("Token set for this session", "本次已设置令牌") : "hf_…"; enabled: !s.busy; onEditingFinished: backend.edit("token", text) }
+ FText { objectName: "tokenError"; visible: s.field_error.key === "token"; text: visible ? s.field_error.message : ""; color: theme.danger; font.pixelSize: theme.micro; Layout.fillWidth: true }
RowLayout {
Layout.fillWidth: true; spacing: 12
FText { text: t("Use your account's download quota. Kept for this session only.", "使用账号下载额度,仅本次打开有效。"); color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true }
@@ -1428,6 +1429,7 @@ ApplicationWindow {
FGroup {
Layout.fillWidth: true; title: t("ComfyUI address", "ComfyUI 地址")
FField { objectName: "listenAddress"; Layout.fillWidth: true; value: s.form.url; enabled: !s.form.lan_access; onEditingFinished: backend.edit("url", text) }
+ FText { objectName: "addressError"; visible: s.field_error.key === "url"; text: visible ? s.field_error.message : ""; color: theme.danger; font.pixelSize: theme.micro; Layout.fillWidth: true }
FText { objectName: "listenAddressHint"; text: s.lan_password_set ? t("With 0.0.0.0 or this computer's LAN IP, devices on the same network can open FreeVideo without the password.", "填 0.0.0.0 或本机的局域网 IP 后,同一网络中的设备不用密码就能打开 FreeVideo。") : t("With 0.0.0.0 or this computer's LAN IP, devices on the same network can open FreeVideo without the access link.", "填 0.0.0.0 或本机的局域网 IP 后,同一网络中的设备不需要访问链接就能打开 FreeVideo。"); color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true }
FText { visible: Qt.platform.os === "windows"; text: t("Windows will ask for permission. Check \"Private networks\", then click \"Allow access\".", "Windows 会弹出确认框,请勾选“专用网络”,再点“允许访问”。"); color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true }
}
diff --git a/freevideo_engine/launcher_session.py b/freevideo_engine/launcher_session.py
index 4728af9..865d8b3 100644
--- a/freevideo_engine/launcher_session.py
+++ b/freevideo_engine/launcher_session.py
@@ -132,6 +132,7 @@ class Session:
self.page = 'comfy'
self.token = ''
self.error = ''
+ self.field_error = {}
self.notice = ''
self.action_notice = ''
self.pending_update = None
@@ -261,6 +262,10 @@ class Session:
self.persist()
def edit(self, key, value):
+ # A rejected entry stays explained until that field is accepted; the text is in the old
+ # interface language after a switch.
+ if self.field_error and key in (self.field_error.get('key'), 'language'):
+ self.field_error = {}
if key in ('engine', 'comfy', 'destination', 'new_comfy', 'offline_runtime') and not self.can_manage():
self.explain_busy()
return
@@ -272,8 +277,12 @@ class Session:
if key == 'token':
if self.controller.busy:
raise ValueError(self.t('Pause installation before changing the token.', '请先暂停安装,再修改 Token。'))
- from .hf_auth import validate
- self.token = validate(str(value)); return
+ from .hf_auth import ERROR_EN, ERROR_ZH, validate
+ try:
+ self.token = validate(str(value))
+ except ValueError:
+ raise ValueError(self.t(ERROR_EN, ERROR_ZH)) from None
+ return
if key not in self.form:
return
if self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy:
@@ -282,7 +291,16 @@ class Session:
if key in ('separate', 'repair', 'new_comfy', 'sampling_caches', 'lan_access', 'image_model', 'prompt_model', 'prompt_hint_dismissed'):
value = bool(value)
if key == 'url':
- value = local_url(str(value))
+ try:
+ value = local_url(str(value))
+ except ValueError as exc:
+ if str(exc).startswith(('Invalid ComfyUI port', 'Port ')):
+ message = self.t('The ComfyUI port is not valid.', 'ComfyUI 端口无效。')
+ else:
+ message = self.t(
+ 'Enter localhost or an IP address of this computer, for example http://127.0.0.1:8188.',
+ '请输入 localhost 或本机的 IP 地址,例如 http://127.0.0.1:8188。')
+ raise ValueError(message) from None
if key == 'environment_method' and value not in ('auto', 'manual'):
raise ValueError('Unknown environment installation method')
if key == 'environment_method' and value == 'manual' and not runtime_packages_supported():
@@ -2333,7 +2351,8 @@ class Session:
and not self.form['offline_runtime'], zh)),
video_model_guide=video_instructions(zh),
adaln_dialog=self.adaln_dialog_view(error, update),
- selected=bool(self.selected), can_repair=self.can_repair(), repair_offered=repair_offered, error=error, retry_kind=self.retry_kind(), notice=self.notice,
+ selected=bool(self.selected), can_repair=self.can_repair(), repair_offered=repair_offered, error=error,
+ field_error=dict(self.field_error or {}), retry_kind=self.retry_kind(), notice=self.notice,
# Qt reads a list as an array; LEVELS is a tuple.
compatibility=dict(self.compatibility, levels=list(self.compatibility.get('levels') or ())),
report=dict(self.report),
diff --git a/freevideo_engine/modern_launcher.py b/freevideo_engine/modern_launcher.py
index e781524..5aef4a3 100644
--- a/freevideo_engine/modern_launcher.py
+++ b/freevideo_engine/modern_launcher.py
@@ -143,7 +143,14 @@ def create_ui(session, *, show=True):
@Slot(str, 'QVariant')
def edit(self, key, value):
- self.invoke(session.edit, key, value)
+ def edit_field():
+ try:
+ session.edit(key, value)
+ except ValueError as exc:
+ if key not in ('token', 'url'):
+ raise
+ session.field_error = dict(key=key, message=str(exc))
+ self.invoke(edit_field)
@Slot(str, bool)
def action(self, name, accepted=False):