groqMessageFromJson static method
Parses the message information from the json
Implementation
static GroqMessage groqMessageFromJson(Map<String, dynamic> json) {
if (json['tool_calls'] != null && json['tool_calls'].isNotEmpty) {
//Is tool call
return GroqMessage(
content: '',
isToolCall: true,
toolCalls: (json['tool_calls'] as List)
.map((item) => groqToolCallFromJson(item as Map<String, dynamic>))
.toList(),
role: GroqMessageRoleParser.tryParse(json['role'] as String) ??
GroqMessageRole.assistant,
username: json['user'] as String?);
}
return GroqMessage(
content: json['content'] as String,
username: json['user'] as String?,
role: GroqMessageRoleParser.tryParse(json['role'] as String) ??
GroqMessageRole.user,
);
}