@@ -390,13 +390,37 @@ def extract_ordered_extractions(
390390 continue
391391
392392 if not isinstance (extraction_value , (str , int , float )):
393- logging .error (
394- "Extraction text must be a string, integer, or float. Found: %s" ,
395- type (extraction_value ),
396- )
397- raise ValueError (
398- "Extraction text must be a string, integer, or float."
399- )
393+ # Coerce recoverable types instead of crashing.
394+ if isinstance (extraction_value , (list , tuple )):
395+ # LLM sometimes returns a list for extraction_text.
396+ str_parts = [str (v ) for v in extraction_value if v ]
397+ if str_parts :
398+ coerced = " " .join (str_parts )
399+ logging .warning (
400+ "Coerced %s extraction_text to str "
401+ "(class=%s, len=%d): %.120s" ,
402+ type (extraction_value ).__name__ ,
403+ extraction_class ,
404+ len (extraction_value ),
405+ coerced ,
406+ )
407+ extraction_value = coerced
408+ else :
409+ logging .warning (
410+ "Skipping extraction with empty %s "
411+ "extraction_text (class=%s)" ,
412+ type (extraction_value ).__name__ ,
413+ extraction_class ,
414+ )
415+ continue
416+ else :
417+ logging .warning (
418+ "Skipping extraction with unsupported "
419+ "extraction_text type %s (class=%s)" ,
420+ type (extraction_value ).__name__ ,
421+ extraction_class ,
422+ )
423+ continue
400424
401425 if not isinstance (extraction_value , str ):
402426 extraction_value = str (extraction_value )
0 commit comments