Merge pull request '明确提示不支持的生图清晰度尚未提交' (#83) from codex/wutong-image-submission-20261113 into main
This commit is contained in:
commit
2b5455d046
@ -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, ImageReferenceReadTimeoutError } from "@/lib/ai/runtime/image-generation-error";
|
||||
import { AgentImageGenerationError, agentImageGenerationError, ImageReferenceReadTimeoutError } 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";
|
||||
@ -4950,7 +4950,7 @@ export async function generateCanvasImage(
|
||||
if (!selectedModel) throw new Error("当前没有可用的备用图片模型,请稍后重试");
|
||||
}
|
||||
if (request.agentImageMode === "pinned" && !isCanvasImageSizeSupported(selectedModel.model.imageGenConfig as CanvasImageGenConfig | null, normalizeCanvasImageSizeValue(request.imageSize)))
|
||||
throw new Error("指定的图片模型不支持所选尺寸,请调整图片尺寸");
|
||||
throw new AgentImageGenerationError("指定的图片模型不支持所选清晰度,任务尚未提交。请调整清晰度后重试。", true);
|
||||
|
||||
const normalizedReferenceImages = Array.from(
|
||||
new Set(
|
||||
|
||||
@ -5,6 +5,16 @@ import { ImageSubmissionRejectedError, agentImageGenerationError } from "@/lib/a
|
||||
import * as generationErrors from "@/lib/ai/runtime/image-generation-error";
|
||||
import { serverLoader } from "../helpers/canvas-download-server-loader";
|
||||
|
||||
test("an unsupported pinned resolution is rejected before submission and can be corrected", async () => {
|
||||
const models = [{ model: { id: "primary", modelId: "primary", isEnabled: true, supportsImageGen: true,
|
||||
imageGenConfig: { supportedImageSizes: ["1K", "2K"] } }, provider: { id: "provider", type: "openai-image", isEnabled: true } }];
|
||||
const h = harness({ models });
|
||||
await expect(h.generate({ ...h.request, agentImageMode: "pinned", imageSize: "4K" })).rejects.toMatchObject({
|
||||
confirmedNoResult: true, message: expect.stringMatching(/尚未提交.*调整清晰度后重试/),
|
||||
});
|
||||
expect(h.calls).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("a balance rejection skips other models on the same account but permits another account of the same provider type", async () => {
|
||||
const models = ["primary", "same-account", "backup"].map(id => ({
|
||||
model: { id, modelId: id, displayName: id, isEnabled: true, supportsImageGen: true, supportsVision: true, imageGenConfig: { maxImages: 1 }, capabilities: { kind: "image" } },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user