using Microsoft.TypeSpec.Generator.Customizations; using System; using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Threading; namespace OpenAI.Batch; // CUSTOM: // - Renamed. // - Suppressed constructor that takes endpoint parameter; endpoint is now a property in the options class. // - Suppressed convenience methods for now. /// The service client for OpenAI batch operations. [CodeGenType("Batches")] [CodeGenSuppress("BatchClient", typeof(ClientPipeline), typeof(Uri))] [CodeGenSuppress("CreateBatch", typeof(string), typeof(InternalCreateBatchRequestEndpoint), typeof(IDictionary), typeof(CancellationToken))] [CodeGenSuppress("CreateBatchAsync", typeof(string), typeof(InternalCreateBatchRequestEndpoint), typeof(IDictionary), typeof(CancellationToken))] [CodeGenSuppress("CreateBatch", typeof(BinaryContent), typeof(RequestOptions))] [CodeGenSuppress("CreateBatchAsync", typeof(BinaryContent), typeof(RequestOptions))] [CodeGenSuppress("GetBatch", typeof(string), typeof(CancellationToken))] [CodeGenSuppress("GetBatchAsync", typeof(string), typeof(CancellationToken))] [CodeGenSuppress("CancelBatch", typeof(string), typeof(CancellationToken))] [CodeGenSuppress("CancelBatchAsync", typeof(string), typeof(CancellationToken))] [CodeGenSuppress("CancelBatch", typeof(string), typeof(RequestOptions))] [CodeGenSuppress("CancelBatchAsync", typeof(string), typeof(RequestOptions))] public partial class BatchClient { // CUSTOM: Added as a convenience. /// Initializes a new instance of . /// The API key to authenticate with the service. /// is null. public BatchClient(string apiKey) : this(new ApiKeyCredential(apiKey), new OpenAIClientOptions()) { } // CUSTOM: // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The to authenticate with the service. /// is null. public BatchClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { } /// /// Initializes a new instance of that will use an API key when authenticating. /// /// The to authenticate with the service. /// Additional options to customize the client. /// The provided was null. public BatchClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) { } // CUSTOM: Added as a convenience. /// Initializes a new instance of . /// The authentication policy used to authenticate with the service. /// is null. public BatchClient(AuthenticationPolicy authenticationPolicy) : this(authenticationPolicy, new OpenAIClientOptions()) { } // CUSTOM: Added as a convenience. /// Initializes a new instance of . /// The authentication policy used to authenticate with the service. /// The options to configure the client. /// is null. public BatchClient(AuthenticationPolicy authenticationPolicy, OpenAIClientOptions options) { Argument.AssertNotNull(authenticationPolicy, nameof(authenticationPolicy)); options ??= new OpenAIClientOptions(); Pipeline = OpenAIClient.CreatePipeline(authenticationPolicy, options); _endpoint = OpenAIClient.GetEndpoint(options); } // CUSTOM: // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. // - Made protected. /// Initializes a new instance of . /// The HTTP pipeline to send and receive REST requests and responses. /// The options to configure the client. /// is null. protected internal BatchClient(ClientPipeline pipeline, OpenAIClientOptions options) { Argument.AssertNotNull(pipeline, nameof(pipeline)); options ??= new OpenAIClientOptions(); Pipeline = pipeline; _endpoint = OpenAIClient.GetEndpoint(options); } [Experimental("SCME0002")] public BatchClient(BatchClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Options) { } /// /// Gets the endpoint URI for the service. /// [Experimental("OPENAI001")] public Uri Endpoint => _endpoint; internal virtual CreateBatchOperation CreateCreateBatchOperation(string batchId, string status, PipelineResponse response) { return new CreateBatchOperation(this, _endpoint, batchId, status, response); } }