openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.0.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/FineTuning/FineTuningClient.cs

90lines · modeblame

58f93c8dShivangiReja2 years ago1using System;
9f9f2936Jose Arriaga Maldonado2 years ago2using System.ClientModel;
3using System.ClientModel.Primitives;
0f5e0249ShivangiReja1 years ago4using System.Diagnostics.CodeAnalysis;
9f9f2936Jose Arriaga Maldonado2 years ago5
6namespace OpenAI.FineTuning;
7
13a9c686Jose Arriaga Maldonado1 years ago8// 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>
0f5e0249ShivangiReja1 years ago13[Experimental("OPENAI001")]
9f9f2936Jose Arriaga Maldonado2 years ago14[CodeGenClient("FineTuning")]
13a9c686Jose Arriaga Maldonado1 years ago15[CodeGenSuppress("FineTuningClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))]
2ab1a942Jose Arriaga Maldonado1 years ago16[CodeGenSuppress("CreateFineTuningJobAsync", typeof(FineTuningOptions))]
17[CodeGenSuppress("CreateFineTuningJob", typeof(FineTuningOptions))]
9f9f2936Jose Arriaga Maldonado2 years ago18[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{
75eded51ShivangiReja1 years ago30// CUSTOM: Remove virtual keyword.
31/// <summary>
32/// The HTTP pipeline for sending and receiving REST requests and responses.
33/// </summary>
34public ClientPipeline Pipeline => _pipeline;
35
2ab1a942Jose Arriaga Maldonado1 years ago36// CUSTOM: Added as a convenience.
37/// <summary> Initializes a new instance of <see cref="FineTuningClient">. </summary>
38/// <param name="apiKey"> The API key to authenticate with the service. </param>
39/// <exception cref="ArgumentNullException"> <paramref name="apiKey"/> is null. </exception>
40public FineTuningClient(string apiKey) : this(new ApiKeyCredential(apiKey), new OpenAIClientOptions())
41{
42}
43
13a9c686Jose Arriaga Maldonado1 years ago44// CUSTOM:
45// - Used a custom pipeline.
46// - Demoted the endpoint parameter to be a property in the options class.
47/// <summary> Initializes a new instance of <see cref="FineTuningClient">. </summary>
48/// <param name="credential"> The API key to authenticate with the service. </param>
49/// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
50public FineTuningClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions())
51{
52}
9f9f2936Jose Arriaga Maldonado2 years ago53
a330c2e7Jose Arriaga Maldonado1 years ago54/// <summary>
55/// Initializes a new instance of <see cref="FineTuningClient"/> that will use an API key when authenticating.
56/// </summary>
57/// <param name="credential"> The API key used to authenticate with the service endpoint. </param>
58/// <param name="options"> Additional options to customize the client. </param>
59/// <exception cref="ArgumentNullException"> The provided <paramref name="credential"/> was null. </exception>
13a9c686Jose Arriaga Maldonado1 years ago60public FineTuningClient(ApiKeyCredential credential, OpenAIClientOptions options)
61{
62Argument.AssertNotNull(credential, nameof(credential));
63options ??= new OpenAIClientOptions();
9f9f2936Jose Arriaga Maldonado2 years ago64
13a9c686Jose Arriaga Maldonado1 years ago65_pipeline = OpenAIClient.CreatePipeline(credential, options);
66_endpoint = OpenAIClient.GetEndpoint(options);
67}
9f9f2936Jose Arriaga Maldonado2 years ago68
13a9c686Jose Arriaga Maldonado1 years ago69// CUSTOM:
70// - Used a custom pipeline.
71// - Demoted the endpoint parameter to be a property in the options class.
72// - Made protected.
73/// <summary> Initializes a new instance of <see cref="FineTuningClient">. </summary>
74/// <param name="pipeline"> The HTTP pipeline to send and receive REST requests and responses. </param>
75/// <param name="options"> The options to configure the client. </param>
76/// <exception cref="ArgumentNullException"> <paramref name="pipeline"/> is null. </exception>
77protected internal FineTuningClient(ClientPipeline pipeline, OpenAIClientOptions options)
9f9f2936Jose Arriaga Maldonado2 years ago78{
13a9c686Jose Arriaga Maldonado1 years ago79Argument.AssertNotNull(pipeline, nameof(pipeline));
80options ??= new OpenAIClientOptions();
81
9f9f2936Jose Arriaga Maldonado2 years ago82_pipeline = pipeline;
13a9c686Jose Arriaga Maldonado1 years ago83_endpoint = OpenAIClient.GetEndpoint(options);
9f9f2936Jose Arriaga Maldonado2 years ago84}
a330c2e7Jose Arriaga Maldonado1 years ago85
86internal virtual FineTuningJobOperation CreateCreateJobOperation(string jobId, string status, PipelineResponse response)
87{
88return new FineTuningJobOperation(_pipeline, _endpoint, jobId, status, response);
89}
9f9f2936Jose Arriaga Maldonado2 years ago90}