microsoft.opentelemetry.a365.core.message_utils module
Conversion and serialization helpers for OTEL gen-ai message format.
Provides normalization from plain list[str] (backward compat) to the
structured array format, and a non-throwing serialize_messages function.
- microsoft.opentelemetry.a365.core.message_utils.is_string_list(param)[source]
Return
Truewhen param is a plainlist[str].- Return type:
- microsoft.opentelemetry.a365.core.message_utils.is_wrapped_messages(param)[source]
Return
Truewhen param is a structured message container.- Return type:
- microsoft.opentelemetry.a365.core.message_utils.to_input_messages(messages)[source]
Convert plain input strings into OTEL
ChatMessageobjects.- Return type:
- microsoft.opentelemetry.a365.core.message_utils.to_output_messages(messages)[source]
Convert plain output strings into OTEL
OutputMessageobjects.- Return type:
- microsoft.opentelemetry.a365.core.message_utils.normalize_input_messages(param)[source]
Normalize an
InputMessagesParamto anInputMessagescontainer.str-> wrapped in a single-element list, then converted.list[str]-> converted toChatMessagelist and wrapped.InputMessages-> returned as-is.
- Return type:
- microsoft.opentelemetry.a365.core.message_utils.normalize_output_messages(param)[source]
Normalize an
OutputMessagesParamto anOutputMessagescontainer.str-> wrapped in a single-element list, then converted.list[str]-> converted toOutputMessagelist and wrapped.OutputMessages-> returned as-is.
- Return type:
- microsoft.opentelemetry.a365.core.message_utils.serialize_messages(wrapper)[source]
Serialize a message container to a JSON array.
The output is a plain JSON array of message objects per OTel spec:
[{"role":"user","parts":[...]}].The try/except ensures telemetry recording is non-throwing even when message parts contain non-JSON-serializable values.
- Return type: