createThreadAndRun method

Future<ThreadAndRunResponse?> createThreadAndRun(
  1. CreateThreadAndRun threadData
)

CREATE A RUN TO EXECUTE THE ASSISTANT

Implementation

Future<ThreadAndRunResponse?> createThreadAndRun(CreateThreadAndRun threadData)async{
  Internet net = Internet();
  try{
    var data = {
      "assistant_id" : threadData.assistantId,
      "thread" : threadData.thread,
      "model" : threadData.model,
      "instructions" : threadData.instructions,
      "tools" : threadData.tools,
      "metadata" : threadData.metadata
    };
    var res = await net.openAIAssitant(data, "threads/runs", apiKey);

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