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.

Free text helper: guests are asked to sign up instead of getting busy

Adarsh1a0a1a0d27b5
diff --git a/src/app/api/enhance/route.ts b/src/app/api/enhance/route.ts
index bc333a17..c4811375 100644
--- a/src/app/api/enhance/route.ts
+++ b/src/app/api/enhance/route.ts
@@ -2,7 +2,7 @@ import { enhancePrompt, writeLyrics } from "@/server/enhance";
import { getModel } from "@/lib/catalog";
import { appliesOwnStyle } from "@/lib/catalog/applied-style";
import type { MediaKind, Operation } from "@/lib/catalog/types";
-import { ownGpuToolMessage } from "@/lib/guest-access";
+import { GUEST_HEADER, GUEST_RUN_MESSAGE, ownGpuToolMessage, SIGN_IN_CODE } from "@/lib/guest-access";
import { LoginGuard, requestViewer } from "@/server/auth";
import { hostedRunsOn } from "@/server/hosted-switch";
import { runAsTenant, type Tenant } from "@/server/tenant";
@@ -10,9 +10,13 @@ import type { HelperAnswer } from "@/server/text-helper";
type HelperTrouble = Exclude<HelperAnswer, { text: string }>;
+/** A guest's call for the free helper: the page opens "Create a free account" (the 401 marked as a guest's). */
+const signIn = () => Response.json({ error: GUEST_RUN_MESSAGE, code: SIGN_IN_CODE }, { status: 401, headers: { [GUEST_HEADER]: "1", "Cache-Control": "no-store" } });
+
/** Why no lyrics came, in words, with a code the page reads ("no-llm" offers Settings → AI helper to the owner). */
function noLyrics(owner: boolean, why: HelperTrouble | null): Response {
const headers = { "Cache-Control": "no-store" };
+ if (why?.error === "sign-in") return signIn();
if (why?.error === "limit") {
return Response.json({ error: "You've written a lot of lyrics just now. Try again in a minute, or type your own.", code: "helper-limit" }, { status: 429, headers: { ...headers, "Retry-After": String(why.retryAfterS ?? 60) } });
}
@@ -39,6 +43,8 @@ export async function POST(request: Request) {
// A visitor (only while hosted runs are on: the proxy lets nothing else through) gets the free helper, as itself.
const viewer = requestViewer(request);
const owner = viewer.kind === "owner";
+ // A guest's lyrics need the free helper: sign up first. A guest's rewrite stays the offline one (freeHelperOn).
+ if (viewer.kind === "guest" && target === "lyrics") return signIn();
if (!owner && !hostedRunsOn()) return Response.json({ error: ownGpuToolMessage(false), code: "own-gpu-tool" }, { status: 403 });
const as: Tenant | null = viewer.kind === "account" ? { kind: "account", id: viewer.account.id } : viewer.kind === "guest" ? { kind: "guest" } : null;
const guestKey = viewer.kind === "guest" ? LoginGuard.clientKey(request.headers) : undefined;
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index dc720506..77950900 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -48,7 +48,7 @@ import { ExactOrbitControls } from "@/components/exact-orbit-controls";
import { useFlyAround } from "@/components/fly-around-run";
import { exactDefaults, takesExact, type ExactOrbit } from "@/lib/exact-orbit";
import { placeOf } from "@/lib/place-name";
-import { askToSignUp, CONNECT_GPU_EVENT, engineForNextPage, enhance, useClipFacts, useCreateGeneration, useElements, useEngine, useHydrated, useIsOwner, useLikelyVisitor, useNewestRun, useStatus, useViewer } from "@/lib/api";
+import { askToSignUp, CONNECT_GPU_EVENT, engineForNextPage, enhance, helperSignIn, useClipFacts, useCreateGeneration, useElements, useEngine, useHydrated, useIsOwner, useLikelyVisitor, useNewestRun, useStatus, useViewer } from "@/lib/api";
import { keyTurnedDown, keyTurnedDownWords, siteRunOf, siteRunRequest } from "@/lib/site-run";
import { usePagePlace } from "@/components/gpu/use-page-place";
import { applyMentions, elementsNote, type StudioElement } from "@/lib/catalog/elements";
@@ -1169,7 +1169,7 @@ export function Composer({ docked }: { docked: boolean }) {
const p = await enhance(draft.prompt, config.kind, op ?? (config.kind === "video" ? "t2v" : "t2i"), draft.modelId);
setDraft({ prompt: p });
} catch (e) {
- toastError(e);
+ if (!helperSignIn(e)) toastError(e);
} finally {
setEnhancing(false);
}
diff --git a/src/components/studio/lyrics-editor.tsx b/src/components/studio/lyrics-editor.tsx
index c641ef47..e48c7efc 100644
--- a/src/components/studio/lyrics-editor.tsx
+++ b/src/components/studio/lyrics-editor.tsx
@@ -4,7 +4,7 @@ import { Loader2, Music2, PenLine, Sparkles, X } from "lucide-react";
import { useRouter } from "next/navigation";
import { useId, useRef, useState } from "react";
import { toast } from "sonner";
-import { useTextHelper, writeLyrics } from "@/lib/api";
+import { helperSignIn, useTextHelper, writeLyrics } from "@/lib/api";
import type { ModelDef } from "@/lib/catalog/types";
import { INSTRUMENTAL, insertTag, isInstrumental, normalizeLyrics, promptWithLyrics, SECTION_TAGS, songLength, structureOf } from "@/lib/lyrics";
import { toastError } from "@/lib/refusals";
@@ -64,7 +64,8 @@ export function LyricsEditor({
try {
onChange(await writeLyrics(idea, { seconds, max: spec.max }));
} catch (e) {
- // Nothing set up to write them: one click to Settings → AI helper.
+ // A guest: "Create a free account". Nothing set up to write them: one click to Settings → AI helper.
+ if (helperSignIn(e)) return;
if ((e as { code?: string }).code === "no-llm") toast.error((e as Error).message, { action: { label: "Set up", onClick: () => router.push("/settings#text-ai") } });
else toastError(e);
} finally {
diff --git a/src/lib/api.ts b/src/lib/api.ts
index 7a6d1db4..b64056eb 100644
--- a/src/lib/api.ts
+++ b/src/lib/api.ts
@@ -28,7 +28,7 @@ import {
import { fetchWithin, READ_LIMIT_MS } from "./fetch-within";
import { cursorAfter, filterToSearch, type AssetUse, type FeedFilter, type Folder } from "./library";
import { markRefusalShown, refusalShown, responseError } from "./refusals";
-import { OWN_SETUP_HEADER, PLACE_ASK_HEADER, RUN_PLACE_HEADER, RUN_SHOWN_HEADER, RUNS_CHANGED_EVENT, shownHeader } from "./guest-access";
+import { OWN_SETUP_HEADER, PLACE_ASK_HEADER, RUN_PLACE_HEADER, RUN_SHOWN_HEADER, RUNS_CHANGED_EVENT, shownHeader, SIGN_IN_CODE } from "./guest-access";
import type { PoolRules } from "./pool-rules";
import { HoldFilesCtx } from "./held-files";
import { postFile } from "./upload";
@@ -1623,6 +1623,16 @@ export function askToSignUp(action: RefusalAction = "upload", more: Pick<Refusal
window.dispatchEvent(new CustomEvent<RefusalDetail>(GUEST_PROMPT_EVENT, { detail: { action, ...more } }));
}
+/**
+ * A guest's free-helper call refused with SIGN_IN_CODE ("Write the lyrics"): "Create a free account" opens (unless the
+ * fetch watcher opened it already), never an error. True when the error was that refusal.
+ */
+export function helperSignIn(e: unknown): boolean {
+ if ((e as { code?: unknown } | null)?.code !== SIGN_IN_CODE) return false;
+ if (!refusalShown(e)) askToSignUp("run");
+ return true;
+}
+
/**
* For a file chooser, a drop or a paste: asks first whoever the upload would refuse, instead of letting them pick a file
* for nothing. A guest gets "Create a free account", an account with neither its own GPU nor its own key "Connect your
diff --git a/src/lib/guest-access.ts b/src/lib/guest-access.ts
index 0b4d3166..54b8a1ab 100644
--- a/src/lib/guest-access.ts
+++ b/src/lib/guest-access.ts
@@ -21,6 +21,8 @@ export const isGuest = (request: Request) => request.headers.get(GUEST_HEADER) =
export const GUEST_LIBRARY_MESSAGE = "Sign up to see this.";
export const GUEST_RUN_MESSAGE = "Create a free account to run this.";
+/** The code on a guest's refused free-helper call (401 with GUEST_HEADER): the client opens "Create a free account". */
+export const SIGN_IN_CODE = "sign-in";
/** Catalog and status reads that hold nothing of the owner's library: a guest gets the real answer. */
const GUEST_READS = new Set(["/api/status", "/api/site/uploads", "/api/examples", "/api/models", "/api/search-index", "/api/comfyui", "/api/settings/models", "/api/gpu/requirements", "/api/live/nodes"]);
@@ -419,7 +421,7 @@ export function ownGpuRun(method: string, pathname: string): boolean {
*/
const POOL_TOOL_RUNS: readonly RegExp[] = [/^\/api\/palettes\/lock$/];
-/** The free text helper's routes (src/server/text-helper.ts): a visitor may call them while hosted runs are on, within the route's own limits. */
+/** The free text helper's routes (src/server/text-helper.ts): a visitor may call them while hosted runs are on (a guest's helper call gets SIGN_IN_CODE). */
const HELPER_ROUTES: readonly RegExp[] = [/^\/api\/enhance$/];
export const helperRoute = (method: string, pathname: string): boolean => method === "POST" && HELPER_ROUTES.some((r) => r.test(pathname));
diff --git a/src/proxy.ts b/src/proxy.ts
index 775e597f..6f8ec887 100644
--- a/src/proxy.ts
+++ b/src/proxy.ts
@@ -217,7 +217,7 @@ function guest(request: NextRequest): NextResponse {
if (isPriceCheck(method, pathname, search, hostedRunsOn())) return priceCheck(request, `guest:${LoginGuard.clientKey(request.headers)}`);
if (isAssistChange(method, pathname)) return assistOwner();
if (anyoneMayReport(method, pathname)) return pass(request);
- // The free text helper (lyrics, a prompt rewrite): while hosted runs are on, its route counts a guest's own limits.
+ // The free text helper's route, while hosted runs are on: a guest gets the offline rewrite, and sign-up for lyrics.
if (helperRoute(method, pathname) && hostedRunsOn()) return pass(request);
// What an account may send, the library, the owner's settings and the studios' runs: signing up is the next step.
// A tool run made only on this install's GPUs counts as one of them with hosted runs on, and as a tool that isn't
diff --git a/src/server/providers/llm.ts b/src/server/providers/llm.ts
index cc2c8590..3f70246d 100644
--- a/src/server/providers/llm.ts
+++ b/src/server/providers/llm.ts
@@ -4,6 +4,7 @@ import { nanoid } from "nanoid";
import { getModel } from "@/lib/catalog";
import { cueText, parseCues, toSrt, type Cue } from "@/lib/cues";
import type { GenInput, ModelRoute, Operation } from "@/lib/catalog/types";
+import { GUEST_RUN_MESSAGE } from "@/lib/guest-access";
import { HOSTED_PROVIDERS, testHosted } from "../llm/hosted";
import { aiHelper, chatLocal, checkLocal, emptyReply, LOCAL_LABELS, localLabel, localProblem, localReady, localServers, localWhat, pinnedKind, probeLocal, type JsonSpec, type LocalKind, type Ready } from "../llm";
import { placeName } from "../place-name";
@@ -206,6 +207,7 @@ async function viaComfy(system: string, user: string, signal: AbortSignal): Prom
/** Words for a free helper's answer that came without text. */
function helperTrouble(a: Exclude<HelperAnswer, { text: string }>): string {
if (a.error === "blocked") return a.message || "This text can't be written here.";
+ if (a.error === "sign-in") return GUEST_RUN_MESSAGE;
if (a.error === "busy") return "The writer is busy right now. Press Retry in a moment.";
return "The writer couldn't finish this text. Press Retry.";
}
diff --git a/src/server/text-helper.ts b/src/server/text-helper.ts
index 5ee04bbd..44cdf5a3 100644
--- a/src/server/text-helper.ts
+++ b/src/server/text-helper.ts
@@ -130,8 +130,11 @@ export function helperLive(now = Date.now(), o: { vision?: boolean } = {}): bool
return rows.some((w) => textEligible(w, now));
}
-/** May this call use the free helper now: it is live, and a visitor's call only while hosted runs are on. */
-export const freeHelperOn = (now = Date.now(), o: { vision?: boolean } = {}): boolean => (!tenant() || hostedRunsOn()) && helperLive(now, o);
+/** May this call use the free helper now: it is live, and an account's call only while hosted runs are on (a guest's never: sign up first). */
+export function freeHelperOn(now = Date.now(), o: { vision?: boolean } = {}): boolean {
+ const t = tenant();
+ return (!t || (t.kind === "account" && hostedRunsOn())) && helperLive(now, o);
+}
/**
* Pictures as the helper takes them: at most four, each from a file the caller already read for the person, made again
@@ -219,7 +222,8 @@ export function finishHelperJob(w: WorkerRow, id: string, body: { lease?: unknow
return r.changes === 1;
}
-export type HelperAnswer = { text: string } | { error: "busy" | "limit" | "blocked" | "failed"; message?: string; retryAfterS?: number };
+/** "sign-in": a guest's call, refused before anything is checked or queued. */
+export type HelperAnswer = { text: string } | { error: "busy" | "limit" | "blocked" | "failed" | "sign-in"; message?: string; retryAfterS?: number };
const rateOf = (who: HelperWho) => (who.startsWith("acct:") ? HELPER_LIMITS.account : who === "guest:shared" ? { perMinute: HELPER_LIMITS.guest.perMinute * 10, perHour: HELPER_LIMITS.guest.perHour * 10 } : HELPER_LIMITS.guest);
@@ -245,6 +249,8 @@ export async function askHelper(o: AskHelper): Promise<HelperAnswer> {
const now = o.now ?? Date.now;
const sleep = o.sleep ?? ((ms: number) => new Promise((r) => setTimeout(r, ms)));
const who = o.who ?? helperWho();
+ // A guest signs up first: no moderation call, no job.
+ if (who.startsWith("guest:")) return { error: "sign-in" };
const d = db();
sweepHelper(now());
const vision = !!o.images?.length;
diff --git a/tests/guest-prompt.test.ts b/tests/guest-prompt.test.ts
index 226d574f..90ddf961 100644
--- a/tests/guest-prompt.test.ts
+++ b/tests/guest-prompt.test.ts
@@ -32,8 +32,8 @@ import { send as shortsSend } from "@/components/shorts/hooks";
import { fileToSlot, type SlotValue } from "@/components/studio/media-slot";
import { useCreateSwapProject } from "@/components/swap-studio/hooks";
import { runGpuCheck } from "@/hooks/use-gpu";
-import { askToSignUp, assetUsage, CONNECT_GPU_EVENT, enhance, GUEST_PROMPT_EVENT, refusalCard, signInHref, watchGuestRefusals } from "@/lib/api";
-import { CONNECT_GPU_HEADER, CONNECT_GPU_MESSAGE, CONNECT_GPU_UPLOAD_MESSAGE, CONNECT_NEEDS_HEADER, GUEST_HEADER, GUEST_LIBRARY_MESSAGE, GUEST_RUN_MESSAGE } from "@/lib/guest-access";
+import { askToSignUp, assetUsage, CONNECT_GPU_EVENT, enhance, GUEST_PROMPT_EVENT, helperSignIn, refusalCard, signInHref, watchGuestRefusals, writeLyrics } from "@/lib/api";
+import { CONNECT_GPU_HEADER, CONNECT_GPU_MESSAGE, CONNECT_GPU_UPLOAD_MESSAGE, CONNECT_NEEDS_HEADER, GUEST_HEADER, GUEST_LIBRARY_MESSAGE, GUEST_RUN_MESSAGE, SIGN_IN_CODE } from "@/lib/guest-access";
import { refusalShown, toastError } from "@/lib/refusals";
const answer = (status: number, body: Record<string, unknown>, headers: Record<string, string> = {}) =>
@@ -174,6 +174,40 @@ describe("a guest's refused run", () => {
});
});
+describe("a guest's free-helper call (Write the lyrics)", () => {
+ const signIn = () => answer(401, { error: GUEST_RUN_MESSAGE, code: SIGN_IN_CODE }, { [GUEST_HEADER]: "1" });
+
+ it("opens Create a free account once, about a run, with no error toast", async () => {
+ page("/audio");
+ server = () => signIn();
+ const e = await writeLyrics("a song about rain").catch((err: unknown) => err);
+ expect((e as { code?: string }).code).toBe(SIGN_IN_CODE);
+ expect(helperSignIn(e)).toBe(true);
+ expect(events).toEqual([GUEST_PROMPT_EVENT]);
+ expect(details).toEqual([{ action: "run" }]);
+ expect(toasts.error).toEqual([]);
+ });
+
+ it("opens the card itself when the watcher didn't (the sign-in code without the guest mark)", async () => {
+ page("/audio");
+ server = () => answer(401, { error: GUEST_RUN_MESSAGE, code: SIGN_IN_CODE });
+ const e = await writeLyrics("a song about rain").catch((err: unknown) => err);
+ expect(events).toEqual([]);
+ expect(helperSignIn(e)).toBe(true);
+ expect(events).toEqual([GUEST_PROMPT_EVENT]);
+ expect(details).toEqual([{ action: "run" }]);
+ });
+
+ it("leaves every other failure to its own words", async () => {
+ page("/audio");
+ server = () => answer(503, { error: "Writing lyrics is busy right now.", code: "helper-busy" });
+ const e = await writeLyrics("a song about rain").catch((err: unknown) => err);
+ expect(helperSignIn(e)).toBe(false);
+ expect(helperSignIn(null)).toBe(false);
+ expect(events).toEqual([]);
+ });
+});
+
describe("each studio's own fetch helper", () => {
// The first thing a guest tries in each studio: the error its helper throws says the card shows it already.
const runs: [string, () => Promise<unknown>][] = [
diff --git a/tests/text-helper.test.ts b/tests/text-helper.test.ts
index 9dfeef3a..74dd920b 100644
--- a/tests/text-helper.test.ts
+++ b/tests/text-helper.test.ts
@@ -8,6 +8,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite
import { NextRequest } from "next/server";
import sharp from "sharp";
import { tempDir } from "./helpers/temp-dir";
+import { startFakeModeration } from "./helpers/fake-billing";
vi.setConfig({ testTimeout: 30_000 });
vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));
@@ -167,11 +168,32 @@ describe("the text slots' line", () => {
expect(helper.textEligible(workerRow(w))).toBe(false);
});
- it("a visitor's calls have limits: a minute's and its waiting jobs; a run's own steps aren't counted", async () => {
+ it("a guest's call is refused for sign-in before any moderation call or job", async () => {
+ const mod = await startFakeModeration();
+ process.env.FUOBE_MODERATION_URL = mod.url;
+ try {
+ const w = addWorker();
+ helper.claimHelperJob(workerRow(w));
+ for (const who of ["guest:203.0.113.9", "guest:shared"]) {
+ expect(await helper.askHelper({ task: "lyrics", system: "s", user: "u", who, waitMs: 30 })).toEqual({ error: "sign-in" });
+ }
+ expect(runAsTenant({ kind: "guest" }, () => helper.freeHelperOn())).toBe(false);
+ expect(jobs()).toEqual([]);
+ expect(mod.calls).toEqual([]);
+ // An account's call does reach moderation.
+ await helper.askHelper({ task: "lyrics", system: "s", user: "u", who: `acct:${account}`, waitMs: 30 });
+ expect(mod.calls_of("/v1/check-run")).toHaveLength(1);
+ } finally {
+ delete process.env.FUOBE_MODERATION_URL;
+ await mod.close();
+ }
+ });
+
+ it("an account's calls have limits: a minute's and its waiting jobs; a run's own steps aren't counted", async () => {
const w = addWorker();
helper.claimHelperJob(workerRow(w));
- const who = "guest:203.0.113.9";
- for (let i = 0; i < helper.HELPER_LIMITS.guest.perMinute; i++) expect(await helper.askHelper({ task: "enhance", system: "s", user: "u", who, waitMs: 30 })).toEqual({ error: "busy" });
+ const who = `acct:${account}`;
+ for (let i = 0; i < helper.HELPER_LIMITS.account.perMinute; i++) expect(await helper.askHelper({ task: "enhance", system: "s", user: "u", who, waitMs: 30 })).toEqual({ error: "busy" });
expect(await helper.askHelper({ task: "enhance", system: "s", user: "u", who, waitMs: 30 })).toMatchObject({ error: "limit" });
expect(await helper.askHelper({ task: "write", system: "s", user: "u", who, waitMs: 30, counted: false })).toEqual({ error: "busy" });
// Two of its own jobs waiting at once, at most.
@@ -284,21 +306,38 @@ describe("the AI helper's order and the lyrics route", () => {
await slot.stop();
});
- it("lyrics: a guest and an account get them from the free helper while hosted runs are on", async () => {
+ it("lyrics: an account gets them from the free helper while hosted runs are on; a guest is asked to sign up", async () => {
process.env.FUOBE_HOSTED_RUNS = "1";
+ const mod = await startFakeModeration();
+ process.env.FUOBE_MODERATION_URL = mod.url;
const w = addWorker();
const slot = standIn(w, (job) => (job.task === "lyrics" ? "[verse] Neon rain\n[chorus] Hold on" : "?"));
- expect(passed(await viaProxy("/api/enhance"))).toBe(true);
- expect(passed(await viaProxy("/api/enhance", "account"))).toBe(true);
- for (const who of [undefined, "account"]) {
- const r = await enhanceRoute.POST(post("/api/enhance", { prompt: "A synthwave song about rain", target: "lyrics", seconds: 30 }, who));
+ try {
+ expect(passed(await viaProxy("/api/enhance"))).toBe(true);
+ expect(passed(await viaProxy("/api/enhance", "account"))).toBe(true);
+ // A guest: 401 with the guest mark and the sign-in code (the page opens "Create a free account"), nothing checked or queued.
+ const guest = await enhanceRoute.POST(post("/api/enhance", { prompt: "A synthwave song about rain", target: "lyrics", seconds: 30 }));
+ expect(guest.status).toBe(401);
+ expect(guest.headers.get("x-fuobe-guest")).toBe("1");
+ expect(await guest.json()).toEqual({ error: "Create a free account to run this.", code: "sign-in" });
+ expect(mod.calls).toEqual([]);
+ // A guest's rewrite is the offline one: the helper isn't asked.
+ const rewrite = await enhanceRoute.POST(post("/api/enhance", { prompt: "a cat", kind: "image", op: "t2i" }));
+ expect(rewrite.status).toBe(200);
+ expect(((await rewrite.json()) as { prompt: string }).prompt).toMatch(/^a cat\. /);
+ expect(mod.calls).toEqual([]);
+ expect(slot.seen).toEqual([]);
+ const r = await enhanceRoute.POST(post("/api/enhance", { prompt: "A synthwave song about rain", target: "lyrics", seconds: 30 }, "account"));
expect(r.status).toBe(200);
expect(((await r.json()) as { lyrics: string }).lyrics).toBe("[Verse]\nNeon rain\n\n[Chorus]\nHold on");
+ const accountRewrite = await enhanceRoute.POST(post("/api/enhance", { prompt: "a cat", kind: "image", op: "t2i" }, "account"));
+ expect(((await accountRewrite.json()) as { prompt: string }).prompt).toBe("?");
+ expect(slot.seen).toEqual(["lyrics", "enhance"]);
+ } finally {
+ await slot.stop();
+ delete process.env.FUOBE_MODERATION_URL;
+ await mod.close();
}
- const rewrite = await enhanceRoute.POST(post("/api/enhance", { prompt: "a cat", kind: "image", op: "t2i" }));
- expect(((await rewrite.json()) as { prompt: string }).prompt).toBe("?");
- expect(slot.seen).toEqual(["lyrics", "lyrics", "enhance"]);
- await slot.stop();
});
it("lyrics for a Gujarati or Hindi description are asked for in its language and script", async () => {
@@ -310,7 +349,7 @@ describe("the AI helper's order and the lyrics route", () => {
return "[Verse]\nગરબા રમીએ";
});
for (const prompt of ["નવરાત્રિ ગરબા પર એક ઉત્સાહી ગીત", "मानसून की पहली बारिश पर एक गीत", "A synth-pop song about rain"]) {
- expect((await enhanceRoute.POST(post("/api/enhance", { prompt, target: "lyrics", seconds: 30 }))).status).toBe(200);
+ expect((await enhanceRoute.POST(post("/api/enhance", { prompt, target: "lyrics", seconds: 30 }, "account"))).status).toBe(200);
}
await slot.stop();
expect(asked[0].system).toContain("Write in the language and script of the description");
@@ -319,9 +358,9 @@ describe("the AI helper's order and the lyrics route", () => {
expect(asked[2].user).not.toContain("Write the lyrics in");
});
- it("never a dead end: busy words for a visitor, the way to set one up for the owner, and the proxy without hosted runs", async () => {
+ it("never a dead end: busy words for an account, the way to set one up for the owner, and the proxy without hosted runs", async () => {
process.env.FUOBE_HOSTED_RUNS = "1";
- const busy = await enhanceRoute.POST(post("/api/enhance", { prompt: "a song", target: "lyrics" }));
+ const busy = await enhanceRoute.POST(post("/api/enhance", { prompt: "a song", target: "lyrics" }, "account"));
expect(busy.status).toBe(503);
expect(await busy.json()).toEqual({ error: "Writing lyrics is busy right now. Try again in a moment, or type your own.", code: "helper-busy" });
// A rewrite always comes back: the offline one when the helper is busy.