@@ -116,7 +116,7 @@ def _get_workflow_span_name(invocation: WorkflowInvocation) -> str:
116116 return f"{ operation_name } { name } " if name else operation_name
117117
118118
119- def _get_llm_messages_attributes_for_span (
119+ def _get_messages_attributes_for_span (
120120 input_messages : list [InputMessage ],
121121 output_messages : list [OutputMessage ],
122122 system_instruction : list [MessagePart ] | None = None ,
@@ -248,7 +248,7 @@ def _apply_llm_finish_attributes(
248248 attributes .update (_get_llm_request_attributes (invocation ))
249249 attributes .update (_get_llm_response_attributes (invocation ))
250250 attributes .update (
251- _get_llm_messages_attributes_for_span (
251+ _get_messages_attributes_for_span (
252252 invocation .input_messages ,
253253 invocation .output_messages ,
254254 invocation .system_instruction ,
@@ -362,7 +362,7 @@ def _apply_workflow_finish_attributes(
362362 attributes : dict [str , Any ] = {}
363363 attributes .update (_get_workflow_common_attributes (invocation ))
364364 attributes .update (
365- _get_workflow_messages_attributes_for_span (
365+ _get_messages_attributes_for_span (
366366 invocation .input_messages ,
367367 invocation .output_messages ,
368368 )
@@ -386,38 +386,6 @@ def _get_workflow_common_attributes(
386386 }
387387
388388
389- def _get_workflow_messages_attributes_for_span (
390- input_messages : list [InputMessage ],
391- output_messages : list [OutputMessage ],
392- ) -> dict [str , Any ]:
393- """Get message attributes formatted for span (JSON string format).
394-
395- Returns empty dict if not in experimental mode or content capturing is disabled.
396- """
397- if not is_experimental_mode () or get_content_capturing_mode () not in (
398- ContentCapturingMode .SPAN_ONLY ,
399- ContentCapturingMode .SPAN_AND_EVENT ,
400- ):
401- return {}
402-
403- optional_attrs = (
404- (
405- GenAI .GEN_AI_INPUT_MESSAGES ,
406- gen_ai_json_dumps ([asdict (m ) for m in input_messages ])
407- if input_messages
408- else None ,
409- ),
410- (
411- GenAI .GEN_AI_OUTPUT_MESSAGES ,
412- gen_ai_json_dumps ([asdict (m ) for m in output_messages ])
413- if output_messages
414- else None ,
415- ),
416- )
417-
418- return {key : value for key , value in optional_attrs if value is not None }
419-
420-
421389def _get_embedding_response_attributes (
422390 invocation : EmbeddingInvocation ,
423391) -> dict [str , Any ]:
0 commit comments