File tree Expand file tree Collapse file tree
integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -670,15 +670,16 @@ def _convert_chunks_to_messages(chunks: list[StreamingChunk]) -> list[ChatMessag
670670
671671 # reasoning signatures are ignored in _convert_streaming_chunks_to_chat_message
672672 # so we need to process them separately
673- for chunk in reversed (chunks ):
674- if reply .reasoning and chunk .reasoning and chunk .reasoning .extra and "signature" in chunk .reasoning .extra :
675- reply .reasoning .extra ["signature" ] = chunk .reasoning .extra ["signature" ]
676- break
673+ if reply .reasoning :
674+ for chunk in reversed (chunks ):
675+ if chunk .reasoning and chunk .reasoning .extra and "signature" in chunk .reasoning .extra :
676+ reply .reasoning .extra ["signature" ] = chunk .reasoning .extra ["signature" ]
677+ break
677678
678679 # the trace are ignored in _convert_streaming_chunks_to_chat_message
679680 # so we need to process them separately
680- if chunks [- 1 ].meta and "trace" in chunks [ - 1 ] .meta :
681- reply .meta ["trace" ] = chunks [ - 1 ] .meta ["trace" ]
681+ if chunks and ( last_chunk := chunks [- 1 ]) and last_chunk .meta and "trace" in last_chunk .meta :
682+ reply .meta ["trace" ] = last_chunk .meta ["trace" ]
682683
683684 return [reply ]
684685
You can’t perform that action at this time.
0 commit comments