openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.2.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/Custom/Files/OpenAIFile.cs

56lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.ComponentModel;
5using System.Diagnostics.CodeAnalysis;
6using System.Text.Json;
7
8namespace OpenAI.Files;
9
10[CodeGenType("OpenAIFile")]
11public partial class OpenAIFile
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>
15 private string Object { get; } = "file";
16
17 // CUSTOM:
18 // - Added Experimental attribute.
19 // - Renamed.
20 /// <summary> The size of the file, in bytes. </summary>
21 [Experimental("OPENAI001")]
22 [CodeGenMember("Bytes")]
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);
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.")]
43 public FileStatus Status { get; }
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; }
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 }
56}
57