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
versioned wrapper 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 versioned wrapper.- 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 a versionedInputMessageswrapper.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 a versionedOutputMessageswrapper.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 versioned message wrapper to JSON.
The output is the full wrapper object:
{"version":"0.1.0","messages":[...]}.The try/except ensures telemetry recording is non-throwing even when message parts contain non-JSON-serializable values.
- Return type: