openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
achandmsft-patch-1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Images/ImageClient.Protocol.cs

162lines · modeblame

58f93c8dShivangiReja2 years ago1using System;
9f9f2936Jose Arriaga Maldonado2 years ago2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.ComponentModel;
5using System.Threading.Tasks;
6
7namespace OpenAI.Images;
8
9[CodeGenSuppress("CreateImageAsync", typeof(BinaryContent), typeof(RequestOptions))]
10[CodeGenSuppress("CreateImage", typeof(BinaryContent), typeof(RequestOptions))]
11[CodeGenSuppress("CreateImageEditAsync", typeof(BinaryContent), typeof(string), typeof(RequestOptions))]
12[CodeGenSuppress("CreateImageEdit", typeof(BinaryContent), typeof(string), typeof(RequestOptions))]
13[CodeGenSuppress("CreateImageVariationAsync", typeof(BinaryContent), typeof(string), typeof(RequestOptions))]
14[CodeGenSuppress("CreateImageVariation", typeof(BinaryContent), typeof(string), typeof(RequestOptions))]
15public partial class ImageClient
16{
17// CUSTOM:
18// - Renamed.
19// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
20// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
21/// <summary>
22/// [Protocol Method] Generates images based on a given prompt.
23/// </summary>
24/// <param name="content"> The content to send as the body of the request. </param>
25/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
26/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
27/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
28/// <returns> The response returned from the service. </returns>
29[EditorBrowsable(EditorBrowsableState.Never)]
30public virtual async Task<ClientResult> GenerateImagesAsync(BinaryContent content, RequestOptions options = null)
31{
32Argument.AssertNotNull(content, nameof(content));
33
34using PipelineMessage message = CreateCreateImageRequest(content, options);
e0fee603Jose Arriaga Maldonado1 years ago35return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago36}
37
38// CUSTOM:
39// - Renamed.
40// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
41// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
42/// <summary>
43/// [Protocol Method] Generates images based on a given prompt.
44/// </summary>
45/// <param name="content"> The content to send as the body of the request. </param>
46/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
47/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
48/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
49/// <returns> The response returned from the service. </returns>
50[EditorBrowsable(EditorBrowsableState.Never)]
51public virtual ClientResult GenerateImages(BinaryContent content, RequestOptions options = null)
52{
53Argument.AssertNotNull(content, nameof(content));
54
55using PipelineMessage message = CreateCreateImageRequest(content, options);
e0fee603Jose Arriaga Maldonado1 years ago56return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago57}
58
59// CUSTOM:
60// - Renamed.
61// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
62// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
63// - Parametrized the Content-Type header.
64// - Added "contentType" parameter.
65/// <summary>
66/// [Protocol Method] Generates edited or extended images given an original image and a prompt.
67/// </summary>
68/// <param name="content"> The content to send as the body of the request. </param>
69/// <param name="contentType"> The content type of the request. </param>
70/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
71/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
72/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
73/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
74/// <returns> The response returned from the service. </returns>
75[EditorBrowsable(EditorBrowsableState.Never)]
76public virtual async Task<ClientResult> GenerateImageEditsAsync(BinaryContent content, string contentType, RequestOptions options = null)
77{
78Argument.AssertNotNull(content, nameof(content));
79Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
80
81using PipelineMessage message = CreateCreateImageEditRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago82return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago83}
84
85// CUSTOM:
86// - Renamed.
87// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
88// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
89// - Parametrized the Content-Type header.
90// - Added "contentType" parameter.
91/// <summary>
92/// [Protocol Method] Generates edited or extended images given an original image and a prompt.
93/// </summary>
94/// <param name="content"> The content to send as the body of the request. </param>
95/// <param name="contentType"> The content type of the request. </param>
96/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
97/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
98/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
99/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
100/// <returns> The response returned from the service. </returns>
101[EditorBrowsable(EditorBrowsableState.Never)]
102public virtual ClientResult GenerateImageEdits(BinaryContent content, string contentType, RequestOptions options = null)
103{
104Argument.AssertNotNull(content, nameof(content));
105Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
106
107using PipelineMessage message = CreateCreateImageEditRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago108return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago109}
110
111// CUSTOM:
112// - Renamed.
113// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
114// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
115// - Parametrized the Content-Type header.
116// - Added "contentType" parameter.
117/// <summary>
118/// [Protocol Method] Generates variations of a given image.
119/// </summary>
120/// <param name="content"> The content to send as the body of the request. </param>
121/// <param name="contentType"> The content type of the request. </param>
122/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
123/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
124/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
125/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
126/// <returns> The response returned from the service. </returns>
127[EditorBrowsable(EditorBrowsableState.Never)]
128public virtual async Task<ClientResult> GenerateImageVariationsAsync(BinaryContent content, string contentType, RequestOptions options = null)
129{
130Argument.AssertNotNull(content, nameof(content));
131Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
132
133using PipelineMessage message = CreateCreateImageVariationRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago134return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago135}
136
137// CUSTOM:
138// - Renamed.
139// - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
140// - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
141// - Parametrized the Content-Type header.
142// - Added "contentType" parameter.
143/// <summary>
144/// [Protocol Method] Generates variations of a given image.
145/// </summary>
146/// <param name="content"> The content to send as the body of the request. </param>
147/// <param name="contentType"> The content type of the request. </param>
148/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
149/// <exception cref="ArgumentNullException"> <paramref name="content"/> or <paramref name="contentType"/> is null. </exception>
150/// <exception cref="ArgumentException"> <paramref name="contentType"/> is an empty string, and was expected to be non-empty. </exception>
151/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
152/// <returns> The response returned from the service. </returns>
153[EditorBrowsable(EditorBrowsableState.Never)]
154public virtual ClientResult GenerateImageVariations(BinaryContent content, string contentType, RequestOptions options = null)
155{
156Argument.AssertNotNull(content, nameof(content));
157Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
158
159using PipelineMessage message = CreateCreateImageVariationRequest(content, contentType, options);
e0fee603Jose Arriaga Maldonado1 years ago160return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago161}
162}