openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Files/OpenAIFileClient.Protocol.cs

137lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.ComponentModel;
5using System.Diagnostics.CodeAnalysis;
6using System.Threading.Tasks;
7
8namespace OpenAI.Files;
9
10public partial class OpenAIFileClient
11{
12 /// <summary>
13 /// [Protocol Method] Creates an intermediate upload to which data can be added in chunks of bytes. An upload
14 /// can accept at most 8 GB in total and expires an hour after it is created.
15 /// </summary>
16 /// <param name="content"> The content to send as the body of the request. </param>
17 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
18 /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
19 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
20 /// <returns> The response returned from the service. </returns>
21 [Experimental("OPENAI001")]
22 public virtual async Task<ClientResult> CreateUploadAsync(BinaryContent content, RequestOptions options = null)
23 {
24 return await _internalUploadsClient.CreateUploadAsync(content, options).ConfigureAwait(false);
25 }
26
27 /// <summary>
28 /// [Protocol Method] Creates an intermediate upload to which data can be added in chunks of bytes. An upload
29 /// can accept at most 8 GB in total and expires an hour after it is created.
30 /// </summary>
31 /// <param name="content"> The content to send as the body of the request. </param>
32 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
33 /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
34 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
35 /// <returns> The response returned from the service. </returns>
36 [Experimental("OPENAI001")]
37 public virtual ClientResult CreateUpload(BinaryContent content, RequestOptions options = null)
38 {
39 return _internalUploadsClient.CreateUpload(content, options);
40 }
41
42 /// <summary>
43 /// [Protocol Method] Adds a chunk of bytes to an existing upload. Each part can contain at most 64 MB, while the
44 /// upload can accept at most 8 GB in total.
45 /// </summary>
46 /// <param name="uploadId"> The ID of the upload. </param>
47 /// <param name="content"> The content to send as the body of the request. </param>
48 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
49 /// <exception cref="ArgumentNullException"> <paramref name="uploadId"/> or <paramref name="content"/> is null. </exception>
50 /// <exception cref="ArgumentException"> <paramref name="uploadId"/> is an empty string, and was expected to be non-empty. </exception>
51 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
52 /// <returns> The response returned from the service. </returns>
53 [Experimental("OPENAI001")]
54 public virtual async Task<ClientResult> AddUploadPartAsync(string uploadId, BinaryContent content, string contentType, RequestOptions options = null)
55 {
56 return await _internalUploadsClient.AddUploadPartAsync(uploadId, content, contentType, options).ConfigureAwait(false);
57 }
58
59 /// <summary>
60 /// [Protocol Method] Adds a chunk of bytes to an existing upload. Each part can contain at most 64 MB, while the
61 /// upload can accept at most 8 GB in total.
62 /// </summary>
63 /// <param name="uploadId"> The ID of the upload. </param>
64 /// <param name="content"> The content to send as the body of the request. </param>
65 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
66 /// <exception cref="ArgumentNullException"> <paramref name="uploadId"/> or <paramref name="content"/> is null. </exception>
67 /// <exception cref="ArgumentException"> <paramref name="uploadId"/> is an empty string, and was expected to be non-empty. </exception>
68 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
69 /// <returns> The response returned from the service. </returns>
70 [Experimental("OPENAI001")]
71 public virtual ClientResult AddUploadPart(string uploadId, BinaryContent content, string contentType, RequestOptions options = null)
72 {
73 return _internalUploadsClient.AddUploadPart(uploadId, content, contentType, options);
74 }
75
76 /// <summary>
77 /// [Protocol Method] Completes an existing upload, creating a file ready to use.
78 /// </summary>
79 /// <param name="uploadId"> The ID of the upload. </param>
80 /// <param name="content"> The content to send as the body of the request. </param>
81 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
82 /// <exception cref="ArgumentNullException"> <paramref name="uploadId"/> or <paramref name="content"/> is null. </exception>
83 /// <exception cref="ArgumentException"> <paramref name="uploadId"/> is an empty string, and was expected to be non-empty. </exception>
84 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
85 /// <returns> The response returned from the service. </returns>
86 [Experimental("OPENAI001")]
87 public virtual async Task<ClientResult> CompleteUploadAsync(string uploadId, BinaryContent content, RequestOptions options = null)
88 {
89 return await _internalUploadsClient.CompleteUploadAsync(uploadId, content, options).ConfigureAwait(false);
90 }
91
92 /// <summary>
93 /// [Protocol Method] Completes an existing upload, creating a file ready to use.
94 /// </summary>
95 /// <param name="uploadId"> The ID of the upload. </param>
96 /// <param name="content"> The content to send as the body of the request. </param>
97 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
98 /// <exception cref="ArgumentNullException"> <paramref name="uploadId"/> or <paramref name="content"/> is null. </exception>
99 /// <exception cref="ArgumentException"> <paramref name="uploadId"/> is an empty string, and was expected to be non-empty. </exception>
100 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
101 /// <returns> The response returned from the service. </returns>
102 [Experimental("OPENAI001")]
103 public virtual ClientResult CompleteUpload(string uploadId, BinaryContent content, RequestOptions options = null)
104 {
105 return _internalUploadsClient.CompleteUpload(uploadId, content, options);
106 }
107
108 /// <summary>
109 /// [Protocol Method] Cancels an existing upload.
110 /// </summary>
111 /// <param name="uploadId"> The ID of the upload. </param>
112 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
113 /// <exception cref="ArgumentNullException"> <paramref name="uploadId"/> is null. </exception>
114 /// <exception cref="ArgumentException"> <paramref name="uploadId"/> is an empty string, and was expected to be non-empty. </exception>
115 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
116 /// <returns> The response returned from the service. </returns>
117 [Experimental("OPENAI001")]
118 public virtual async Task<ClientResult> CancelUploadAsync(string uploadId, RequestOptions options = null)
119 {
120 return await _internalUploadsClient.CancelUploadAsync(uploadId, options).ConfigureAwait(false);
121 }
122
123 /// <summary>
124 /// [Protocol Method] Cancels an existing upload.
125 /// </summary>
126 /// <param name="uploadId"> The ID of the upload. </param>
127 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
128 /// <exception cref="ArgumentNullException"> <paramref name="uploadId"/> is null. </exception>
129 /// <exception cref="ArgumentException"> <paramref name="uploadId"/> is an empty string, and was expected to be non-empty. </exception>
130 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
131 /// <returns> The response returned from the service. </returns>
132 [Experimental("OPENAI001")]
133 public virtual ClientResult CancelUpload(string uploadId, RequestOptions options = null)
134 {
135 return _internalUploadsClient.CancelUpload(uploadId, options);
136 }
137}
138