openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Files/OpenAIFile.cs
56lines · modeblame
2ab1a942Jose Arriaga Maldonado1 years ago | 1 | using System; |
5dce104aJose Arriaga Maldonado1 years ago | 2 | using System.ClientModel; |
| 3 | using System.ClientModel.Primitives; | |
| 4 | using System.ComponentModel; | |
| 5 | using System.Diagnostics.CodeAnalysis; | |
| 6 | using System.Text.Json; | |
2ab1a942Jose Arriaga Maldonado1 years ago | 7 | |
9f9f2936Jose Arriaga Maldonado2 years ago | 8 | namespace OpenAI.Files; |
| 9 | | |
0ca4c062Jose Arriaga Maldonado1 years ago | 10 | [CodeGenType("OpenAIFile")] |
19ceae44ShivangiReja1 years ago | 11 | public partial class OpenAIFile |
9f9f2936Jose Arriaga Maldonado2 years ago | 12 | { |
| 13 | // CUSTOM: Made private. This property does not add value in the context of a strongly-typed class. | |
| 14 | /// <summary> The object type, which is always "file". </summary> | |
5dce104aJose Arriaga Maldonado1 years ago | 15 | private string Object { get; } = "file"; |
9f9f2936Jose Arriaga Maldonado2 years ago | 16 | |
5dce104aJose Arriaga Maldonado1 years ago | 17 | // CUSTOM: |
| 18 | // - Added Experimental attribute. | |
| 19 | // - Renamed. | |
| 20 | /// <summary> The size of the file, in bytes. </summary> | |
| 21 | [Experimental("OPENAI001")] | |
9f9f2936Jose Arriaga Maldonado2 years ago | 22 | [CodeGenMember("Bytes")] |
5dce104aJose Arriaga Maldonado1 years ago | 23 | public long? SizeInBytesLong { get; } |
| 24 | | |
| 25 | /// <summary> | |
| 26 | /// <para> | |
| 27 | /// <b>Please use <see cref="SizeInBytesLong"/> instead of this property.</b> | |
| 28 | /// </para> | |
| 29 | /// A backwards-compatible facade for <see cref="SizeInBytesLong"/>. | |
| 30 | /// </summary> | |
| 31 | /// <remarks> | |
| 32 | /// This property will throw an <see cref="OverflowException"/> if the reported file size exceeds the maximum value | |
| 33 | /// of a 32-bit integer, approximately 2GB. The newer <see cref="SizeInBytesLong"/> property addresses this | |
| 34 | /// limitation and should always be used. | |
| 35 | /// </remarks> | |
| 36 | [EditorBrowsable(EditorBrowsableState.Never)] | |
| 37 | public int? SizeInBytes => SizeInBytesLong is null ? null : checked((int)SizeInBytesLong.Value); | |
2ab1a942Jose Arriaga Maldonado1 years ago | 38 | |
| 39 | // CUSTOM: Added the Obsolete attribute. | |
| 40 | [Obsolete($"This property is obsolete. If this is a fine-tuning training file, it may take some time to process" | |
| 41 | + $" after it has been uploaded. While the file is processing, you can still create a fine-tuning job but it" | |
| 42 | + $" will not start until the file processing has completed.")] | |
a330c2e7Jose Arriaga Maldonado1 years ago | 43 | public FileStatus Status { get; } |
2ab1a942Jose Arriaga Maldonado1 years ago | 44 | |
| 45 | // CUSTOM: Added the Obsolete attribute. | |
| 46 | [Obsolete($"This property is obsolete. For details on why a fine-tuning training file failed validation, see the" | |
| 47 | + $" `error` field on the fine-tuning job.")] | |
| 48 | public string StatusDetails { get; } | |
5dce104aJose Arriaga Maldonado1 years ago | 49 | |
| 50 | internal static OpenAIFile FromClientResult(ClientResult result) | |
| 51 | { | |
| 52 | using PipelineResponse response = result.GetRawResponse(); | |
| 53 | using JsonDocument document = JsonDocument.Parse(response.Content); | |
| 54 | return DeserializeOpenAIFile(document.RootElement, ModelSerializationExtensions.WireOptions); | |
| 55 | } | |
9f9f2936Jose Arriaga Maldonado2 years ago | 56 | } |