OpenAIStreamChatCompletionModel.fromMap constructor

OpenAIStreamChatCompletionModel.fromMap(
  1. Map<String, dynamic> json
)

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((e) => OpenAIStreamChatCompletionChoiceModel.fromMap(e))
        .toList(),
  );
}