File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -171,3 +171,21 @@ async def test_openai_video_url_raises_not_implemented():
171171
172172 with pytest .raises (NotImplementedError ):
173173 await OpenAIChatModel ._map_single_item (VideoUrl (url = 'https://example.com/file.mp4' ))
174+
175+
176+ async def test_openai_image_url_maps_to_image_url_part ():
177+ # Functional: verify that an ImageUrl input maps to an image_url content part
178+ from pydantic_ai .messages import ImageUrl
179+
180+ part = UserPromptPart (content = [ImageUrl (url = 'https://example.com/picture.png' )])
181+ msg = await OpenAIChatModel ._map_user_prompt (part )
182+ content = cast (list [dict [str , Any ]], msg ['content' ])
183+ assert content [0 ]['type' ] == 'image_url'
184+
185+
186+ async def test_openai_magic_binary_image_maps_to_image_url ():
187+ # Functional: MagicBinaryContent with image/* should map to image_url content part
188+ part = UserPromptPart (content = [MagicBinaryContent (data = b'\x89 PNG' , media_type = 'image/png' )])
189+ msg = await OpenAIChatModel ._map_user_prompt (part )
190+ content = cast (list [dict [str , Any ]], msg ['content' ])
191+ assert content [0 ]['type' ] == 'image_url'
You can’t perform that action at this time.
0 commit comments