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.

Leave the rewrite's subject definitions out of the prompt box

Bowen Xueee61e54954ee
diff --git a/web/cast_mention.js b/web/cast_mention.js
index cfe34e0..e6364f8 100644
--- a/web/cast_mention.js
+++ b/web/cast_mention.js
@@ -94,8 +94,7 @@ export function mentionRanges(text, people) {
// pictures are gone is written as a plain name. `active: false` (first/last frames) leaves every name plain too, since
// pictures of people cannot go with those. `continued` (the part continues a video) lets the characters stay: the part
// keeps three reference pictures (see pictureNumbers) and its frames come after them, so a character whose pictures are
-// not among those three is written as a plain name. A rewritten prompt already opens with its own subject definitions
-// (the rewrite writes them in H3's ref2va form); only its names become <Subject N> then.
+// not among those three is written as a plain name.
export function expandCast(text, rows, {active = true, continued = false} = {}) {
text = String(text ?? '');
const list = Array.isArray(rows) ? rows : [];
@@ -128,18 +127,20 @@ export function expandCast(text, rows, {active = true, continued = false} = {})
}
return {name: person.name, handle: person.handle ?? person.name, description: person.description, pictures: ranges, audio: null};
});
- if (/^\s*subject_definitions:/.test(text)) return {text: result, subjects};
return {text: subjectDefinitions(subjects) + '\n\n' + result, subjects};
}
// The rewrite of an expanded prompt, written back with the names the box had: <Subject N> becomes "@handle" of the
-// subject expandCast gave that number. A rewrite with a number that stands for no one is kept as it came.
+// subject expandCast gave that number, and the subject definitions the rewrite opens with are left out, since
+// expandCast writes them again from the cards (their picture numbers follow the media list as it is then). A rewrite
+// with a number that stands for no one is kept as it came.
export function restoreCast(text, subjects) {
text = String(text ?? '');
const handles = (Array.isArray(subjects) ? subjects : []).map(subject => subject.handle ?? subject.name);
const numbers = [...text.matchAll(/<Subject (\d+)>/g)].map(match => Number(match[1]));
if (!numbers.length || numbers.some(number => !handles[number - 1])) return text;
- return text.replace(/<Subject (\d+)>/g, (_, number) => '@' + handles[number - 1]);
+ const body = text.replace(/^\s*subject_definitions:(?:[\s\S]*?\n\s*\n(?=[a-z_]+:)|[\s\S]*?\n\s*\n|[\s\S]*$)/, '').trim();
+ return (body || text).replace(/<Subject (\d+)>/g, (_, number) => '@' + handles[number - 1]);
}
// The pictures of a card to put in the media list, as the Agent carries them (agent/drama.py person_pictures): the sheet of