File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -357,7 +357,7 @@ def _extract_text_from_input(input_data: Any) -> str:
357357
358358 # If it's a list (conversation history), extract the latest user message
359359 if isinstance (input_data , list ):
360- if len ( input_data ) == 0 :
360+ if not input_data :
361361 return "" # Empty list returns empty string
362362
363363 # Iterate from the end to find the latest user message
@@ -374,8 +374,12 @@ def _extract_text_from_input(input_data: Any) -> str:
374374 text_parts = []
375375 for part in content :
376376 if isinstance (part , dict ):
377- # Check for various text field names
378- text = part .get ("text" ) or part .get ("input_text" ) or part .get ("output_text" )
377+ # Check for various text field names (avoid falsy empty string issue)
378+ text = None
379+ for field in ['text' , 'input_text' , 'output_text' ]:
380+ if field in part :
381+ text = part [field ]
382+ break
379383 if text and isinstance (text , str ):
380384 text_parts .append (text )
381385 if text_parts :
You can’t perform that action at this time.
0 commit comments