deleteAssistantFile method

Future<void> deleteAssistantFile({
  1. required String apiKey,
  2. required String organizationId,
  3. required String assistantId,
  4. required String fileId,
})

Implementation

Future<void> deleteAssistantFile({
  required String apiKey,
  required String organizationId,
  required String assistantId,
  required String fileId
}) async {

  Map<String, String> headers = {
    "Authorization": "Bearer $apiKey",
    "OpenAI-Organization": organizationId,
    'Content-Type': 'application/json',
    "Access-Control-Allow-Origin": "*", // Required for CORS support to work
    "OpenAI-Beta": "assistants=v1"
  };


  Uri endpoint;
  if(secure) {
    endpoint = Uri.https(
        baseUrl, "/v1/assistants/$assistantId/files/$fileId");
  }
  else {
    endpoint = Uri.http(
        baseUrl, "/v1/assistants/$assistantId/files/$fileId");
  }

  var response = await
  http.delete(endpoint, headers: headers);

  if (response.statusCode == 200 || response.statusCode == 201) {
    return ;
  }
  else {
    var error = ServerError.fromJson(jsonDecode(response.body));
    throw AssistantException(statusCode: response.statusCode, message: error.message);
  }
}