OpenAIStreamChatCompletionModel.fromMap constructor
The OpenAIStreamChatCompletionModel class represents the chat completion response model of the OpenAI API, which is used and get returned while using the chat methods that leverages Stream functionality. This is used to convert a Map<String, dynamic> object to a OpenAIStreamChatCompletionModel object.
Implementation
factory OpenAIStreamChatCompletionModel.fromMap(Map<String, dynamic> json) {
return OpenAIStreamChatCompletionModel(
id: json['id'],
created: DateTime.fromMillisecondsSinceEpoch(json['created'] * 1000),
choices: (json['choices'] as List)
.map(
(choice) => OpenAIStreamChatCompletionChoiceModel.fromMap(choice),
)
.toList(),
systemFingerprint: json['system_fingerprint'],
);
}