Changesets · Branches · Tags · Compare
| Changeset | d2b29fd95725246e73f747da2c0fd6555208cf58e20218a33b012011977e5713 |
|---|---|
| Author | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-08 22:31 +05:30 |
| Committer | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-08 22:31 +05:30 |
| Parents | f679de86c340 |
1 file changed
modified packages/openai-adapters/src/apis/Anthropic.ts +9 −3
| @@ -174,13 +174,19 @@ | ||
| 174 | 174 | } |
| 175 | 175 | return part; |
| 176 | 176 | } |
| 177 | + const dataUrl = | |
| 178 | + (part as OpenAI.Chat.Completions.ChatCompletionContentPartImage) | |
| 179 | + ?.image_url?.url || ""; | |
| 180 | + // Extract media type from data URL (ex. "data:image/png;base64,..." -> "image/png") | |
| 181 | + const mediaTypeMatch = dataUrl.match(/^data:([^;]+);base64,/); | |
| 182 | + const mediaType = mediaTypeMatch ? mediaTypeMatch[1] : "image/jpeg"; | |
| 183 | + | |
| 177 | 184 | return { |
| 178 | 185 | type: "image", |
| 179 | 186 | source: { |
| 180 | 187 | type: "base64", |
| 181 | - media_type: "image/jpeg", | |
| 182 | - // @ts-ignore | |
| 183 | - data: part.image_url.url.split(",")[1], | |
| 188 | + media_type: mediaType, | |
| 189 | + data: dataUrl.split(",")[1], | |
| 184 | 190 | }, |
| 185 | 191 | }; |
| 186 | 192 | }) |