openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.2.0-beta.4

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/FineTuning/FineTuningClient.cs

85lines · modeblame

58f93c8dShivangiReja2 years ago1using System;
9f9f2936Jose Arriaga Maldonado2 years ago2using System.ClientModel;
3using System.ClientModel.Primitives;
0f5e0249ShivangiReja1 years ago4using System.Diagnostics.CodeAnalysis;
e0fee603Jose Arriaga Maldonado1 years ago5using System.Threading;
9f9f2936Jose Arriaga Maldonado2 years ago6
7namespace OpenAI.FineTuning;
8
13a9c686Jose Arriaga Maldonado1 years ago9// 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 ago14[Experimental("OPENAI001")]
0ca4c062Jose Arriaga Maldonado1 years ago15[CodeGenType("FineTuning")]
16[CodeGenSuppress("FineTuningClient", typeof(ClientPipeline), typeof(Uri))]
e0fee603Jose Arriaga Maldonado1 years ago17[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 ago29public partial class FineTuningClient
30{
2ab1a942Jose Arriaga Maldonado1 years ago31// CUSTOM: Added as a convenience.
e0fee603Jose Arriaga Maldonado1 years ago32/// <summary> Initializes a new instance of <see cref="FineTuningClient"/>. </summary>
2ab1a942Jose Arriaga Maldonado1 years ago33/// <param name="apiKey"> The API key to authenticate with the service. </param>
34/// <exception cref="ArgumentNullException"> <paramref name="apiKey"/> is null. </exception>
35public FineTuningClient(string apiKey) : this(new ApiKeyCredential(apiKey), new OpenAIClientOptions())
36{
37}
38
13a9c686Jose Arriaga Maldonado1 years ago39// CUSTOM:
40// - Used a custom pipeline.
41// - Demoted the endpoint parameter to be a property in the options class.
e0fee603Jose Arriaga Maldonado1 years ago42/// <summary> Initializes a new instance of <see cref="FineTuningClient"/>. </summary>
13a9c686Jose Arriaga Maldonado1 years ago43/// <param name="credential"> The API key to authenticate with the service. </param>
44/// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
45public FineTuningClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions())
46{
47}
9f9f2936Jose Arriaga Maldonado2 years ago48
a330c2e7Jose Arriaga Maldonado1 years ago49/// <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 ago55public FineTuningClient(ApiKeyCredential credential, OpenAIClientOptions options)
56{
57Argument.AssertNotNull(credential, nameof(credential));
58options ??= new OpenAIClientOptions();
9f9f2936Jose Arriaga Maldonado2 years ago59
e0fee603Jose Arriaga Maldonado1 years ago60Pipeline = OpenAIClient.CreatePipeline(credential, options);
13a9c686Jose Arriaga Maldonado1 years ago61_endpoint = OpenAIClient.GetEndpoint(options);
62}
9f9f2936Jose Arriaga Maldonado2 years ago63
13a9c686Jose Arriaga Maldonado1 years ago64// 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 ago68/// <summary> Initializes a new instance of <see cref="FineTuningClient"/>. </summary>
13a9c686Jose Arriaga Maldonado1 years ago69/// <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>
72protected internal FineTuningClient(ClientPipeline pipeline, OpenAIClientOptions options)
9f9f2936Jose Arriaga Maldonado2 years ago73{
13a9c686Jose Arriaga Maldonado1 years ago74Argument.AssertNotNull(pipeline, nameof(pipeline));
75options ??= new OpenAIClientOptions();
76
e0fee603Jose Arriaga Maldonado1 years ago77Pipeline = pipeline;
13a9c686Jose Arriaga Maldonado1 years ago78_endpoint = OpenAIClient.GetEndpoint(options);
9f9f2936Jose Arriaga Maldonado2 years ago79}
a330c2e7Jose Arriaga Maldonado1 years ago80
81internal virtual FineTuningJobOperation CreateCreateJobOperation(string jobId, string status, PipelineResponse response)
82{
e0fee603Jose Arriaga Maldonado1 years ago83return new FineTuningJobOperation(Pipeline, _endpoint, jobId, status, response);
a330c2e7Jose Arriaga Maldonado1 years ago84}
9f9f2936Jose Arriaga Maldonado2 years ago85}