openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Files/Internal/InternalFileUploadOptions.cs
42lines · modeblame
9f9f2936Jose Arriaga Maldonado2 years ago | 1 | using System.IO; |
| 2 | | |
| 3 | namespace OpenAI.Files; | |
| 4 | | |
| 5 | [CodeGenModel("CreateFileRequest")] | |
| 6 | [CodeGenSuppress("InternalFileUploadOptions", typeof(Stream), typeof(FileUploadPurpose))] | |
| 7 | internal partial class InternalFileUploadOptions | |
| 8 | { | |
| 9 | // CUSTOM: | |
| 10 | // - Made internal. This value comes from a parameter on the client method. | |
| 11 | // - Added setter. | |
| 12 | /// <summary> The file object (not file name) to be uploaded. </summary> | |
| 13 | internal Stream File { get; set; } | |
| 14 | | |
| 15 | // CUSTOM: | |
| 16 | // - Made internal. This value comes from a parameter on the client method. | |
| 17 | // - Added setter. | |
| 18 | /// <summary> | |
| 19 | /// The intended purpose of the uploaded file. Use "fine-tune" for | |
| 20 | /// [Fine-tuning](/docs/api-reference/fine-tuning) and "assistants" for | |
| 21 | /// [Assistants](/docs/api-reference/assistants) and [Messages](/docs/api-reference/messages). This | |
| 22 | /// allows us to validate the format of the uploaded file is correct for fine-tuning. | |
| 23 | /// </summary> | |
| 24 | internal FileUploadPurpose Purpose { get; set; } | |
| 25 | | |
| 26 | // CUSTOM: Made public now that there are no required properties. | |
| 27 | /// <summary> Initializes a new instance of <see cref="InternalFileUploadOptions"/> for deserialization. </summary> | |
| 28 | public InternalFileUploadOptions() | |
| 29 | { | |
| 30 | } | |
| 31 | | |
| 32 | internal MultipartFormDataBinaryContent ToMultipartContent(Stream file, string filename) | |
| 33 | { | |
| 34 | MultipartFormDataBinaryContent content = new(); | |
| 35 | | |
| 36 | content.Add(file, "file", filename); | |
| 37 | | |
| 38 | content.Add(Purpose.ToString(), "purpose"); | |
| 39 | | |
| 40 | return content; | |
| 41 | } | |
| 42 | } |