From 4496bf96c88bee6bfbe39696d3c381e291d660d8 Mon Sep 17 00:00:00 2001 From: decolua Date: Mon, 23 Mar 2026 12:17:51 +0700 Subject: [PATCH] Feat : Kiro Provider can now read images. --- open-sse/translator/request/openai-to-kiro.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/open-sse/translator/request/openai-to-kiro.js b/open-sse/translator/request/openai-to-kiro.js index d4471bd..7cea219 100644 --- a/open-sse/translator/request/openai-to-kiro.js +++ b/open-sse/translator/request/openai-to-kiro.js @@ -113,17 +113,24 @@ function convertMessages(messages, tools, model) { if (c.type === "text" || c.text) { textParts.push(c.text || ""); } else if (c.type === "image_url") { + // OpenAI format: image_url.url with data URI const url = c.image_url?.url || ""; const base64Match = url.match(/^data:([^;]+);base64,(.+)$/); if (base64Match) { - // Extract format from media type (e.g. "image/png" → "png") const mediaType = base64Match[1]; const format = mediaType.split("/")[1] || mediaType; pendingImages.push({ format, source: { bytes: base64Match[2] } }); } else if (url.startsWith("http://") || url.startsWith("https://")) { - // Kiro images field only supports base64 — fallback to URL text + // Kiro only supports base64 — fallback to URL text textParts.push(`[Image: ${url}]`); } + } else if (c.type === "image") { + // Claude format: source.type = "base64", source.media_type, source.data + if (c.source?.type === "base64" && c.source?.data) { + const mediaType = c.source.media_type || "image/png"; + const format = mediaType.split("/")[1] || mediaType; + pendingImages.push({ format, source: { bytes: c.source.data } }); + } } } content = textParts.join("\n");