Merge pull request '提示 VIP 高清透明方图的规格风险' (#118) from codex/vip-transparent-generation-notice into main
This commit is contained in:
commit
e264fd3e30
@ -9912,6 +9912,12 @@ export async function POST(request: Request) {
|
||||
imageGenConfig: alibabaModelConfig?.imageGenConfig || null,
|
||||
modelDisplayName, // 🆕 传递模型显示名称
|
||||
overrideModelId: isRetry ? modelIdToUse : undefined,
|
||||
onImageGenerationNotice: (notice: string) =>
|
||||
safeWriteStreamChunk(writer, {
|
||||
type: "data-imageGenerationNotice",
|
||||
data: notice,
|
||||
transient: true,
|
||||
}, "alibaba:image-notice"),
|
||||
});
|
||||
|
||||
if (result?.finishReason === "error") {
|
||||
|
||||
@ -267,7 +267,11 @@ export async function POST(request: Request) {
|
||||
let archiveVideoResults: (() => Promise<void>) | undefined;
|
||||
const stream = createUIMessageStream({
|
||||
execute: async ({ writer }) => {
|
||||
const emit = (type: string, data: unknown) => writer.write({ type, data, ...(type === "data-canvasAgentRun" ? { transient: true } : {}) } as never);
|
||||
const emit = (type: string, data: unknown) => writer.write({
|
||||
type,
|
||||
data,
|
||||
...(type === "data-canvasAgentRun" || type === "data-imageGenerationNotice" ? { transient: true } : {}),
|
||||
} as never);
|
||||
let cancelled = false;
|
||||
let leaseLost = false;
|
||||
const activeModelController = new AbortController();
|
||||
|
||||
@ -4198,6 +4198,12 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
id: chatId,
|
||||
messages: historyMessages,
|
||||
onData(part) {
|
||||
if (part.type === "data-imageGenerationNotice") {
|
||||
if (typeof part.data === "string") {
|
||||
toast.warning(part.data, { id: "image-generation-spec-notice" });
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (part.type !== "data-appendMessage") return;
|
||||
try {
|
||||
const appended = parseAppendedGenerationMessage(part.data);
|
||||
|
||||
@ -8148,6 +8148,13 @@ export function CanvasChatPanel({
|
||||
const eventChatId = inFlightChatIdRef.current || activeChatId;
|
||||
const isEventForActiveChat = eventChatId === activeChatIdRef.current;
|
||||
|
||||
if (dataPart.type === "data-imageGenerationNotice") {
|
||||
if (isEventForActiveChat && typeof dataPart.data === "string") {
|
||||
toast.warning(dataPart.data, { id: "image-generation-spec-notice" });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataPart.type === "data-canvasProjectMetadata") {
|
||||
const payload = dataPart.data as { projectId?: string; title?: string };
|
||||
const state = useCanvasStore.getState();
|
||||
|
||||
@ -278,6 +278,7 @@ export async function buildCanvasRuntimeTools(params: {
|
||||
negativePrompt: input.negativePrompt,
|
||||
promptExtend: input.promptExtend,
|
||||
providerImageParams: agentProviderImageParameters(input),
|
||||
onImageGenerationNotice: (notice) => params.emit("data-imageGenerationNotice", notice),
|
||||
allowFailover: !pinnedModel,
|
||||
agentImageMode: pinnedModel ? "pinned" : "auto",
|
||||
agentImageMaxCreditCost: points.enabled && points.blockOnInsufficient !== false && !user?.isHighVip
|
||||
|
||||
@ -53,7 +53,10 @@ import {
|
||||
} from "@/lib/ai/vip98k-reference-staging";
|
||||
import { createLogger } from "@/lib/observability/logger";
|
||||
import { getUserFacingImageGenerationErrorMessage } from "@/lib/request-error";
|
||||
import { AgentImageGenerationError } from "@/lib/ai/runtime/image-generation-error";
|
||||
import {
|
||||
AgentImageGenerationError,
|
||||
ImageGenerationCompatibilityError,
|
||||
} from "@/lib/ai/runtime/image-generation-error";
|
||||
import { createDeferredUploadedImage } from "@/lib/storage/image-archive";
|
||||
import {
|
||||
IMAGE_UPLOAD_MAX_BYTES,
|
||||
@ -85,6 +88,7 @@ interface Vip98kTaskParams {
|
||||
videoParams?: Record<string, unknown>;
|
||||
imageParams?: Record<string, unknown>;
|
||||
modelConfig: Vip98kModelRuntimeConfig;
|
||||
onImageGenerationNotice?: (message: string) => void;
|
||||
}
|
||||
|
||||
type Vip98kModelRuntimeConfig = {
|
||||
@ -1060,6 +1064,10 @@ function isSynchronousImagePath(path: string) {
|
||||
return /^\/v1\/images\/(?:generations|edits)\/?$/.test(path);
|
||||
}
|
||||
|
||||
const transparentHigh4kNotice =
|
||||
"GPT Image 2 VIP 的 4K 方图、高质量、透明 PNG 组合当前可能生成失败。";
|
||||
const noCompatibleImageRouteNotice = "本次未找到支持该规格的可用备用线路。";
|
||||
|
||||
async function recoverImageSubmission(params: {
|
||||
apiKey: string;
|
||||
baseURL: string;
|
||||
@ -1068,6 +1076,7 @@ async function recoverImageSubmission(params: {
|
||||
idempotencyKey: string;
|
||||
pollIntervalMs: number;
|
||||
maxPollMs: number;
|
||||
warnTransparentHigh4k?: boolean;
|
||||
}) {
|
||||
if (!isSynchronousImagePath(params.path)) return null;
|
||||
const startedAt = Date.now();
|
||||
@ -1093,6 +1102,13 @@ async function recoverImageSubmission(params: {
|
||||
providerRequestId: state.request_id,
|
||||
durationMs: Date.now() - startedAt,
|
||||
});
|
||||
if (params.warnTransparentHigh4k) {
|
||||
const routeNotice = toRecord(state.error)?.code === "no_eligible_route" ? noCompatibleImageRouteNotice : "";
|
||||
throw new ImageGenerationCompatibilityError(
|
||||
`生图服务已确认本次失败,未生成图片。${transparentHigh4kNotice}${routeNotice}`,
|
||||
String(state.request_id),
|
||||
);
|
||||
}
|
||||
throw new AgentImageGenerationError("生图服务已确认本次生成失败,未生成图片。请稍后重试或手动选择其他模型。", true);
|
||||
}
|
||||
if (!state || !["processing", "succeeded"].includes(String(state.status))) return null;
|
||||
@ -1149,10 +1165,25 @@ async function submitTask(params: {
|
||||
submissionRetryBaseDelayMs: number;
|
||||
pollIntervalMs: number;
|
||||
maxPollMs: number;
|
||||
onImageGenerationNotice?: Vip98kTaskParams["onImageGenerationNotice"];
|
||||
}) {
|
||||
const baseURL = normalizeVip98kBaseUrl(params.baseURL);
|
||||
const path = String(params.path || "/api/external/task/generate").trim();
|
||||
if (!path.startsWith("/")) throw new Error("VIP98K invocation path is invalid");
|
||||
const warnTransparentHigh4k =
|
||||
params.modelId === "gpt-image-2-vip" &&
|
||||
/^\/v1\/images\/generations\/?$/.test(path) &&
|
||||
params.body.size === "2880x2880" &&
|
||||
params.body.quality === "high" &&
|
||||
params.body.background === "transparent" &&
|
||||
params.body.output_format === "png";
|
||||
if (warnTransparentHigh4k && params.onImageGenerationNotice) {
|
||||
try {
|
||||
params.onImageGenerationNotice(transparentHigh4kNotice);
|
||||
} catch {
|
||||
logger.warn("image generation notice could not be sent");
|
||||
}
|
||||
}
|
||||
const stagedReferenceKeys = [
|
||||
"file_urls",
|
||||
"image[]",
|
||||
@ -1171,7 +1202,7 @@ async function submitTask(params: {
|
||||
isVip98kStagedReferenceUrl(candidate),
|
||||
);
|
||||
});
|
||||
const maxAttempts = params.maxSubmissionAttempts;
|
||||
const maxAttempts = warnTransparentHigh4k ? 1 : params.maxSubmissionAttempts;
|
||||
let refreshStagedReferences = false;
|
||||
let idempotencyKey = randomUUID();
|
||||
const submissionStartedAt = Date.now();
|
||||
@ -1214,7 +1245,7 @@ async function submitTask(params: {
|
||||
signal: AbortSignal.timeout(params.submissionTimeoutMs),
|
||||
});
|
||||
} catch (error) {
|
||||
const recovered = await recoverImageSubmission({ ...params, baseURL, path, idempotencyKey });
|
||||
const recovered = await recoverImageSubmission({ ...params, baseURL, path, idempotencyKey, warnTransparentHigh4k });
|
||||
if (recovered) return recovered;
|
||||
if (isSynchronousImagePath(path) || attempt >= maxAttempts) {
|
||||
logger.error("provider submission transport failed", {
|
||||
@ -1263,13 +1294,20 @@ async function submitTask(params: {
|
||||
}
|
||||
|
||||
if ([502, 504, 524].includes(response.status)) {
|
||||
const recovered = await recoverImageSubmission({ ...params, baseURL, path, idempotencyKey });
|
||||
const recovered = await recoverImageSubmission({ ...params, baseURL, path, idempotencyKey, warnTransparentHigh4k });
|
||||
if (recovered) return recovered;
|
||||
if (isSynchronousImagePath(path)) {
|
||||
throw new ProviderTaskUncertainError(`供应商提交结果未确认,可能仍在处理,请勿重复生成:${getUserFacingImageGenerationErrorMessage({ message: extractErrorMessage(payload), status: response.status })} (HTTP ${response.status})`);
|
||||
}
|
||||
}
|
||||
|
||||
const providerError = toRecord(toRecord(payload)?.error);
|
||||
if (warnTransparentHigh4k && providerError?.code === "no_eligible_route") {
|
||||
throw new ImageGenerationCompatibilityError(
|
||||
`生图服务未能处理本次请求。${transparentHigh4kNotice}${noCompatibleImageRouteNotice}`,
|
||||
response.headers.get("x-request-id"),
|
||||
);
|
||||
}
|
||||
const errorMessage = extractErrorMessage(payload);
|
||||
const stagedMediaRetryDelayMs = getVip98kStagedMediaRetryDelay({
|
||||
status: response.status,
|
||||
@ -1320,6 +1358,7 @@ async function submitTask(params: {
|
||||
throw Object.assign(new Error(`${errorMessage} (HTTP ${response.status})`), {
|
||||
status: response.status,
|
||||
providerRequestId: response.headers.get("x-request-id"),
|
||||
...(warnTransparentHigh4k ? { preserveImageSpec: true } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
@ -1354,6 +1393,7 @@ export async function submitVip98kExternalTask(params: {
|
||||
videoParams?: Record<string, unknown>;
|
||||
imageParams?: Record<string, unknown>;
|
||||
modelConfig?: Vip98kModelRuntimeConfig;
|
||||
onImageGenerationNotice?: Vip98kTaskParams["onImageGenerationNotice"];
|
||||
}): Promise<Vip98kExternalTaskSubmission> {
|
||||
const runtimeConfig = await getVip98kRuntimeConfig();
|
||||
const referencePreparationStartedAt = Date.now();
|
||||
@ -1433,6 +1473,7 @@ export async function submitVip98kExternalTask(params: {
|
||||
contentType: invocation?.contentType,
|
||||
headers: invocation?.headers,
|
||||
body,
|
||||
onImageGenerationNotice: params.onImageGenerationNotice,
|
||||
submissionTimeoutMs: resolveVip98kSubmissionTimeoutMs(
|
||||
params.modelId,
|
||||
runtimeConfig,
|
||||
@ -1873,6 +1914,7 @@ export async function executeVip98kExternalTask(params: {
|
||||
imageParams?: Record<string, unknown>;
|
||||
modelConfig?: Vip98kModelRuntimeConfig;
|
||||
lifecycle?: ProviderTaskLifecycle;
|
||||
onImageGenerationNotice?: Vip98kTaskParams["onImageGenerationNotice"];
|
||||
}): Promise<Vip98kExternalTaskResult> {
|
||||
await params.lifecycle?.assertActive();
|
||||
const submitted = params.lifecycle?.resume
|
||||
@ -1928,6 +1970,7 @@ async function runTask(params: Vip98kTaskParams) {
|
||||
videoParams: params.videoParams,
|
||||
imageParams: params.imageParams,
|
||||
modelConfig: params.modelConfig,
|
||||
onImageGenerationNotice: params.onImageGenerationNotice,
|
||||
});
|
||||
const outputUrls = completed.outputUrls;
|
||||
|
||||
@ -1985,6 +2028,7 @@ export function createVip98k({ apiKey, baseURL }: Vip98kConfig) {
|
||||
videoParams?: Record<string, unknown>;
|
||||
imageGenConfig?: unknown;
|
||||
overrideModelId?: string;
|
||||
onImageGenerationNotice?: Vip98kTaskParams["onImageGenerationNotice"];
|
||||
}) => {
|
||||
const runtimeConfig =
|
||||
options.imageGenConfig !== undefined
|
||||
@ -2010,6 +2054,7 @@ export function createVip98k({ apiKey, baseURL }: Vip98kConfig) {
|
||||
videoParams: options.videoParams,
|
||||
imageParams: options.imageParams,
|
||||
modelConfig: runtimeConfig,
|
||||
onImageGenerationNotice: options.onImageGenerationNotice,
|
||||
});
|
||||
return {
|
||||
text,
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import { agentModelFault, type AgentModelFault } from "./agent-model-failover";
|
||||
import { shouldPreserveImageSpec } from "./image-generation-error";
|
||||
|
||||
export function agentImageFailurePolicy(error: unknown): { retry: boolean; pause: AgentModelFault | null } {
|
||||
if (shouldPreserveImageSpec(error)) return { retry: false, pause: null };
|
||||
const value = error as { message?: string; providerOutcomeUnknown?: boolean; status?: number; statusCode?: number } | null;
|
||||
const message = String(value?.message || "").toLowerCase();
|
||||
if (value?.providerOutcomeUnknown || ["AbortError", "TimeoutError"].includes(String((error as { name?: string })?.name || ""))) return { retry: false, pause: null };
|
||||
|
||||
@ -10,6 +10,18 @@ export class AgentImageGenerationError extends Error {
|
||||
constructor(message: string, readonly confirmedNoResult: boolean) { super(message); }
|
||||
}
|
||||
|
||||
export class ImageGenerationCompatibilityError extends AgentImageGenerationError {
|
||||
readonly preserveImageSpec = true;
|
||||
|
||||
constructor(message: string, readonly providerRequestId: string | null) {
|
||||
super(message, true);
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldPreserveImageSpec(error: unknown) {
|
||||
return (error as { preserveImageSpec?: boolean } | null)?.preserveImageSpec === true;
|
||||
}
|
||||
|
||||
export class ImageReferenceReadTimeoutError extends AgentImageGenerationError {
|
||||
constructor() {
|
||||
super("提交生图前读取参考图超时,任务尚未提交,可以稍后重试。", true);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import "server-only";
|
||||
import { ProviderTaskUncertainError } from "@/lib/video-canvas/video-task-lifecycle";
|
||||
import { isProviderAuthenticationFailure, isCredentialFailureBan } from "./authentication-failover";
|
||||
import { ImageGenerationCompatibilityError, shouldPreserveImageSpec } from "./image-generation-error";
|
||||
|
||||
import { and, desc, eq, exists, inArray, isNotNull, or, sql } from "drizzle-orm";
|
||||
import { db } from "@/lib/db";
|
||||
@ -109,6 +110,9 @@ export function classifyAiModelHealthFailure(error: unknown): {
|
||||
counted: boolean;
|
||||
reason: string;
|
||||
} {
|
||||
if (error instanceof ImageGenerationCompatibilityError) {
|
||||
return { eventType: "error", severity: "warning", counted: false, reason: "image_spec_failure" };
|
||||
}
|
||||
const message = getErrorMessage(error);
|
||||
const normalized = message.toLowerCase();
|
||||
const httpStatus = getErrorHttpStatus(error);
|
||||
@ -347,6 +351,7 @@ export function classifyAiModelHealthFailure(error: unknown): {
|
||||
|
||||
export function shouldFailoverAiModelError(error: unknown) {
|
||||
if (
|
||||
shouldPreserveImageSpec(error) ||
|
||||
error instanceof ProviderTaskUncertainError ||
|
||||
isGatewayResponseTimeout(error) ||
|
||||
getRequestFailureDetails(error).outcome === "unknown" ||
|
||||
@ -436,7 +441,7 @@ export function shouldFailoverVip98kRequestRejection(
|
||||
error: unknown,
|
||||
providerType: unknown,
|
||||
) {
|
||||
if (String(providerType || "").trim().toLowerCase() !== "vip98k") {
|
||||
if (shouldPreserveImageSpec(error) || String(providerType || "").trim().toLowerCase() !== "vip98k") {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import sharp from "sharp";
|
||||
import { agentImageCircuitStore } from "@/lib/ai/runtime/agent-model-circuit-store";
|
||||
import { getModelGenerationCreditCost, type DiscountableImageGenConfigLike } from "@/lib/ai/image-model-pricing";
|
||||
import { agentImageFailurePolicy } from "@/lib/ai/runtime/agent-image-failover";
|
||||
import { AgentImageGenerationError, agentImageGenerationError, ImageReferenceReadTimeoutError } from "@/lib/ai/runtime/image-generation-error";
|
||||
import { AgentImageGenerationError, agentImageGenerationError, ImageReferenceReadTimeoutError, shouldPreserveImageSpec } from "@/lib/ai/runtime/image-generation-error";
|
||||
import { getAiModelById, getEnabledAiModelsWithProvider } from "@/lib/db/queries";
|
||||
import { fetchImageBufferFromUrl } from "@/lib/ai/rmbg/service";
|
||||
import { createGeminiImage } from "@/lib/ai/providers/gemini-image";
|
||||
@ -181,6 +181,7 @@ export interface CanvasGenerateImageRequest {
|
||||
falThinkingLevel?: "minimal" | "high";
|
||||
promptExtend?: boolean;
|
||||
providerImageParams?: Record<string, unknown>;
|
||||
onImageGenerationNotice?: (message: string) => void;
|
||||
referenceImage?: string;
|
||||
referenceImages?: string[];
|
||||
referenceImageBuffers?: ReadonlyMap<string, Buffer>;
|
||||
@ -5436,6 +5437,7 @@ export async function generateCanvasImage(
|
||||
imageCount: batchImageCount,
|
||||
},
|
||||
imageGenConfig: selectedModel.model.imageGenConfig || null,
|
||||
onImageGenerationNotice: request.onImageGenerationNotice,
|
||||
});
|
||||
return result.text || "";
|
||||
};
|
||||
@ -5698,8 +5700,9 @@ export async function generateCanvasImage(
|
||||
return { images: collectedImages, model: selectedModel.model.displayName, modelRef: selectedModel.model.id, prompt: resultPrompt };
|
||||
}
|
||||
|
||||
// An accepted or uncertain request must not start another paid model/variant.
|
||||
// Keep the original outcome and any explicitly preserved output spec.
|
||||
if (caughtError && (
|
||||
shouldPreserveImageSpec(caughtError) ||
|
||||
caughtError instanceof ProviderTaskUncertainError ||
|
||||
getRequestFailureDetails(caughtError).outcome === "unknown" ||
|
||||
["AbortError", "TimeoutError"].includes(String((caughtError as { name?: string })?.name || ""))
|
||||
|
||||
@ -33,6 +33,7 @@ export type ChatTools = {
|
||||
export type CustomUIDataTypes = {
|
||||
textDelta: string;
|
||||
imageDelta: string;
|
||||
imageGenerationNotice: string;
|
||||
sheetDelta: string;
|
||||
codeDelta: string;
|
||||
suggestion: Suggestion;
|
||||
|
||||
@ -72,6 +72,100 @@ for (const status of ["failed", "unresolved", "unknown", "missing"]) {
|
||||
});
|
||||
}
|
||||
|
||||
test("VIP transparent 4K high notices preserve the request and only report verified route failures", async () => {
|
||||
const spec = { size: "2880x2880", quality: "high", background: "transparent", output_format: "png" };
|
||||
const scenarios = [
|
||||
{ name: "confirmed generation failure", status: 502, recovery: "failed", notice: true },
|
||||
{ name: "confirmed no eligible route", status: 503, notice: true },
|
||||
{ name: "explicit submission rejection", status: 400, notice: true },
|
||||
{ name: "unknown result", status: 502, recovery: "unknown", notice: true },
|
||||
{ name: "successful generation", status: 200, notice: true },
|
||||
{ name: "medium quality", status: 200, fields: { quality: "medium" } },
|
||||
{ name: "opaque background", status: 200, fields: { background: "opaque" } },
|
||||
{ name: "WebP output", status: 200, fields: { output_format: "webp" } },
|
||||
{ name: "smaller size", status: 200, fields: { size: "2048x2048" } },
|
||||
{ name: "ordinary model", status: 200, model: "gpt-image-2" },
|
||||
];
|
||||
for (const scenario of scenarios) {
|
||||
await test.step(scenario.name, async () => {
|
||||
const events: string[] = [];
|
||||
const model = scenario.model || "gpt-image-2-vip";
|
||||
const wireSpec = { ...spec, ...scenario.fields };
|
||||
const loader = serverLoader({
|
||||
"@/lib/db": {},
|
||||
"@/lib/db/queries": { getSystemSetting: async () => null },
|
||||
"@/lib/storage/image-archive": { createDeferredUploadedImage: async (url: string) => ({ original: url, thumbnail: url }) },
|
||||
"@/lib/storage/service": {},
|
||||
"@/lib/observability/logger": { createLogger: () => ({ info() {}, warn() {}, error() {} }) },
|
||||
fetch: async (url: string, init: RequestInit) => {
|
||||
if (init.method === "POST") {
|
||||
events.push("submit");
|
||||
expect(url).toBe("https://provider.test/v1/images/generations");
|
||||
expect(JSON.parse(String(init.body))).toMatchObject({ ...wireSpec, model });
|
||||
if (scenario.status === 200) return Response.json({ data: [{ url: "https://assets.test/image.png" }] });
|
||||
const error = scenario.status === 400
|
||||
? { code: "invalid_request", message: "The request is invalid" }
|
||||
: { code: scenario.status === 503 ? "no_eligible_route" : "service_error", message: "Generation failed" };
|
||||
return Response.json({ error }, {
|
||||
status: scenario.status, headers: { "X-Request-ID": "original-request" },
|
||||
});
|
||||
}
|
||||
events.push("lookup");
|
||||
expect(url).toContain("/api/external/requests/by-idempotency-key");
|
||||
return Response.json({
|
||||
status: scenario.recovery,
|
||||
request_id: "original-request",
|
||||
result_available: false,
|
||||
error: { code: "service_error" },
|
||||
});
|
||||
},
|
||||
});
|
||||
const provider = loader("lib/ai/providers/vip98k.ts").createVip98k({ apiKey: "fixture", baseURL: "https://provider.test" });
|
||||
const attempt = provider.chat(model, { capabilities: { vip98k: { invocation: {
|
||||
kind: "image", method: "POST", path: "/v1/images/generations", contentType: "application/json",
|
||||
requestExample: { ...wireSpec, model, prompt: "Fixture prompt" },
|
||||
} } } }).doGenerate({
|
||||
messages: [{ role: "user", content: "a blue cup" }],
|
||||
onImageGenerationNotice: (notice: string) => {
|
||||
expect(notice).toContain("组合当前可能生成失败");
|
||||
events.push("notice");
|
||||
},
|
||||
});
|
||||
if (scenario.status === 200) {
|
||||
expect((await attempt).text).toContain("https://assets.test/image.png");
|
||||
} else {
|
||||
const error = await attempt.catch((cause: Error) => cause);
|
||||
const { getRequestFailureDetails, formatRequestFailure } = loader("lib/request-error.ts");
|
||||
const details = getRequestFailureDetails(error);
|
||||
const failure = formatRequestFailure(details, "canvas-request");
|
||||
expect(failure).toContain("请求编号:canvas-request");
|
||||
if (scenario.recovery === "unknown") {
|
||||
expect(details.outcome).toBe("unknown");
|
||||
expect(failure).not.toContain("备用线路");
|
||||
} else if (scenario.status === 400) {
|
||||
expect(failure).toContain("The request is invalid");
|
||||
expect(failure).not.toContain("备用线路");
|
||||
const health = loader("lib/ai/runtime/model-health.ts");
|
||||
expect(health.shouldFailoverVip98kRequestRejection(error, "vip98k")).toBe(false);
|
||||
} else {
|
||||
expect(error).toMatchObject({ confirmedNoResult: true, providerRequestId: "original-request" });
|
||||
expect(failure).toContain("组合当前可能生成失败");
|
||||
expect(failure.includes("备用线路")).toBe(scenario.status === 503);
|
||||
expect(loader("lib/ai/runtime/agent-image-failover.ts").agentImageFailurePolicy(error)).toEqual({ retry: false, pause: null });
|
||||
const health = loader("lib/ai/runtime/model-health.ts");
|
||||
expect(health.shouldFailoverAiModelError(error)).toBe(false);
|
||||
expect(health.classifyAiModelHealthFailure(error).counted).toBe(false);
|
||||
}
|
||||
}
|
||||
expect(events).toEqual([
|
||||
...(scenario.notice ? ["notice"] : []),
|
||||
"submit",
|
||||
...(scenario.recovery ? ["lookup"] : []),
|
||||
]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("catalog defaults allow async failover time while retaining an explicit polling limit", () => {
|
||||
const models = [{ id: "nano-banana-2", type: "image", invocation: {
|
||||
kind: "task", method: "POST", path: "/extensions/v1/tasks", content_type: "application/json",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user