@@ -350,15 +350,75 @@ def _build_parts_inventory_message(out: Dict[str, Any], part_type: str) -> Tuple
350350 part_type = str (part_type or "" ).strip ().lower ()
351351
352352 if part_type == "gear" :
353- msg = (
354- "Detected gears:\n "
355- f"- biggear: { counts .get ('biggear' , 0 )} \n "
356- f"- smallgear: { counts .get ('smallgear' , 0 )} \n "
357- f"- driving gear: { counts .get ('driving_gear' , counts .get ('drivinggear' , 0 ))} "
353+ driving_count = _safe_int (
354+ counts .get ("Driving_Gear" , counts .get ("driving_gear" , counts .get ("drivinggear" , 0 )))
358355 )
359- if not is_correct :
360- msg += "\n Please spread the gears out clearly and retake the photo."
361- return is_correct , msg
356+ big_count = _safe_int (
357+ counts .get ("Gear_big" , counts .get ("biggear" , 0 ))
358+ )
359+ small_count = _safe_int (
360+ counts .get ("Gear_small" , counts .get ("smallgear" , 0 ))
361+ )
362+ summary = out .get ("summary" , {}) if isinstance (out .get ("summary" ), dict ) else {}
363+ shaft_count = _safe_int (summary .get ("shafts" , 0 ))
364+
365+ counts_text = (
366+ f"Driving gear: { driving_count } \n "
367+ f"Big gears: { big_count } \n "
368+ f"Small gears: { small_count } "
369+ )
370+
371+ if shaft_count > 0 :
372+ feedback = (
373+ "The image contains shafts, which are not required for this task. "
374+ "Please remove the shafts and any attached gear assemblies (e.g. orange gears) "
375+ "and upload a photo showing only the gears."
376+ )
377+ return False , f"{ counts_text } \n { feedback } "
378+
379+ if driving_count == 0 :
380+ feedback = (
381+ "No driving gear was detected. Please include the white driving gear clearly in the photo."
382+ )
383+ return False , f"{ counts_text } \n { feedback } "
384+
385+ if driving_count > 1 :
386+ feedback = (
387+ "More than one driving gear was detected. Please upload an image containing only one white driving gear."
388+ )
389+ return False , f"{ counts_text } \n { feedback } "
390+
391+ if big_count != small_count :
392+ feedback = (
393+ "The detected green idler gears are incomplete or unclear. "
394+ "Each green idler gear unit should contain one big gear and one small gear. "
395+ "Please retake a clearer photo."
396+ )
397+ return False , f"{ counts_text } \n { feedback } "
398+
399+ idler_units = big_count
400+
401+ if idler_units == 2 :
402+ feedback = (
403+ "Good. You have met the task requirement. "
404+ "Detected counts: 1 driving gear and 2 green idler gear units."
405+ )
406+ return True , f"{ counts_text } \n { feedback } "
407+
408+ if idler_units < 2 :
409+ feedback = (
410+ "Not enough green idler gear units were detected. "
411+ "This task requires two green idler gear units. "
412+ "Please include both units clearly in the photo."
413+ )
414+ return False , f"{ counts_text } \n { feedback } "
415+
416+ feedback = (
417+ "Too many green idler gear units were detected. "
418+ "This task requires exactly two green idler gear units. "
419+ "Please remove the extra gears and upload a new photo."
420+ )
421+ return False , f"{ counts_text } \n { feedback } "
362422
363423 if part_type == "shaft" :
364424 msg = (
@@ -838,4 +898,4 @@ def evaluation_function(response: Any, answer: Any, params: Params) -> Result:
838898 selected_errors = selected_errors ,
839899 part_type = part_type ,
840900 )
841- return _result_minimal (is_correct , msg )
901+ return _result_minimal (is_correct , msg )
0 commit comments