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 · modeblame

2ab1a942Jose Arriaga Maldonado1 years ago1using System;
5dce104aJose Arriaga Maldonado1 years ago2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.ComponentModel;
5using System.Diagnostics.CodeAnalysis;
6using System.Text.Json;
2ab1a942Jose Arriaga Maldonado1 years ago7
9f9f2936Jose Arriaga Maldonado2 years ago8namespace OpenAI.Files;
9
0ca4c062Jose Arriaga Maldonado1 years ago10[CodeGenType("OpenAIFile")]
19ceae44ShivangiReja1 years ago11public partial class OpenAIFile
9f9f2936Jose Arriaga Maldonado2 years ago12{
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 ago15private string Object { get; } = "file";
9f9f2936Jose Arriaga Maldonado2 years ago16
5dce104aJose Arriaga Maldonado1 years ago17// CUSTOM:
18// - Added Experimental attribute.
19// - Renamed.
20/// <summary> The size of the file, in bytes. </summary>
21[Experimental("OPENAI001")]
9f9f2936Jose Arriaga Maldonado2 years ago22[CodeGenMember("Bytes")]
5dce104aJose Arriaga Maldonado1 years ago23public 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)]
37public int? SizeInBytes => SizeInBytesLong is null ? null : checked((int)SizeInBytesLong.Value);
2ab1a942Jose Arriaga Maldonado1 years ago38
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 ago43public FileStatus Status { get; }
2ab1a942Jose Arriaga Maldonado1 years ago44
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.")]
48public string StatusDetails { get; }
5dce104aJose Arriaga Maldonado1 years ago49
50internal static OpenAIFile FromClientResult(ClientResult result)
51{
52using PipelineResponse response = result.GetRawResponse();
53using JsonDocument document = JsonDocument.Parse(response.Content);
54return DeserializeOpenAIFile(document.RootElement, ModelSerializationExtensions.WireOptions);
55}
9f9f2936Jose Arriaga Maldonado2 years ago56}