openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Images/ImageClient.Protocol.cs
162lines · modecode
| 1 | using System; |
| 2 | using System.ClientModel; |
| 3 | using System.ClientModel.Primitives; |
| 4 | using System.ComponentModel; |
| 5 | using System.Threading.Tasks; |
| 6 | |
| 7 | namespace 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))] |
| 15 | public 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)] |
| 30 | public virtual async Task<ClientResult> GenerateImagesAsync(BinaryContent content, RequestOptions options = null) |
| 31 | { |
| 32 | Argument.AssertNotNull(content, nameof(content)); |
| 33 | |
| 34 | using PipelineMessage message = CreateCreateImageRequest(content, options); |
| 35 | return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 36 | } |
| 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)] |
| 51 | public virtual ClientResult GenerateImages(BinaryContent content, RequestOptions options = null) |
| 52 | { |
| 53 | Argument.AssertNotNull(content, nameof(content)); |
| 54 | |
| 55 | using PipelineMessage message = CreateCreateImageRequest(content, options); |
| 56 | return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); |
| 57 | } |
| 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)] |
| 76 | public virtual async Task<ClientResult> GenerateImageEditsAsync(BinaryContent content, string contentType, RequestOptions options = null) |
| 77 | { |
| 78 | Argument.AssertNotNull(content, nameof(content)); |
| 79 | Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); |
| 80 | |
| 81 | using PipelineMessage message = CreateCreateImageEditRequest(content, contentType, options); |
| 82 | return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 83 | } |
| 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)] |
| 102 | public virtual ClientResult GenerateImageEdits(BinaryContent content, string contentType, RequestOptions options = null) |
| 103 | { |
| 104 | Argument.AssertNotNull(content, nameof(content)); |
| 105 | Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); |
| 106 | |
| 107 | using PipelineMessage message = CreateCreateImageEditRequest(content, contentType, options); |
| 108 | return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); |
| 109 | } |
| 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)] |
| 128 | public virtual async Task<ClientResult> GenerateImageVariationsAsync(BinaryContent content, string contentType, RequestOptions options = null) |
| 129 | { |
| 130 | Argument.AssertNotNull(content, nameof(content)); |
| 131 | Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); |
| 132 | |
| 133 | using PipelineMessage message = CreateCreateImageVariationRequest(content, contentType, options); |
| 134 | return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 135 | } |
| 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)] |
| 154 | public virtual ClientResult GenerateImageVariations(BinaryContent content, string contentType, RequestOptions options = null) |
| 155 | { |
| 156 | Argument.AssertNotNull(content, nameof(content)); |
| 157 | Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); |
| 158 | |
| 159 | using PipelineMessage message = CreateCreateImageVariationRequest(content, contentType, options); |
| 160 | return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); |
| 161 | } |
| 162 | } |
| 163 | |