fix(studio): move AI generation behind short-lived job requests
This commit is contained in:
1 parent
e8c0f06d8f
commit
58687d8679
7 files changed
+248
-8
No files matched your search
@@ -36,6 +36,13 @@ try {
|
||||
]) {
|
||||
const response = await fetch(origin + path);
|
||||
if (!response.ok) throw Error(`${path} returned ${response.status}`);
|
||||
if (
|
||||
path === "/design-studio/studio.js" &&
|
||||
!(await response.clone().text()).includes("respond-async")
|
||||
)
|
||||
throw Error(
|
||||
"The deployed Studio client is missing background generation polling.",
|
||||
);
|
||||
if (path === "/design-studio/") {
|
||||
const html = await response.clone().text();
|
||||
const presetMenu =
|
||||
@@ -97,6 +104,7 @@ try {
|
||||
process.env.APIMART_API_KEY?.trim() &&
|
||||
(generation.provider !== "APIMart" ||
|
||||
generation.model !== "gpt-6-luna" ||
|
||||
generation.delivery !== "polling" ||
|
||||
generation.maxAttempts !== 2 ||
|
||||
generation.maxOutputTokens !== 8192 ||
|
||||
generation.timeoutMs !== 60_000)
|
||||
@@ -104,6 +112,21 @@ try {
|
||||
throw Error(
|
||||
"The compiled app did not pick up its server-side AI configuration.",
|
||||
);
|
||||
if (process.env.APIMART_API_KEY?.trim()) {
|
||||
const missingJob = await fetch(
|
||||
origin +
|
||||
"/design-studio/api/generate/jobs/00000000-0000-4000-8000-000000000000",
|
||||
);
|
||||
if (
|
||||
missingJob.status !== 410 ||
|
||||
!(missingJob.headers.get("content-type") ?? "").includes(
|
||||
"application/json",
|
||||
)
|
||||
)
|
||||
throw Error(
|
||||
"The compiled app did not serve the background generation job endpoint.",
|
||||
);
|
||||
}
|
||||
if (application.enabled !== false)
|
||||
throw Error("Hosted Studio must remain export-only.");
|
||||
const preview = await fetch(origin + "/design-studio/api/preview", {
|
||||
|
||||
Reference in new issue
Block a user