create method

CREATE MESSAGE WITHIN A THREAD

Implementation

Future<ThreadMessageModel?> create(CreateThreadMessageModel message)async{
  Internet net = Internet();
  try{
    var data = {
      "role" : message.role != "user" ? "user" : message.role,
      "content" : message.content
    };
    var res = await net.openAIAssitant(data, "threads/${message.threadId}", apiKey);

    if(res.statusCode == 200){
      var r = ThreadMessageModel.fromJson(jsonDecode(res.body));
      return r;
    }else{
      return null;
    }
  }catch(e){
    if (kDebugMode) {
      print(e.toString());
    }
    return null;
  }
}