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:
parent
8df8b94180
commit
99cb9ed11f
2 changed files with 9 additions and 0 deletions
|
|
@ -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/*" }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue