Serializes LangChain Message structs to JSON strings following the
gen_ai.input.messages / gen_ai.output.messages GenAI Semantic Convention schema.
The Erlang OpenTelemetry SDK uses flat key-value attributes, so messages are serialized as a JSON string rather than nested structures.
Summary
Functions
Serializes a list of messages to a JSON string for gen_ai.input.messages.
Serializes a result (single message or list of messages) to a JSON string
for gen_ai.output.messages.
Functions
@spec serialize_input([LangChain.Message.t()]) :: String.t()
Serializes a list of messages to a JSON string for gen_ai.input.messages.
Each message is represented as a map with role and content keys.
Tool calls are included under the tool_calls key when present.
@spec serialize_output(LangChain.Message.t() | [LangChain.Message.t()]) :: String.t()
Serializes a result (single message or list of messages) to a JSON string
for gen_ai.output.messages.