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:
@@ -54,6 +54,10 @@ export function convertOpenAIContentToParts(content) {
|
|||||||
inlineData: { mime_type: mimeType, data: data }
|
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",
|
type: "image",
|
||||||
source: { type: "base64", media_type: match[1], data: match[2] }
|
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) {
|
} else if (part.type === "image" && part.source) {
|
||||||
blocks.push({ type: "image", source: part.source });
|
blocks.push({ type: "image", source: part.source });
|
||||||
|
|||||||
Reference in New Issue
Block a user