openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/FineTuning/FineTuningClient.Protocol.cs
267lines · modecode
| 1 | using System; |
| 2 | using System.ClientModel; |
| 3 | using System.ClientModel.Primitives; |
| 4 | using System.Threading.Tasks; |
| 5 | |
| 6 | namespace OpenAI.FineTuning; |
| 7 | |
| 8 | [CodeGenSuppress("CreateFineTuningJobAsync", typeof(BinaryContent), typeof(RequestOptions))] |
| 9 | [CodeGenSuppress("CreateFineTuningJob", typeof(BinaryContent), typeof(RequestOptions))] |
| 10 | [CodeGenSuppress("GetPaginatedFineTuningJobsAsync", typeof(string), typeof(int?), typeof(RequestOptions))] |
| 11 | [CodeGenSuppress("GetPaginatedFineTuningJobs", typeof(string), typeof(int?), typeof(RequestOptions))] |
| 12 | [CodeGenSuppress("RetrieveFineTuningJobAsync", typeof(string), typeof(RequestOptions))] |
| 13 | [CodeGenSuppress("RetrieveFineTuningJob", typeof(string), typeof(RequestOptions))] |
| 14 | [CodeGenSuppress("CancelFineTuningJobAsync", typeof(string), typeof(RequestOptions))] |
| 15 | [CodeGenSuppress("CancelFineTuningJob", typeof(string), typeof(RequestOptions))] |
| 16 | [CodeGenSuppress("GetFineTuningEventsAsync", typeof(string), typeof(string), typeof(int?), typeof(RequestOptions))] |
| 17 | [CodeGenSuppress("GetFineTuningEvents", typeof(string), typeof(string), typeof(int?), typeof(RequestOptions))] |
| 18 | [CodeGenSuppress("GetFineTuningJobCheckpointsAsync", typeof(string), typeof(string), typeof(int?), typeof(RequestOptions))] |
| 19 | [CodeGenSuppress("GetFineTuningJobCheckpoints", typeof(string), typeof(string), typeof(int?), typeof(RequestOptions))] |
| 20 | public partial class FineTuningClient |
| 21 | { |
| 22 | // CUSTOM: |
| 23 | // - Renamed. |
| 24 | // - Edited doc comment. |
| 25 | /// <summary> |
| 26 | /// [Protocol Method] Creates a fine-tuning job which begins the process of creating a new model from a given dataset. |
| 27 | /// |
| 28 | /// Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. |
| 29 | /// |
| 30 | /// [Learn more about fine-tuning](/docs/guides/fine-tuning) |
| 31 | /// </summary> |
| 32 | /// <param name="content"> The content to send as the body of the request. </param> |
| 33 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 34 | /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception> |
| 35 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 36 | /// <returns> The response returned from the service. </returns> |
| 37 | public virtual async Task<ClientResult> CreateJobAsync(BinaryContent content, RequestOptions options = null) |
| 38 | { |
| 39 | Argument.AssertNotNull(content, nameof(content)); |
| 40 | |
| 41 | using PipelineMessage message = CreateCreateFineTuningJobRequest(content, options); |
| 42 | return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 43 | } |
| 44 | |
| 45 | // CUSTOM: |
| 46 | // - Renamed. |
| 47 | // - Edited doc comment. |
| 48 | /// <summary> |
| 49 | /// [Protocol Method] Creates a fine-tuning job which begins the process of creating a new model from a given dataset. |
| 50 | /// |
| 51 | /// Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. |
| 52 | /// |
| 53 | /// [Learn more about fine-tuning](/docs/guides/fine-tuning) |
| 54 | /// </summary> |
| 55 | /// <param name="content"> The content to send as the body of the request. </param> |
| 56 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 57 | /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception> |
| 58 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 59 | /// <returns> The response returned from the service. </returns> |
| 60 | public virtual ClientResult CreateJob(BinaryContent content, RequestOptions options = null) |
| 61 | { |
| 62 | Argument.AssertNotNull(content, nameof(content)); |
| 63 | |
| 64 | using PipelineMessage message = CreateCreateFineTuningJobRequest(content, options); |
| 65 | return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); |
| 66 | } |
| 67 | |
| 68 | // CUSTOM: |
| 69 | // - Renamed. |
| 70 | // - Edited doc comment. |
| 71 | /// <summary> |
| 72 | /// [Protocol Method] List your organization's fine-tuning jobs |
| 73 | /// </summary> |
| 74 | /// <param name="after"> Identifier for the last job from the previous pagination request. </param> |
| 75 | /// <param name="limit"> Number of fine-tuning jobs to retrieve. </param> |
| 76 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 77 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 78 | /// <returns> The response returned from the service. </returns> |
| 79 | public virtual async Task<ClientResult> GetJobsAsync(string after, int? limit, RequestOptions options) |
| 80 | { |
| 81 | using PipelineMessage message = CreateGetPaginatedFineTuningJobsRequest(after, limit, options); |
| 82 | return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 83 | } |
| 84 | |
| 85 | // CUSTOM: |
| 86 | // - Renamed. |
| 87 | // - Edited doc comment. |
| 88 | /// <summary> |
| 89 | /// [Protocol Method] List your organization's fine-tuning jobs |
| 90 | /// </summary> |
| 91 | /// <param name="after"> Identifier for the last job from the previous pagination request. </param> |
| 92 | /// <param name="limit"> Number of fine-tuning jobs to retrieve. </param> |
| 93 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 94 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 95 | /// <returns> The response returned from the service. </returns> |
| 96 | public virtual ClientResult GetJobs(string after, int? limit, RequestOptions options) |
| 97 | { |
| 98 | using PipelineMessage message = CreateGetPaginatedFineTuningJobsRequest(after, limit, options); |
| 99 | return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); |
| 100 | } |
| 101 | |
| 102 | // CUSTOM: |
| 103 | // - Renamed. |
| 104 | // - Edited doc comment. |
| 105 | /// <summary> |
| 106 | /// [Protocol Method] Get info about a fine-tuning job. |
| 107 | /// |
| 108 | /// [Learn more about fine-tuning](/docs/guides/fine-tuning) |
| 109 | /// </summary> |
| 110 | /// <param name="jobId"> The ID of the fine-tuning job. </param> |
| 111 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 112 | /// <exception cref="ArgumentNullException"> <paramref name="jobId"/> is null. </exception> |
| 113 | /// <exception cref="ArgumentException"> <paramref name="jobId"/> is an empty string, and was expected to be non-empty. </exception> |
| 114 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 115 | /// <returns> The response returned from the service. </returns> |
| 116 | public virtual async Task<ClientResult> GetJobAsync(string jobId, RequestOptions options) |
| 117 | { |
| 118 | Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); |
| 119 | |
| 120 | using PipelineMessage message = CreateRetrieveFineTuningJobRequest(jobId, options); |
| 121 | return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 122 | } |
| 123 | |
| 124 | // CUSTOM: |
| 125 | // - Renamed. |
| 126 | // - Edited doc comment. |
| 127 | /// <summary> |
| 128 | /// [Protocol Method] Get info about a fine-tuning job. |
| 129 | /// |
| 130 | /// [Learn more about fine-tuning](/docs/guides/fine-tuning) |
| 131 | /// </summary> |
| 132 | /// <param name="jobId"> The ID of the fine-tuning job. </param> |
| 133 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 134 | /// <exception cref="ArgumentNullException"> <paramref name="jobId"/> is null. </exception> |
| 135 | /// <exception cref="ArgumentException"> <paramref name="jobId"/> is an empty string, and was expected to be non-empty. </exception> |
| 136 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 137 | /// <returns> The response returned from the service. </returns> |
| 138 | public virtual ClientResult GetJob(string jobId, RequestOptions options) |
| 139 | { |
| 140 | Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); |
| 141 | |
| 142 | using PipelineMessage message = CreateRetrieveFineTuningJobRequest(jobId, options); |
| 143 | return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); |
| 144 | } |
| 145 | |
| 146 | // CUSTOM: |
| 147 | // - Renamed. |
| 148 | // - Edited doc comment. |
| 149 | /// <summary> |
| 150 | /// [Protocol Method] Immediately cancel a fine-tune job. |
| 151 | /// </summary> |
| 152 | /// <param name="jobId"> The ID of the fine-tuning job to cancel. </param> |
| 153 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 154 | /// <exception cref="ArgumentNullException"> <paramref name="jobId"/> is null. </exception> |
| 155 | /// <exception cref="ArgumentException"> <paramref name="jobId"/> is an empty string, and was expected to be non-empty. </exception> |
| 156 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 157 | /// <returns> The response returned from the service. </returns> |
| 158 | public virtual async Task<ClientResult> CancelJobAsync(string jobId, RequestOptions options) |
| 159 | { |
| 160 | Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); |
| 161 | |
| 162 | using PipelineMessage message = CreateCancelFineTuningJobRequest(jobId, options); |
| 163 | return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 164 | } |
| 165 | |
| 166 | // CUSTOM: |
| 167 | // - Renamed. |
| 168 | // - Edited doc comment. |
| 169 | /// <summary> |
| 170 | /// [Protocol Method] Immediately cancel a fine-tune job. |
| 171 | /// </summary> |
| 172 | /// <param name="jobId"> The ID of the fine-tuning job to cancel. </param> |
| 173 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 174 | /// <exception cref="ArgumentNullException"> <paramref name="jobId"/> is null. </exception> |
| 175 | /// <exception cref="ArgumentException"> <paramref name="jobId"/> is an empty string, and was expected to be non-empty. </exception> |
| 176 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 177 | /// <returns> The response returned from the service. </returns> |
| 178 | public virtual ClientResult CancelJob(string jobId, RequestOptions options) |
| 179 | { |
| 180 | Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); |
| 181 | |
| 182 | using PipelineMessage message = CreateCancelFineTuningJobRequest(jobId, options); |
| 183 | return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); |
| 184 | } |
| 185 | |
| 186 | // CUSTOM: |
| 187 | // - Renamed. |
| 188 | // - Edited doc comment. |
| 189 | /// <summary> |
| 190 | /// [Protocol Method] Get status updates for a fine-tuning job. |
| 191 | /// </summary> |
| 192 | /// <param name="jobId"> The ID of the fine-tuning job to get events for. </param> |
| 193 | /// <param name="after"> Identifier for the last event from the previous pagination request. </param> |
| 194 | /// <param name="limit"> Number of events to retrieve. </param> |
| 195 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 196 | /// <exception cref="ArgumentNullException"> <paramref name="jobId"/> is null. </exception> |
| 197 | /// <exception cref="ArgumentException"> <paramref name="jobId"/> is an empty string, and was expected to be non-empty. </exception> |
| 198 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 199 | /// <returns> The response returned from the service. </returns> |
| 200 | public virtual async Task<ClientResult> GetJobEventsAsync(string jobId, string after, int? limit, RequestOptions options) |
| 201 | { |
| 202 | Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); |
| 203 | |
| 204 | using PipelineMessage message = CreateGetFineTuningEventsRequest(jobId, after, limit, options); |
| 205 | return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 206 | } |
| 207 | |
| 208 | // CUSTOM: |
| 209 | // - Renamed. |
| 210 | // - Edited doc comment. |
| 211 | /// <summary> |
| 212 | /// [Protocol Method] Get status updates for a fine-tuning job. |
| 213 | /// </summary> |
| 214 | /// <param name="jobId"> The ID of the fine-tuning job to get events for. </param> |
| 215 | /// <param name="after"> Identifier for the last event from the previous pagination request. </param> |
| 216 | /// <param name="limit"> Number of events to retrieve. </param> |
| 217 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 218 | /// <exception cref="ArgumentNullException"> <paramref name="jobId"/> is null. </exception> |
| 219 | /// <exception cref="ArgumentException"> <paramref name="jobId"/> is an empty string, and was expected to be non-empty. </exception> |
| 220 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 221 | /// <returns> The response returned from the service. </returns> |
| 222 | public virtual ClientResult GetJobEvents(string jobId, string after, int? limit, RequestOptions options) |
| 223 | { |
| 224 | Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); |
| 225 | |
| 226 | using PipelineMessage message = CreateGetFineTuningEventsRequest(jobId, after, limit, options); |
| 227 | return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); |
| 228 | } |
| 229 | |
| 230 | /// <summary> |
| 231 | /// [Protocol Method] List the checkpoints for a fine-tuning job. |
| 232 | /// </summary> |
| 233 | /// <param name="fineTuningJobId"> The ID of the fine-tuning job to get checkpoints for. </param> |
| 234 | /// <param name="after"> Identifier for the last checkpoint ID from the previous pagination request. </param> |
| 235 | /// <param name="limit"> Number of checkpoints to retrieve. </param> |
| 236 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 237 | /// <exception cref="ArgumentNullException"> <paramref name="fineTuningJobId"/> is null. </exception> |
| 238 | /// <exception cref="ArgumentException"> <paramref name="fineTuningJobId"/> is an empty string, and was expected to be non-empty. </exception> |
| 239 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 240 | /// <returns> The response returned from the service. </returns> |
| 241 | public virtual async Task<ClientResult> GetJobCheckpointsAsync(string fineTuningJobId, string after, int? limit, RequestOptions options) |
| 242 | { |
| 243 | Argument.AssertNotNullOrEmpty(fineTuningJobId, nameof(fineTuningJobId)); |
| 244 | |
| 245 | using PipelineMessage message = CreateGetFineTuningJobCheckpointsRequest(fineTuningJobId, after, limit, options); |
| 246 | return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 247 | } |
| 248 | |
| 249 | /// <summary> |
| 250 | /// [Protocol Method] List the checkpoints for a fine-tuning job. |
| 251 | /// </summary> |
| 252 | /// <param name="fineTuningJobId"> The ID of the fine-tuning job to get checkpoints for. </param> |
| 253 | /// <param name="after"> Identifier for the last checkpoint ID from the previous pagination request. </param> |
| 254 | /// <param name="limit"> Number of checkpoints to retrieve. </param> |
| 255 | /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 256 | /// <exception cref="ArgumentNullException"> <paramref name="fineTuningJobId"/> is null. </exception> |
| 257 | /// <exception cref="ArgumentException"> <paramref name="fineTuningJobId"/> is an empty string, and was expected to be non-empty. </exception> |
| 258 | /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception> |
| 259 | /// <returns> The response returned from the service. </returns> |
| 260 | public virtual ClientResult GetJobCheckpoints(string fineTuningJobId, string after, int? limit, RequestOptions options) |
| 261 | { |
| 262 | Argument.AssertNotNullOrEmpty(fineTuningJobId, nameof(fineTuningJobId)); |
| 263 | |
| 264 | using PipelineMessage message = CreateGetFineTuningJobCheckpointsRequest(fineTuningJobId, after, limit, options); |
| 265 | return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); |
| 266 | } |
| 267 | } |
| 268 | |