openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.0.0-beta.12

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/FineTuning/FineTuningClient.cs

89lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.Diagnostics.CodeAnalysis;
5
6namespace OpenAI.FineTuning;
7
8// CUSTOM:
9// - Renamed.
10// - Suppressed constructor that takes endpoint parameter; endpoint is now a property in the options class.
11// - Suppressed convenience methods for now.
12/// <summary> The service client for OpenAI fine-tuning operations. </summary>
13[Experimental("OPENAI001")]
14[CodeGenClient("FineTuning")]
15[CodeGenSuppress("FineTuningClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))]
16[CodeGenSuppress("CreateFineTuningJobAsync", typeof(FineTuningOptions))]
17[CodeGenSuppress("CreateFineTuningJob", typeof(FineTuningOptions))]
18[CodeGenSuppress("GetPaginatedFineTuningJobsAsync", typeof(string), typeof(int?))]
19[CodeGenSuppress("GetPaginatedFineTuningJobs", typeof(string), typeof(int?))]
20[CodeGenSuppress("RetrieveFineTuningJobAsync", typeof(string))]
21[CodeGenSuppress("RetrieveFineTuningJob", typeof(string))]
22[CodeGenSuppress("CancelFineTuningJobAsync", typeof(string))]
23[CodeGenSuppress("CancelFineTuningJob", typeof(string))]
24[CodeGenSuppress("GetFineTuningEventsAsync", typeof(string), typeof(string), typeof(int?))]
25[CodeGenSuppress("GetFineTuningEvents", typeof(string), typeof(string), typeof(int?))]
26[CodeGenSuppress("GetFineTuningJobCheckpointsAsync", typeof(string), typeof(string), typeof(int?))]
27[CodeGenSuppress("GetFineTuningJobCheckpoints", typeof(string), typeof(string), typeof(int?))]
28public partial class FineTuningClient
29{
30 // CUSTOM: Added as a convenience.
31 /// <summary> Initializes a new instance of <see cref="FineTuningClient">. </summary>
32 /// <param name="apiKey"> The API key to authenticate with the service. </param>
33 /// <exception cref="ArgumentNullException"> <paramref name="apiKey"/> is null. </exception>
34 public FineTuningClient(string apiKey) : this(new ApiKeyCredential(apiKey), new OpenAIClientOptions())
35 {
36 }
37
38 // CUSTOM: Added as a convenience.
39 /// <summary> Initializes a new instance of <see cref="FineTuningClient">. </summary>
40 /// <param name="apiKey"> The API key to authenticate with the service. </param>
41 /// <param name="options"> The options to configure the client. </param>
42 /// <exception cref="ArgumentNullException"> <paramref name="apiKey"/> is null. </exception>
43 public FineTuningClient(string apiKey, OpenAIClientOptions options) : this(new ApiKeyCredential(apiKey), options)
44 {
45 }
46
47 // CUSTOM:
48 // - Used a custom pipeline.
49 // - Demoted the endpoint parameter to be a property in the options class.
50 /// <summary> Initializes a new instance of <see cref="FineTuningClient">. </summary>
51 /// <param name="credential"> The API key to authenticate with the service. </param>
52 /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
53 public FineTuningClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions())
54 {
55 }
56
57 // CUSTOM:
58 // - Used a custom pipeline.
59 // - Demoted the endpoint parameter to be a property in the options class.
60 /// <summary> Initializes a new instance of <see cref="FineTuningClient">. </summary>
61 /// <param name="credential"> The API key to authenticate with the service. </param>
62 /// <param name="options"> The options to configure the client. </param>
63 /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
64 public FineTuningClient(ApiKeyCredential credential, OpenAIClientOptions options)
65 {
66 Argument.AssertNotNull(credential, nameof(credential));
67 options ??= new OpenAIClientOptions();
68
69 _pipeline = OpenAIClient.CreatePipeline(credential, options);
70 _endpoint = OpenAIClient.GetEndpoint(options);
71 }
72
73 // CUSTOM:
74 // - Used a custom pipeline.
75 // - Demoted the endpoint parameter to be a property in the options class.
76 // - Made protected.
77 /// <summary> Initializes a new instance of <see cref="FineTuningClient">. </summary>
78 /// <param name="pipeline"> The HTTP pipeline to send and receive REST requests and responses. </param>
79 /// <param name="options"> The options to configure the client. </param>
80 /// <exception cref="ArgumentNullException"> <paramref name="pipeline"/> is null. </exception>
81 protected internal FineTuningClient(ClientPipeline pipeline, OpenAIClientOptions options)
82 {
83 Argument.AssertNotNull(pipeline, nameof(pipeline));
84 options ??= new OpenAIClientOptions();
85
86 _pipeline = pipeline;
87 _endpoint = OpenAIClient.GetEndpoint(options);
88 }
89}