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.
A LoRA trigger word inside a longer word (sks in asks) no longer counts as already written
Bowen Xuedf3bc7d35e02
diff --git a/freevideo_engine/lora_triggers.py b/freevideo_engine/lora_triggers.pyindex c29e4e4..dca1aa5 100644--- a/freevideo_engine/lora_triggers.py+++ b/freevideo_engine/lora_triggers.py@@ -161,8 +161,18 @@ def get_trigger_words(name, *, folders=None):return get_trigger(name, folders=folders)['words']+def _written(prompt, words):+ """Whether the phrase stands on its own in the prompt: sks is not found in asks.++ Only letters and digits at the phrase's own edges are checked, so a phrase in Chinese still matches in running text."""+ ends = ''.join(('(?<![A-Za-z0-9_])' if words[:1].isascii() and (words[:1].isalnum() or words[:1] == '_') else '',+ re.escape(words),+ '(?![A-Za-z0-9_])' if words[-1:].isascii() and (words[-1:].isalnum() or words[-1:] == '_') else ''))+ return re.search(ends, prompt, re.IGNORECASE) is not None++def prepend_words(prompt, words):- if not words or words.casefold() in prompt.casefold():+ if not words or _written(prompt, words):return promptreturn words + ', ' + prompt if prompt else wordsdiff --git a/web/lora_triggers.js b/web/lora_triggers.jsindex 663350f..7a13836 100644--- a/web/lora_triggers.js+++ b/web/lora_triggers.js@@ -1,8 +1,23 @@// Records are saved on the generation node: {name, words, added}. A phrase// already written by the user has added=false, so it is never removed or// reinserted after a manual edit. A missing table entry means lookup is pending.+// Where the phrase stands on its own: a word that only sits inside a longer one+// (sks in asks, TOK in Tokyo) is not the trigger. Only letters and digits of the+// phrase's own edges are checked, so a phrase in Chinese still matches in running text.+function phraseIndex(text, phrase, ignoreCase = false) {+ if (ignoreCase) { text = text.toLowerCase(); phrase = phrase.toLowerCase(); }+ const word = /[A-Za-z0-9_]/;+ const startsWord = word.test(phrase[0] ?? ''), endsWord = word.test(phrase.at(-1) ?? '');+ for (let index = text.indexOf(phrase); phrase && index >= 0; index = text.indexOf(phrase, index + 1)) {+ const end = index + phrase.length;+ if (!(startsWord && index > 0 && word.test(text[index - 1]))+ && !(endsWord && end < text.length && word.test(text[end]))) return index;+ }+ return -1;+}+function removeInsertion(prompt, words) {- const index = prompt.indexOf(words);+ const index = phraseIndex(prompt, words);if (index < 0) return prompt;const before = prompt.slice(0, index), after = prompt.slice(index + words.length);const following = after.match(/^\s*,\s*/);@@ -30,13 +45,13 @@ export function reconcileLoraTriggers(prompt, records, rows, wordsByName) {}// Shared phrases have joint ownership, including when one model replaces// another with the same phrase. Remove them only after the last owner leaves.- const owned = new Set([...previous.values()].filter(row => row.added && prompt.includes(row.words)).map(row => row.words));+ const owned = new Set([...previous.values()].filter(row => row.added && phraseIndex(prompt, row.words) >= 0).map(row => row.words));const next = [], prefix = [];for (const name of names) {if (retained.has(name)) { next.push(retained.get(name)); continue; }const phrase = words(name);if (!phrase) continue;- const present = [...prefix, prompt].join(', ').toLowerCase().includes(phrase.toLowerCase());+ const present = phraseIndex([...prefix, prompt].join(', '), phrase, true) >= 0;const added = !present || owned.has(phrase);if (!present) { prefix.push(phrase); owned.add(phrase); }next.push({name, words: phrase, added});