Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Chat plans read "film" as a photo's look, and say what to tap next

Adarsh706977112b31
diff --git a/src/server/assist/agent.ts b/src/server/assist/agent.ts
index 4f9170d9..36d97256 100644
--- a/src/server/assist/agent.ts
+++ b/src/server/assist/agent.ts
@@ -993,6 +993,18 @@ const TAKE_NOUN = /^(?:takes?|versions?|variations?|options?)$/i;
const CONTENT_WORD = /\b(?:with|of|showing|featuring|containing|including|holding|having|and|plus|from|in|on)\b/i;
/** What a still can be called, singular or plural, before "then animate it". */
const STILL = /\b(stills?|photos?|pictures?|images?|portraits?|headshots?|posters?|frames?|shots?|renders?|key ?visuals?)\b/i;
+
+/**
+ * Does a request ask for moving pictures? "film" as a photo's look ("35mm film", "film grain", "film noir") doesn't, and
+ * an ad that names a still ("a poster ad", "portraits for an ad") stays a still.
+ */
+function asksForMotion(t: string): boolean {
+ const words = t
+ .replace(/\b(\d+\s?mm|analog(?:ue)?|on|kodak|fuji|portra|polaroid|instant|medium[- ]format|large[- ]format|black[- ]and[- ]white)\s+film\b/g, " ")
+ .replace(/\bfilm[- ](grain|look|stock|photo\w*|camera|still|emulsion|aesthetic|noir|style|tones?|colou?rs?)\b/g, " ");
+ if (/\b(videos?|clips?|animate|animation|motion|films?|footage|movies?|trailers?)\b/.test(words)) return true;
+ return /\b(commercials?|ads?)\b/.test(words) && !STILL.test(words);
+}
/** "… then pick the best and animate it": the person chooses which take moves. */
const PICK_WORDS = /\b(best|favou?rite|pick|choose|select|strongest|one of them)\b/;
@@ -1235,7 +1247,7 @@ export function offlinePlan(message: string, preferred: Engine, hint?: SkillMeta
}
const isSpeech = !isMusic && (/\b(voice ?over|narrat\w*|read (this|it|out)|say|speak|text to speech|tts)\b/.test(t) || hint?.kind === "audio");
const isVideo =
- !isMusic && !isSpeech && (files.some((f) => f.kind === "video") || !!shots || /\b(videos?|clips?|animate|animation|motion|films?|footage|movies?|trailers?|commercials?|ads?)\b/.test(t) || hint?.kind === "video");
+ !isMusic && !isSpeech && (files.some((f) => f.kind === "video") || !!shots || asksForMotion(t) || hint?.kind === "video");
if (isMusic || isSpeech) {
const quoted = /["“]([^"”]+)["”]/.exec(text)?.[1] ?? text.replace(/^.*?:\s*/, "");
return {
diff --git a/src/server/chat/make.ts b/src/server/chat/make.ts
index ad348cfe..3ad2259a 100644
--- a/src/server/chat/make.ts
+++ b/src/server/chat/make.ts
@@ -104,8 +104,11 @@ export async function planMake(from: Request, who: string, text: string, image:
});
requests.push(req);
}
- const say = then ? `${read.say.replace(/\s*[—-]\s*the video starts by itself.*$/i, ".")} Once it's ready, tap Animate on the one you like.` : read.say;
- return { say, plan: { summary: input.summary ?? text.slice(0, 80), jobs: out, requests, status: "ready", ids: [], errors: [], ...(then && { then }) } };
+ // The planner's words, without its machinery ("with the default image model"), and what to do next.
+ const base = read.say.replace(/\s+with the default (?:image|video|music|audio) model/i, "").replace(/\s*[—-]\s*the video starts by itself.*$/i, ".");
+ const say = then ? `${base} Once it's ready, tap Animate on the one you like.` : `${base} Tap Make it to start.`;
+ const summary = (input.summary ?? text.slice(0, 80)).replace(/^(?:image|video|edit|write):\s*/i, "");
+ return { say, plan: { summary: summary.charAt(0).toUpperCase() + summary.slice(1), jobs: out, requests, status: "ready", ids: [], errors: [], ...(then && { then }) } };
}
/** Run a plan's steps through the studios' route, as the person; each refusal is kept in its own words. */
diff --git a/tests/chat.test.ts b/tests/chat.test.ts
index 41ad06a5..52e48ec7 100644
--- a/tests/chat.test.ts
+++ b/tests/chat.test.ts
@@ -25,6 +25,7 @@ const prompt = await import("@/lib/chat/prompt");
const catalog = await import("@/lib/chat/catalog");
const { chatShareRoute } = await import("@/lib/chat/share");
const { wantsToMake } = await import("@/lib/chat/make-intent");
+const catalogModels = await import("@/lib/catalog");
const auth = await import("@/server/auth");
const { db } = await import("@/server/db");
const { resetRates } = await import("@/server/rate");
@@ -369,6 +370,20 @@ describe("making things in a chat", () => {
expect(wantsToMake("Animate this", false)).toBe(false);
});
+ it("reads film as a photo's look, not a video, and an ad that names a still as a still", async () => {
+ const { offlinePlan } = await import("@/server/assist/agent");
+ const kindOf = (s: string) => {
+ const p = offlinePlan(s, "open");
+ const job = (p?.input as { jobs?: { model_id: string }[] } | undefined)?.jobs?.[0];
+ return job ? (catalogModels.getModel(job.model_id)?.kind ?? null) : null;
+ };
+ expect(kindOf("Four moody portraits of a model in a black velvet suit, 35mm film")).toBe("image");
+ expect(kindOf("A portrait with film grain and a film noir look")).toBe("image");
+ expect(kindOf("A poster ad for a perfume")).toBe("image");
+ expect(kindOf("A short film of a tailor in Naples")).toBe("video");
+ expect(kindOf("An ad for a gold watch")).toBe("video");
+ });
+
it("answers a request to make with a plan priced by the studio's own check, and a plan can be put aside", async () => {
const t = (await (await threadsRoute.POST(req(cookies.a, "/api/chat/threads", "POST", { kind: "chat" }))).json()) as { id: string };
const ev = await events(await replyRoute.POST(req(cookies.a, `/api/chat/threads/${t.id}/reply`, "POST", { text: "Make four portraits of a model in a black velvet suit" }), ctx({ id: t.id })));