toJson method

Map<String, Object?> toJson()

Converts this message to JSON-compatible values.

Implementation

Map<String, Object?> toJson() {
  return {
    'role': role.jsonName,
    if (!contents.isEmpty) 'content': contents.toJson(),
    if (toolCalls.isNotEmpty)
      'tool_calls': toolCalls.map((toolCall) => toolCall.toJson()).toList(),
    if (channels.isNotEmpty) 'channels': channels,
  };
}