feat: detect image media type in anthropic openai adapter
This commit is contained in:
parent
c5cacded4b
commit
986d633ac2
1 changed files with 7 additions and 1 deletions
|
|
@ -174,11 +174,17 @@ export class AnthropicApi implements BaseLlmApi {
|
|||
}
|
||||
return part;
|
||||
}
|
||||
// Extract media type from data URL (e.g., "data:image/png;base64,..." -> "image/png")
|
||||
// @ts-ignore
|
||||
const dataUrl = part.image_url.url || "";
|
||||
const mediaTypeMatch = dataUrl.match(/^data:([^;]+);base64,/);
|
||||
const mediaType = mediaTypeMatch ? mediaTypeMatch[1] : "image/jpeg";
|
||||
|
||||
return {
|
||||
type: "image",
|
||||
source: {
|
||||
type: "base64",
|
||||
media_type: "image/jpeg",
|
||||
media_type: mediaType,
|
||||
// @ts-ignore
|
||||
data: part.image_url.url.split(",")[1],
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue