openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/FineTuning/FineTuningClient.cs
65lines · modecode
| 1 | using System; |
| 2 | using System.ClientModel; |
| 3 | using System.ClientModel.Primitives; |
| 4 | |
| 5 | namespace OpenAI.FineTuning; |
| 6 | |
| 7 | /// <summary> |
| 8 | /// The service client for OpenAI fine-tuning operations. |
| 9 | /// </summary> |
| 10 | [CodeGenClient("FineTuning")] |
| 11 | [CodeGenSuppress("CreateFineTuningJobAsync", typeof(InternalCreateFineTuningJobRequest))] |
| 12 | [CodeGenSuppress("CreateFineTuningJob", typeof(InternalCreateFineTuningJobRequest))] |
| 13 | [CodeGenSuppress("GetPaginatedFineTuningJobsAsync", typeof(string), typeof(int?))] |
| 14 | [CodeGenSuppress("GetPaginatedFineTuningJobs", typeof(string), typeof(int?))] |
| 15 | [CodeGenSuppress("RetrieveFineTuningJobAsync", typeof(string))] |
| 16 | [CodeGenSuppress("RetrieveFineTuningJob", typeof(string))] |
| 17 | [CodeGenSuppress("CancelFineTuningJobAsync", typeof(string))] |
| 18 | [CodeGenSuppress("CancelFineTuningJob", typeof(string))] |
| 19 | [CodeGenSuppress("GetFineTuningEventsAsync", typeof(string), typeof(string), typeof(int?))] |
| 20 | [CodeGenSuppress("GetFineTuningEvents", typeof(string), typeof(string), typeof(int?))] |
| 21 | [CodeGenSuppress("GetFineTuningJobCheckpointsAsync", typeof(string), typeof(string), typeof(int?))] |
| 22 | [CodeGenSuppress("GetFineTuningJobCheckpoints", typeof(string), typeof(string), typeof(int?))] |
| 23 | public partial class FineTuningClient |
| 24 | { |
| 25 | // Customization: documented constructors, apply protected visibility |
| 26 | |
| 27 | /// <summary> |
| 28 | /// Initializes a new instance of <see cref="FineTuningClient"/> that will use an API key when authenticating. |
| 29 | /// </summary> |
| 30 | /// <param name="credential"> The API key used to authenticate with the service endpoint. </param> |
| 31 | /// <param name="options"> Additional options to customize the client. </param> |
| 32 | /// <exception cref="ArgumentNullException"> The provided <paramref name="credential"/> was null. </exception> |
| 33 | public FineTuningClient(ApiKeyCredential credential, OpenAIClientOptions options = null) |
| 34 | : this( |
| 35 | OpenAIClient.CreatePipeline(OpenAIClient.GetApiKey(credential, requireExplicitCredential: true), options), |
| 36 | OpenAIClient.GetEndpoint(options), |
| 37 | options) |
| 38 | { } |
| 39 | |
| 40 | /// <summary> |
| 41 | /// Initializes a new instance of <see cref="FineTuningClient"/> that will use an API key from the OPENAI_API_KEY |
| 42 | /// environment variable when authenticating. |
| 43 | /// </summary> |
| 44 | /// <remarks> |
| 45 | /// To provide an explicit credential instead of using the environment variable, use an alternate constructor like |
| 46 | /// <see cref="FineTuningClient(ApiKeyCredential,OpenAIClientOptions)"/>. |
| 47 | /// </remarks> |
| 48 | /// <param name="options"> Additional options to customize the client. </param> |
| 49 | /// <exception cref="InvalidOperationException"> The OPENAI_API_KEY environment variable was not found. </exception> |
| 50 | public FineTuningClient(OpenAIClientOptions options = null) |
| 51 | : this( |
| 52 | OpenAIClient.CreatePipeline(OpenAIClient.GetApiKey(), options), |
| 53 | OpenAIClient.GetEndpoint(options), |
| 54 | options) |
| 55 | {} |
| 56 | |
| 57 | /// <summary> Initializes a new instance of FineTuningClient. </summary> |
| 58 | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| 59 | /// <param name="endpoint"> OpenAI Endpoint. </param> |
| 60 | protected internal FineTuningClient(ClientPipeline pipeline, Uri endpoint, OpenAIClientOptions options) |
| 61 | { |
| 62 | _pipeline = pipeline; |
| 63 | _endpoint = endpoint; |
| 64 | } |
| 65 | } |
| 66 | |