createWithMessages method

Future<ThreadModel?> createWithMessages(
  1. NewMessageThreadModel threadDetails
)

CREATE THREAD WITH MESSAGES

Implementation

Future<ThreadModel?> createWithMessages(NewMessageThreadModel threadDetails)async{
  Internet net = Internet();
  try{
    var res = await net.openAIAssitant(threadDetails.toJson(), "threads", apiKey);

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