@@ -60,7 +60,10 @@ def _extract_and_set_chat_attributes(self, span, kwargs, response_obj):
6060
6161 inputs = self ._construct_input (kwargs )
6262 input_messages = inputs .get ("messages" , [])
63- output_messages = [c .message .model_dump (exclude_none = True ) for c in getattr (response_obj , "choices" , [])]
63+ output_messages = [
64+ c .message .model_dump (exclude_none = True )
65+ for c in getattr (response_obj , "choices" , [])
66+ ]
6467 if messages := [* input_messages , * output_messages ]:
6568 set_span_chat_messages (span , messages )
6669 if tools := inputs .get ("tools" ):
@@ -184,7 +187,9 @@ def _extract_attributes(self, kwargs):
184187 "call_type" : kwargs .get ("call_type" ),
185188 "model" : kwargs .get ("model" ),
186189 }
187- standard_obj : Optional [StandardLoggingPayload ] = kwargs .get ("standard_logging_object" )
190+ standard_obj : Optional [StandardLoggingPayload ] = kwargs .get (
191+ "standard_logging_object"
192+ )
188193 if standard_obj :
189194 attributes .update (
190195 {
@@ -257,12 +262,25 @@ def _start_span_or_trace(self, kwargs, start_time):
257262 span_type = span_type ,
258263 inputs = inputs ,
259264 attributes = attributes ,
260- tags = self ._transform_tag_list_to_dict (attributes .get ("request_tags" , [])),
265+ tags = self ._transform_tag_list_to_dict (
266+ attributes .get ("request_tags" , [])
267+ ),
261268 start_time_ns = start_time_ns ,
262269 )
263270
264271 def _transform_tag_list_to_dict (self , tag_list : list ) -> dict :
265- return {tag : "" for tag in tag_list }
272+ """
273+ Transform a list of colon-separated tags into a dictionary.
274+ Tags without colons are stored with empty string as the value.
275+ """
276+ tags = {}
277+ for tag in tag_list :
278+ if ":" in tag :
279+ k , v = tag .split (":" , 1 )
280+ tags [k .strip ()] = v .strip ()
281+ else :
282+ tags [tag .strip ()] = ""
283+ return tags
266284
267285 def _end_span_or_trace (self , span , outputs , end_time_ns , status ):
268286 """End an MLflow span or a trace."""
0 commit comments