File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,9 @@ def __format_anthropic_messages(
156
156
"type" : "image" ,
157
157
"source" : {
158
158
"type" : "base64" ,
159
- "media_type" : "image/jpeg" ,
159
+ "media_type" : content_item ["content" ][
160
+ "media_type"
161
+ ],
160
162
"data" : media_data ,
161
163
},
162
164
}
@@ -167,7 +169,7 @@ def __format_anthropic_messages(
167
169
"type" : "image" ,
168
170
"source" : {
169
171
"type" : "base64" ,
170
- "media_type" : "image/jpeg" ,
172
+ "media_type" : content_item [ "content" ][ "media_type" ] ,
171
173
"data" : content_item ["content" ]["media_base64" ],
172
174
},
173
175
}
Original file line number Diff line number Diff line change @@ -61,11 +61,12 @@ def __format_google_messages(
61
61
parts .append ({"text" : content ["content" ]["text" ]})
62
62
elif content ["type" ] == "media_url" :
63
63
media_url = content ["content" ]["media_url" ]
64
+ media_type = content ["content" ]["media_type" ]
64
65
response = requests .get (media_url )
65
66
66
67
data = base64 .b64encode (response .content ).decode ("utf-8" )
67
68
parts .append (
68
- {"inlineData" : {"data" : data , "mimeType" : "image/jpeg" }}
69
+ {"inlineData" : {"data" : data , "mimeType" : media_type }}
69
70
)
70
71
elif content ["type" ] == "media_base64" :
71
72
media_base64 = content ["content" ]["media_base64" ]
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ def chat_arguments(provider_name: str):
11
11
{
12
12
"type" : "media_url" ,
13
13
"content" : {
14
- "media_url" : "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
14
+ "media_url" : "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg" ,
15
+ "media_type" : "image/jpeg" ,
15
16
},
16
17
},
17
18
],
You can’t perform that action at this time.
0 commit comments