fix: keep remote image markdown when normalization fails
This commit is contained in:
parent
947495ccfb
commit
e4315282a2
@ -929,18 +929,37 @@ async function normalizeAssistantImageMarkdown(
|
||||
altText,
|
||||
thumbnailUrl
|
||||
);
|
||||
const hostedThumbnailUrl = await ensureHostedImageUrl(thumbnailUrl);
|
||||
const hostedOriginalUrl =
|
||||
originalUrl && originalUrl !== thumbnailUrl
|
||||
? await ensureHostedImageUrl(originalUrl)
|
||||
: hostedThumbnailUrl;
|
||||
|
||||
uploadedUrls.push(hostedThumbnailUrl);
|
||||
uploadedUrls.push(hostedOriginalUrl);
|
||||
rebuilt += ``;
|
||||
let hostedThumbnailUrl = thumbnailUrl;
|
||||
let hostedOriginalUrl =
|
||||
originalUrl && originalUrl !== thumbnailUrl ? originalUrl : thumbnailUrl;
|
||||
|
||||
try {
|
||||
hostedThumbnailUrl = await ensureHostedImageUrl(thumbnailUrl);
|
||||
} catch (error) {
|
||||
console.error("[Chat API] Failed to normalize remote thumbnail URL:", error);
|
||||
}
|
||||
|
||||
if (originalUrl && originalUrl !== thumbnailUrl) {
|
||||
try {
|
||||
hostedOriginalUrl = await ensureHostedImageUrl(originalUrl);
|
||||
} catch (error) {
|
||||
console.error("[Chat API] Failed to normalize remote original URL:", error);
|
||||
hostedOriginalUrl = hostedThumbnailUrl || originalUrl;
|
||||
}
|
||||
} else {
|
||||
hostedOriginalUrl = hostedThumbnailUrl;
|
||||
}
|
||||
|
||||
const finalThumbnailUrl = hostedThumbnailUrl || thumbnailUrl;
|
||||
const finalOriginalUrl = hostedOriginalUrl || finalThumbnailUrl;
|
||||
|
||||
uploadedUrls.push(finalThumbnailUrl);
|
||||
uploadedUrls.push(finalOriginalUrl);
|
||||
rebuilt += ``;
|
||||
} catch (error) {
|
||||
console.error("[Chat API] Failed to normalize remote image URL:", error);
|
||||
rebuilt += "";
|
||||
console.error("[Chat API] Failed to parse remote image markdown metadata:", error);
|
||||
rebuilt += matchText;
|
||||
}
|
||||
|
||||
cursor = start + matchText.length;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user