@@ -399,9 +399,7 @@ def instrument(self, enable_content_recording: Optional[bool] = None):
399399 )
400400
401401 # Check if binary data tracing is enabled
402- enable_binary_data = self ._str_to_bool (
403- os .environ .get ("AZURE_TRACING_GEN_AI_INCLUDE_BINARY_DATA" , "false" )
404- )
402+ enable_binary_data = self ._str_to_bool (os .environ .get ("AZURE_TRACING_GEN_AI_INCLUDE_BINARY_DATA" , "false" ))
405403
406404 if not self .is_instrumented ():
407405 self ._instrument_responses (enable_content_recording , enable_binary_data )
@@ -618,17 +616,17 @@ def _add_structured_input_events(
618616
619617 # Build structured event content with content parts
620618 event_body : Dict [str , Any ] = {}
621-
619+
622620 # Only process content if content recording is enabled
623621 if _trace_responses_content :
624622 content_parts = []
625623 has_non_text_content = False
626-
624+
627625 # Content can be a list of content items
628626 if isinstance (content , list ):
629627 for content_item in content :
630628 content_type = None
631-
629+
632630 # Handle dict format
633631 if isinstance (content_item , dict ):
634632 content_type = content_item .get ("type" )
@@ -665,7 +663,7 @@ def _add_structured_input_events(
665663 # Other content types (audio, video, etc.)
666664 has_non_text_content = True
667665 content_parts .append ({"type" : content_type })
668-
666+
669667 # Handle object format
670668 elif hasattr (content_item , "type" ):
671669 content_type = getattr (content_item , "type" , None )
@@ -702,23 +700,23 @@ def _add_structured_input_events(
702700 # Other content types
703701 has_non_text_content = True
704702 content_parts .append ({"type" : content_type })
705-
703+
706704 # Only add content if we have content parts
707705 if content_parts :
708706 # Always use consistent structured format
709707 event_body ["content" ] = content_parts
710-
708+
711709 # Create event attributes
712710 attributes = self ._create_event_attributes (
713711 conversation_id = conversation_id ,
714712 message_role = role ,
715713 )
716714 attributes [GEN_AI_EVENT_CONTENT ] = json .dumps (event_body , ensure_ascii = False )
717-
715+
718716 # Add the event
719717 event_name = f"gen_ai.{ role } .message"
720718 span .span_instance .add_event (name = event_name , attributes = attributes )
721-
719+
722720 except Exception : # pylint: disable=broad-exception-caught
723721 # Skip items that can't be processed
724722 logger .debug ("Failed to process structured input item: %s" , input_item , exc_info = True )
0 commit comments