2525 "https://upload.wikimedia.org/wikipedia/commons/0/0b/RGBA_comp.png" ,
2626]
2727
28+ EXPECTED_MM_BEAM_SEARCH_RES = [
29+ [
30+ "The image shows a wooden boardwalk leading through a" ,
31+ "The image shows a wooden boardwalk extending into a" ,
32+ ],
33+ [
34+ "The image shows two parrots perched on" ,
35+ "The image shows two birds perched on a cur" ,
36+ ],
37+ [
38+ "The image shows a Venn diagram with three over" ,
39+ "This image shows a Venn diagram with three over" ,
40+ ],
41+ [
42+ "This image displays a gradient of colors ranging from" ,
43+ "This image displays a gradient of colors transitioning from" ,
44+ ],
45+ ]
46+
2847
2948@pytest .fixture (scope = "module" )
3049def server ():
@@ -270,10 +289,13 @@ async def test_single_chat_session_image_base64encoded(
270289
271290@pytest .mark .asyncio
272291@pytest .mark .parametrize ("model_name" , [MODEL_NAME ])
273- @pytest .mark .parametrize ("image_url " , TEST_IMAGE_URLS )
292+ @pytest .mark .parametrize ("image_idx " , list ( range ( len ( TEST_IMAGE_URLS ))) )
274293async def test_single_chat_session_image_base64encoded_beamsearch (
275- client : openai .AsyncOpenAI , model_name : str , image_url : str ,
294+ client : openai .AsyncOpenAI , model_name : str , image_idx : int ,
276295 base64_encoded_image : dict [str , str ]):
296+ # NOTE: This test also validates that we pass MM data through beam search
297+ image_url = TEST_IMAGE_URLS [image_idx ]
298+ expected_res = EXPECTED_MM_BEAM_SEARCH_RES [image_idx ]
277299
278300 messages = [{
279301 "role" :
@@ -297,10 +319,11 @@ async def test_single_chat_session_image_base64encoded_beamsearch(
297319 messages = messages ,
298320 n = 2 ,
299321 max_completion_tokens = 10 ,
322+ temperature = 0.0 ,
300323 extra_body = dict (use_beam_search = True ))
301324 assert len (chat_completion .choices ) == 2
302- assert chat_completion .choices [
303- 0 ] .message .content != chat_completion . choices [ 1 ]. message . content
325+ for actual , expected_str in zip ( chat_completion .choices , expected_res ):
326+ assert actual .message .content == expected_str
304327
305328
306329@pytest .mark .asyncio
0 commit comments