Skip to content
Tolga Kayhan edited this page Feb 16, 2023 · 1 revision

Note: you may need to wait a bit after you upload a file. OpenAI services need to process your file.

Create a files

const string fileName = "SentimentAnalysisSample.jsonl";
var sampleFile = await File.ReadAllBytesAsync($"SampleData/{fileName}");  

var uploadFilesResponse = await sdk.Files.FileUpload(UploadFilePurposes.UploadFilePurpose.FineTune, sampleFile, fileName);

if (uploadFilesResponse.Successful)
{
   // Congrats
}

List Files

var uploadedFiles = await sdk.Files.ListFile();

foreach (var uploadedFile in uploadedFiles.Data)
{
   ConsoleExtensions.WriteLine($"File: {uploadedFile.FileName}", ConsoleColor.DarkCyan);
}

Retrieve a File

var retrieveFileResponse = await sdk.Files.RetrieveFile(uploadedFiles.Data.First().Id);

if (retrieveFileResponse.Successful)
{
   // Congrats
}

Delete a file

var deleteResponse = await sdk.Files.DeleteFile(uploadedFiles.Data.First().Id);

if (deleteResponse.Successful)
{
   // Congrats
}
Clone this wiki locally