openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.0.0-beta.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Batch/BatchClient.cs

63lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.Collections.Generic;
5using System.Threading.Tasks;
6
7namespace OpenAI.Batch;
8
9[CodeGenClient("Batches")]
10[CodeGenSuppress("BatchClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))]
11[CodeGenSuppress("CreateBatch", typeof(string), typeof(InternalBatchOperationEndpoint), typeof(InternalBatchCompletionTimeframe), typeof(IDictionary<string, string>))]
12[CodeGenSuppress("CreateBatchAsync", typeof(string), typeof(InternalBatchOperationEndpoint), typeof(InternalBatchCompletionTimeframe), typeof(IDictionary<string, string>))]
13[CodeGenSuppress("RetrieveBatch", typeof(string))]
14[CodeGenSuppress("RetrieveBatchAsync", typeof(string))]
15[CodeGenSuppress("RetrieveBatch", typeof(string), typeof(RequestOptions))]
16[CodeGenSuppress("RetrieveBatchAsync", typeof(string), typeof(RequestOptions))]
17[CodeGenSuppress("CancelBatch", typeof(string))]
18[CodeGenSuppress("CancelBatchAsync", typeof(string))]
19[CodeGenSuppress("GetBatches", typeof(string), typeof(int?))]
20[CodeGenSuppress("GetBatchesAsync", typeof(string), typeof(int?))]
21public partial class BatchClient
22{
23 /// <summary>
24 /// Initializes a new instance of <see cref="BatchClient"/> that will use an API key when authenticating.
25 /// </summary>
26 /// <param name="credential"> The API key used to authenticate with the service endpoint. </param>
27 /// <param name="options"> Additional options to customize the client. </param>
28 /// <exception cref="ArgumentNullException"> The provided <paramref name="credential"/> was null. </exception>
29 public BatchClient(ApiKeyCredential credential, OpenAIClientOptions options = null)
30 : this(
31 OpenAIClient.CreatePipeline(OpenAIClient.GetApiKey(credential, requireExplicitCredential: true), options),
32 OpenAIClient.GetEndpoint(options),
33 options)
34 { }
35
36 /// <summary>
37 /// Initializes a new instance of <see cref="BatchClient"/> that will use an API key from the OPENAI_API_KEY
38 /// environment variable when authenticating.
39 /// </summary>
40 /// <remarks>
41 /// To provide an explicit credential instead of using the environment variable, use an alternate constructor like
42 /// <see cref="BatchClient(ApiKeyCredential,OpenAIClientOptions)"/>.
43 /// </remarks>
44 /// <param name="options"> Additional options to customize the client. </param>
45 /// <exception cref="InvalidOperationException"> The OPENAI_API_KEY environment variable was not found. </exception>
46 public BatchClient(OpenAIClientOptions options = null)
47 : this(
48 OpenAIClient.CreatePipeline(OpenAIClient.GetApiKey(), options),
49 OpenAIClient.GetEndpoint(options),
50 options)
51 { }
52
53 /// <summary>
54 /// Initializes a new instance of <see cref="BatchClient"/>.
55 /// </summary>
56 /// <param name="pipeline"> The client pipeline to use. </param>
57 /// <param name="endpoint"> The endpoint to use. </param>
58 protected internal BatchClient(ClientPipeline pipeline, Uri endpoint, OpenAIClientOptions options)
59 {
60 _pipeline = pipeline;
61 _endpoint = endpoint;
62 }
63}
64