5050with open (flower_path , "rb" ) as f :
5151 flower_image_b64 = base64 .b64encode (f .read ()).decode ()
5252
53+ # https://commons.wikimedia.org/wiki/File:Soni_test_image.png
54+ test_image_path = Path (__file__ ).parent / "assets" / "960px-Soni_test_image.png"
55+ test_image_b64 = None
56+ with open (test_image_path , "rb" ) as f :
57+ test_image_b64 = base64 .b64encode (f .read ()).decode ()
58+
5359
5460def walk_process_tree (root_pid : int ) -> set [int ]:
5561 pids = {root_pid }
@@ -439,7 +445,9 @@ async def _check_completion_streaming_tool_call_health(
439445
440446 return result
441447
442- async def _check_completion_with_image_input_health (self ) -> dict [str , str ]:
448+ async def _check_completion_with_image_input_health_flower (
449+ self ,
450+ ) -> dict [str , str ]:
443451 messages = [
444452 ChatCompletionUserMessageParam (
445453 role = "user" ,
@@ -449,7 +457,7 @@ async def _check_completion_with_image_input_health(self) -> dict[str, str]:
449457 {
450458 "type" : "image_url" ,
451459 "image_url" : {
452- "url" : f"data:image/jpeg;base64,{ flower_image_b64 } "
460+ "url" : f"data:image/jpeg;base64,{ flower_image_b64 } " ,
453461 },
454462 }
455463 ),
@@ -474,6 +482,41 @@ async def _check_completion_with_image_input_health(self) -> dict[str, str]:
474482 }
475483 return {"completion_with_image_input" : "" }
476484
485+ async def _check_completion_with_image_input_health (self ) -> dict [str , str ]:
486+ messages = [
487+ ChatCompletionUserMessageParam (
488+ role = "user" ,
489+ content = [
490+ {"type" : "text" , "text" : "Please extract image text" },
491+ ChatCompletionContentPartImageParam (
492+ {
493+ "type" : "image_url" ,
494+ "image_url" : {
495+ "url" : f"data:image/png;base64,{ test_image_b64 } " ,
496+ },
497+ }
498+ ),
499+ ],
500+ )
501+ ]
502+ try :
503+ client = openai .AsyncOpenAI (base_url = self .endpoint , api_key = "" )
504+ resp = await client .chat .completions .create (
505+ model = self .config .id ,
506+ messages = messages ,
507+ )
508+ except openai .APIConnectionError as e :
509+ return {"completion_with_image_input" : f"Error connecting: { e } " }
510+ content = resp .choices [0 ].message .content
511+ expected = "This is a test image"
512+ if not content :
513+ return {"completion_with_image_input" : "Response content is empty" }
514+ if expected not in content :
515+ return {
516+ "completion_with_image_input" : f"Response does not contain expected text: { expected !r} not in { content !r} "
517+ }
518+ return {"completion_with_image_input" : "" }
519+
477520 async def terminate (self ) -> None :
478521 """Terminate the process, escalating to kill if necessary."""
479522 log .info ("Terminating model" , model = self .config .id )
0 commit comments