Changesets · Branches · Tags · Compare
| Changeset | 43b3a27128129ec6358d791ab24e3b754dead47535aa3bb1a22e86e6fa813479 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-09-08 17:42 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-08 17:42 -07:00 |
| Parents | ff1fecc9110c, 4badedb41b9b |
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 | }) |