fix: support HTTP/HTTPS image URLs in Claude and Gemini translators (#344)

Previously only base64 data: URLs were handled in the OpenAI-to-Claude
and OpenAI-to-Gemini request translators. HTTP/HTTPS image URLs were
silently dropped, causing vision-capable models to respond with
"I don't see any image."
This commit is contained in:
Ryan 2026-03-23 10:56:40 +03:00 committed by GitHub
parent 8df8b94180
commit 99cb9ed11f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -54,6 +54,10 @@ export function convertOpenAIContentToParts(content) {
inlineData: { mime_type: mimeType, data: data }
});
}
} else if (item.type === "image_url" && item.image_url?.url && (item.image_url.url.startsWith("http://") || item.image_url.url.startsWith("https://"))) {
parts.push({
fileData: { fileUri: item.image_url.url, mimeType: "image/*" }
});
}
}
}

View file

@ -216,6 +216,11 @@ function getContentBlocksFromMessage(msg, toolNameMap = new Map()) {
type: "image",
source: { type: "base64", media_type: match[1], data: match[2] }
});
} else if (url.startsWith("http://") || url.startsWith("https://")) {
blocks.push({
type: "image",
source: { type: "url", url }
});
}
} else if (part.type === "image" && part.source) {
blocks.push({ type: "image", source: part.source });