88from typing import TYPE_CHECKING , Any , Dict , Generic , List , Optional , TypeVar , Union
99
1010from wayflowcore ._utils .dataclass_utils import _required_attribute
11+ from wayflowcore ._utils .formatting import stringify
1112from wayflowcore .conversationalcomponent import ConversationalComponent
1213from wayflowcore .serialization .context import SerializationContext
1314from wayflowcore .serialization .serializer import serialize_any_to_dict , serialize_to_dict
@@ -258,7 +259,7 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
258259 "conversational_component.type" : self .conversational_component .__class__ .__name__ ,
259260 "conversational_component.id" : self .conversational_component .id ,
260261 "inputs" : (
261- {key : str (value ) for key , value in (self .inputs or {}).items ()}
262+ {key : stringify (value ) for key , value in (self .inputs or {}).items ()}
262263 if not mask_sensitive_information
263264 else _MASKING_TOKEN
264265 ),
@@ -309,7 +310,7 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
309310 return {
310311 ** super ().to_tracing_info (mask_sensitive_information = mask_sensitive_information ),
311312 "tool_request.inputs" : (
312- {key : str (value ) for key , value in self .tool_request .args .items ()}
313+ {key : stringify (value ) for key , value in self .tool_request .args .items ()}
313314 if not mask_sensitive_information
314315 else _MASKING_TOKEN
315316 ),
@@ -332,7 +333,9 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
332333 return {
333334 ** super ().to_tracing_info (mask_sensitive_information = mask_sensitive_information ),
334335 "tool_result.output" : (
335- str (self .tool_result .content ) if not mask_sensitive_information else _MASKING_TOKEN
336+ stringify (self .tool_result .content )
337+ if not mask_sensitive_information
338+ else _MASKING_TOKEN
336339 ),
337340 "tool_result.tool_request_id" : self .tool_result .tool_request_id ,
338341 }
@@ -353,7 +356,7 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
353356 return {
354357 ** super ().to_tracing_info (mask_sensitive_information = mask_sensitive_information ),
355358 "inputs" : (
356- {key : str (value ) for key , value in self .inputs .items ()}
359+ {key : stringify (value ) for key , value in self .inputs .items ()}
357360 if not mask_sensitive_information
358361 else _MASKING_TOKEN
359362 ),
@@ -372,10 +375,11 @@ class StepInvocationResultEvent(EndSpanEvent["StepInvocationSpan"]):
372375 """Result of the step invocation"""
373376
374377 def to_tracing_info (self , mask_sensitive_information : bool = True ) -> Dict [str , Any ]:
378+
375379 return {
376380 ** super ().to_tracing_info (mask_sensitive_information = mask_sensitive_information ),
377381 "step_result.outputs" : (
378- {key : str (value ) for key , value in self .step_result .outputs .items ()}
382+ {key : stringify (value ) for key , value in self .step_result .outputs .items ()}
379383 if not mask_sensitive_information
380384 else _MASKING_TOKEN
381385 ),
@@ -412,7 +416,7 @@ class ContextProviderExecutionResultEvent(EndSpanEvent["ContextProviderExecution
412416 def to_tracing_info (self , mask_sensitive_information : bool = True ) -> Dict [str , Any ]:
413417 return {
414418 ** super ().to_tracing_info (mask_sensitive_information = mask_sensitive_information ),
415- "output" : str (self .output ) if not mask_sensitive_information else _MASKING_TOKEN ,
419+ "output" : stringify (self .output ) if not mask_sensitive_information else _MASKING_TOKEN ,
416420 }
417421
418422
@@ -520,7 +524,9 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
520524 else _MASKING_TOKEN
521525 ),
522526 "execution_state.plan" : (
523- str (self .execution_state .plan ) if not mask_sensitive_information else _MASKING_TOKEN
527+ stringify (self .execution_state .plan )
528+ if not mask_sensitive_information
529+ else _MASKING_TOKEN
524530 ),
525531 "execution_state.tool_call_queue" : [
526532 _serialize_tool_request (tool_request , mask_sensitive_information )
@@ -570,7 +576,9 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
570576 else _MASKING_TOKEN
571577 ),
572578 "execution_state.plan" : (
573- str (self .execution_state .plan ) if not mask_sensitive_information else _MASKING_TOKEN
579+ stringify (self .execution_state .plan )
580+ if not mask_sensitive_information
581+ else _MASKING_TOKEN
574582 ),
575583 "execution_state.tool_call_queue" : [
576584 _serialize_tool_request (tool_request , mask_sensitive_information )
@@ -610,7 +618,7 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
610618 ** super ().to_tracing_info (mask_sensitive_information = mask_sensitive_information ),
611619 "exception.type" : self .exception .__class__ .__name__ ,
612620 "exception.message" : (
613- str (self .exception ) if not mask_sensitive_information else _MASKING_TOKEN
621+ stringify (self .exception ) if not mask_sensitive_information else _MASKING_TOKEN
614622 ),
615623 "exception.traceback" : (
616624 self .exception .__traceback__ if not mask_sensitive_information else _MASKING_TOKEN
0 commit comments