feat(studio): deploy manual designer and configurable AI model
This commit is contained in:
1 parent
58687d8679
commit
eefc86a057
10 files changed
+133
-32
No files matched your search
+29
-4
@@ -56,7 +56,7 @@ test("APIMart uses the specified model, bearer authentication, non-streaming JSO
|
||||
);
|
||||
expect(init?.signal).toBe(controller.signal);
|
||||
const body = JSON.parse(init?.body as string);
|
||||
expect(body.model).toBe("gpt-6-luna");
|
||||
expect(body.model).toBe("gpt-5-mini");
|
||||
expect(body.stream).toBe(false);
|
||||
expect(body.max_tokens).toBe(AI_OUTPUT_TOKENS);
|
||||
expect(body.messages).toEqual([
|
||||
@@ -87,7 +87,7 @@ test("AI proposals use engine validation, preserve draft source, locks and revis
|
||||
const batch = await response!.json();
|
||||
expect(batch.alternatives).toHaveLength(3);
|
||||
expect(batch.provenance.provider).toBe("APIMart");
|
||||
expect(batch.provenance.model).toBe("gpt-6-luna");
|
||||
expect(batch.provenance.model).toBe("gpt-5-mini");
|
||||
expect(JSON.stringify(system)).toBe(original);
|
||||
const locked = await handler(
|
||||
await request(await input(["/tokens/shape.control"])),
|
||||
@@ -114,7 +114,7 @@ test("metadata and errors never contain the key or raw upstream response", async
|
||||
new Request("https://components.example/design-studio/api/generation"),
|
||||
);
|
||||
const text = await meta!.text();
|
||||
expect(text).toContain("gpt-6-luna");
|
||||
expect(text).toContain("gpt-5-mini");
|
||||
expect(JSON.parse(text).timeoutMs).toBe(AI_TIMEOUT_MS);
|
||||
expect(AI_TIMEOUT_MS).toBe(60_000);
|
||||
expect(text).not.toContain("test-secret");
|
||||
@@ -227,7 +227,7 @@ test("authentication and quota failures provide actionable redacted diagnostics
|
||||
for (const [status, code, hint] of [
|
||||
[401, "invalid_api_key", "server API key"],
|
||||
[402, "insufficient_quota", "credit or quota"],
|
||||
[404, "model_not_found", "gpt-6-luna"],
|
||||
[404, "model_not_found", "configured model"],
|
||||
] as const) {
|
||||
let calls = 0;
|
||||
const handler = studioAI(
|
||||
@@ -407,3 +407,28 @@ test("background generation cancellation aborts the provider and leaves no propo
|
||||
expect((await response!.json()).status).toBe("cancelled");
|
||||
expect(aborted).toBe(true);
|
||||
});
|
||||
|
||||
test("the configured model is used consistently for metadata and upstream requests", async () => {
|
||||
let selected = "";
|
||||
const handler = studioAI(
|
||||
"test-secret",
|
||||
mockFetch(async (_url, init) => {
|
||||
selected = JSON.parse(init!.body as string).model;
|
||||
return completion();
|
||||
}),
|
||||
"custom-model",
|
||||
);
|
||||
const metadata = await (await handler(
|
||||
new Request("https://components.example/design-studio/api/generation"),
|
||||
))!.json();
|
||||
expect(metadata.model).toBe("custom-model");
|
||||
const batch = await (await handler(await request()))!.json();
|
||||
expect(selected).toBe("custom-model");
|
||||
expect(batch.provenance.model).toBe("custom-model");
|
||||
expect(
|
||||
addStudioGuide('<div id="diagnostics"></div>', true, "custom-model"),
|
||||
).toContain("custom-model");
|
||||
expect(
|
||||
addStudioGuide('<div id="diagnostics"></div>', true, "<script>"),
|
||||
).not.toContain("with <script>");
|
||||
});
|
||||
Reference in new issue
Block a user