openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/FineTuning/FineTuningClient.cs
85lines · modeblame
58f93c8dShivangiReja2 years ago | 1 | using System; |
9f9f2936Jose Arriaga Maldonado2 years ago | 2 | using System.ClientModel; |
| 3 | using System.ClientModel.Primitives; | |
0f5e0249ShivangiReja1 years ago | 4 | using System.Diagnostics.CodeAnalysis; |
e0fee603Jose Arriaga Maldonado1 years ago | 5 | using System.Threading; |
9f9f2936Jose Arriaga Maldonado2 years ago | 6 | |
| 7 | namespace OpenAI.FineTuning; | |
| 8 | | |
13a9c686Jose Arriaga Maldonado1 years ago | 9 | // CUSTOM: |
| 10 | // - Renamed. | |
| 11 | // - Suppressed constructor that takes endpoint parameter; endpoint is now a property in the options class. | |
| 12 | // - Suppressed convenience methods for now. | |
| 13 | /// <summary> The service client for OpenAI fine-tuning operations. </summary> | |
0f5e0249ShivangiReja1 years ago | 14 | [Experimental("OPENAI001")] |
0ca4c062Jose Arriaga Maldonado1 years ago | 15 | [CodeGenType("FineTuning")] |
| 16 | [CodeGenSuppress("FineTuningClient", typeof(ClientPipeline), typeof(Uri))] | |
e0fee603Jose Arriaga Maldonado1 years ago | 17 | [CodeGenSuppress("CreateFineTuningJobAsync", typeof(FineTuningOptions), typeof(CancellationToken))] |
| 18 | [CodeGenSuppress("CreateFineTuningJob", typeof(FineTuningOptions), typeof(CancellationToken))] | |
| 19 | [CodeGenSuppress("ListPaginatedFineTuningJobsAsync", typeof(string), typeof(int?), typeof(CancellationToken))] | |
| 20 | [CodeGenSuppress("ListPaginatedFineTuningJobs", typeof(string), typeof(int?), typeof(CancellationToken))] | |
| 21 | [CodeGenSuppress("RetrieveFineTuningJobAsync", typeof(string), typeof(CancellationToken))] | |
| 22 | [CodeGenSuppress("RetrieveFineTuningJob", typeof(string), typeof(CancellationToken))] | |
| 23 | [CodeGenSuppress("CancelFineTuningJobAsync", typeof(string), typeof(CancellationToken))] | |
| 24 | [CodeGenSuppress("CancelFineTuningJob", typeof(string), typeof(CancellationToken))] | |
| 25 | [CodeGenSuppress("ListFineTuningEventsAsync", typeof(string), typeof(string), typeof(int?), typeof(CancellationToken))] | |
| 26 | [CodeGenSuppress("ListFineTuningEvents", typeof(string), typeof(string), typeof(int?), typeof(CancellationToken))] | |
| 27 | [CodeGenSuppress("ListFineTuningJobCheckpointsAsync", typeof(string), typeof(string), typeof(int?), typeof(CancellationToken))] | |
| 28 | [CodeGenSuppress("ListFineTuningJobCheckpoints", typeof(string), typeof(string), typeof(int?), typeof(CancellationToken))] | |
9f9f2936Jose Arriaga Maldonado2 years ago | 29 | public partial class FineTuningClient |
| 30 | { | |
2ab1a942Jose Arriaga Maldonado1 years ago | 31 | // CUSTOM: Added as a convenience. |
e0fee603Jose Arriaga Maldonado1 years ago | 32 | /// <summary> Initializes a new instance of <see cref="FineTuningClient"/>. </summary> |
2ab1a942Jose Arriaga Maldonado1 years ago | 33 | /// <param name="apiKey"> The API key to authenticate with the service. </param> |
| 34 | /// <exception cref="ArgumentNullException"> <paramref name="apiKey"/> is null. </exception> | |
| 35 | public FineTuningClient(string apiKey) : this(new ApiKeyCredential(apiKey), new OpenAIClientOptions()) | |
| 36 | { | |
| 37 | } | |
| 38 | | |
13a9c686Jose Arriaga Maldonado1 years ago | 39 | // CUSTOM: |
| 40 | // - Used a custom pipeline. | |
| 41 | // - Demoted the endpoint parameter to be a property in the options class. | |
e0fee603Jose Arriaga Maldonado1 years ago | 42 | /// <summary> Initializes a new instance of <see cref="FineTuningClient"/>. </summary> |
13a9c686Jose Arriaga Maldonado1 years ago | 43 | /// <param name="credential"> The API key to authenticate with the service. </param> |
| 44 | /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception> | |
| 45 | public FineTuningClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) | |
| 46 | { | |
| 47 | } | |
9f9f2936Jose Arriaga Maldonado2 years ago | 48 | |
a330c2e7Jose Arriaga Maldonado1 years ago | 49 | /// <summary> |
| 50 | /// Initializes a new instance of <see cref="FineTuningClient"/> that will use an API key when authenticating. | |
| 51 | /// </summary> | |
| 52 | /// <param name="credential"> The API key used to authenticate with the service endpoint. </param> | |
| 53 | /// <param name="options"> Additional options to customize the client. </param> | |
| 54 | /// <exception cref="ArgumentNullException"> The provided <paramref name="credential"/> was null. </exception> | |
13a9c686Jose Arriaga Maldonado1 years ago | 55 | public FineTuningClient(ApiKeyCredential credential, OpenAIClientOptions options) |
| 56 | { | |
| 57 | Argument.AssertNotNull(credential, nameof(credential)); | |
| 58 | options ??= new OpenAIClientOptions(); | |
9f9f2936Jose Arriaga Maldonado2 years ago | 59 | |
e0fee603Jose Arriaga Maldonado1 years ago | 60 | Pipeline = OpenAIClient.CreatePipeline(credential, options); |
13a9c686Jose Arriaga Maldonado1 years ago | 61 | _endpoint = OpenAIClient.GetEndpoint(options); |
| 62 | } | |
9f9f2936Jose Arriaga Maldonado2 years ago | 63 | |
13a9c686Jose Arriaga Maldonado1 years ago | 64 | // CUSTOM: |
| 65 | // - Used a custom pipeline. | |
| 66 | // - Demoted the endpoint parameter to be a property in the options class. | |
| 67 | // - Made protected. | |
e0fee603Jose Arriaga Maldonado1 years ago | 68 | /// <summary> Initializes a new instance of <see cref="FineTuningClient"/>. </summary> |
13a9c686Jose Arriaga Maldonado1 years ago | 69 | /// <param name="pipeline"> The HTTP pipeline to send and receive REST requests and responses. </param> |
| 70 | /// <param name="options"> The options to configure the client. </param> | |
| 71 | /// <exception cref="ArgumentNullException"> <paramref name="pipeline"/> is null. </exception> | |
| 72 | protected internal FineTuningClient(ClientPipeline pipeline, OpenAIClientOptions options) | |
9f9f2936Jose Arriaga Maldonado2 years ago | 73 | { |
13a9c686Jose Arriaga Maldonado1 years ago | 74 | Argument.AssertNotNull(pipeline, nameof(pipeline)); |
| 75 | options ??= new OpenAIClientOptions(); | |
| 76 | | |
e0fee603Jose Arriaga Maldonado1 years ago | 77 | Pipeline = pipeline; |
13a9c686Jose Arriaga Maldonado1 years ago | 78 | _endpoint = OpenAIClient.GetEndpoint(options); |
9f9f2936Jose Arriaga Maldonado2 years ago | 79 | } |
a330c2e7Jose Arriaga Maldonado1 years ago | 80 | |
| 81 | internal virtual FineTuningJobOperation CreateCreateJobOperation(string jobId, string status, PipelineResponse response) | |
| 82 | { | |
e0fee603Jose Arriaga Maldonado1 years ago | 83 | return new FineTuningJobOperation(Pipeline, _endpoint, jobId, status, response); |
a330c2e7Jose Arriaga Maldonado1 years ago | 84 | } |
9f9f2936Jose Arriaga Maldonado2 years ago | 85 | } |