fix: harden detail plan image-link fallback and model send sync
This commit is contained in:
parent
dcb82c73b5
commit
e3eb167652
@ -39,6 +39,19 @@ function isAbortError(error: unknown): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function isReferenceImageDownloadError(error: unknown): boolean {
|
||||
const target = error as { name?: unknown; message?: unknown };
|
||||
const name = String(target?.name || "");
|
||||
const message = String(target?.message || "");
|
||||
return (
|
||||
/AI_DownloadError/i.test(name) ||
|
||||
/Failed to download/i.test(message) ||
|
||||
/404\s*Not\s*Found/i.test(message) ||
|
||||
/403\s*Forbidden/i.test(message) ||
|
||||
/image.*download/i.test(message)
|
||||
);
|
||||
}
|
||||
|
||||
function supportsVisionPlanning(model: {
|
||||
supportsVision?: boolean | null;
|
||||
capabilities?: unknown;
|
||||
@ -1849,12 +1862,15 @@ export async function POST(request: Request) {
|
||||
if (
|
||||
isAbortError(error) ||
|
||||
/invalid scheme/i.test(message) ||
|
||||
isReferenceImageDownloadError(error) ||
|
||||
/operationtimeouterror|timed out|timeout/i.test(message)
|
||||
) {
|
||||
console.error("[Canvas Detail Plan] Primary planning aborted, fallback applied:", error);
|
||||
const fallbackReason = /invalid scheme/i.test(message)
|
||||
? "规划模型图片输入协议不兼容,已回退到稳定分镜模板。"
|
||||
: "规划模型调用超时,已自动回退到稳定分镜模板。";
|
||||
: isReferenceImageDownloadError(error)
|
||||
? "参考图链接不可访问(404/下载失败),已自动忽略参考图并回退稳定分镜模板。"
|
||||
: "规划模型调用超时,已自动回退到稳定分镜模板。";
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: {
|
||||
|
||||
@ -6450,14 +6450,18 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
}}
|
||||
disabled={isDetailGenerating}
|
||||
className={cn(
|
||||
"rounded-lg border px-3 py-2 text-left transition-colors",
|
||||
"rounded-lg border px-3 py-2 text-left transition-all duration-150",
|
||||
isDetailGenerating && "cursor-not-allowed opacity-60",
|
||||
selected
|
||||
? "border-primary/50 bg-primary/10 text-primary"
|
||||
: "border-border/50 bg-background text-muted-foreground hover:border-primary/30 hover:text-foreground"
|
||||
? "border-[#5b7cff] bg-[#eef3ff] text-[#2f57d8] shadow-[0_0_0_1px_rgba(91,124,255,0.28)]"
|
||||
: "border-border/60 bg-background text-muted-foreground hover:border-[#9fb3ff] hover:bg-[#f8faff] hover:text-foreground"
|
||||
)}
|
||||
aria-pressed={selected}
|
||||
>
|
||||
<div className="text-[11px] font-medium">{option.label}</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="text-[11px] font-medium">{option.label}</div>
|
||||
{selected ? <Check className="h-3.5 w-3.5" /> : null}
|
||||
</div>
|
||||
<div className="mt-1 text-[10px] leading-snug opacity-80">
|
||||
{option.description}
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user