create method

  1. @override
Future<Conversation> create([
  1. List<Message>? messages
])
override

Implementation

@override
Future<Conversation> create([List<Message>? messages]) async {
  var payload = {
    if (messages != null)
      'messages': messages.map((x) => x.toGptMap).toList(),
  };
  var response = await httpClient.post(
    'https://api.openai.com/v1/threads',
    data: payload,
  );
  Map<String, dynamic> data = response.data;
  return Conversation.fromMap(data);
}