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/Assistants/Internal/InternalAssistantThreadClient.cs

61lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4
5namespace OpenAI.Assistants;
6
7[CodeGenClient("Threads")]
8[CodeGenSuppress("InternalAssistantThreadClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))]
9[CodeGenSuppress("CreateThreadAsync", typeof(ThreadCreationOptions))]
10[CodeGenSuppress("CreateThread", typeof(ThreadCreationOptions))]
11[CodeGenSuppress("GetThreadAsync", typeof(string))]
12[CodeGenSuppress("GetThread", typeof(string))]
13[CodeGenSuppress("ModifyThreadAsync", typeof(string), typeof(ThreadModificationOptions))]
14[CodeGenSuppress("ModifyThread", typeof(string), typeof(ThreadModificationOptions))]
15[CodeGenSuppress("DeleteThreadAsync", typeof(string))]
16[CodeGenSuppress("DeleteThread", typeof(string))]
17internal partial class InternalAssistantThreadClient
18{
19 // CUSTOM:
20 // - Used a custom pipeline.
21 // - Demoted the endpoint parameter to be a property in the options class.
22 /// <summary> Initializes a new instance of <see cref="InternalAssistantThreadClient">. </summary>
23 /// <param name="credential"> The API key to authenticate with the service. </param>
24 /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
25 public InternalAssistantThreadClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions())
26 {
27 }
28
29 // CUSTOM:
30 // - Used a custom pipeline.
31 // - Demoted the endpoint parameter to be a property in the options class.
32 /// <summary> Initializes a new instance of <see cref="InternalAssistantThreadClient">. </summary>
33 /// <param name="credential"> The API key to authenticate with the service. </param>
34 /// <param name="options"> The options to configure the client. </param>
35 /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
36 public InternalAssistantThreadClient(ApiKeyCredential credential, OpenAIClientOptions options)
37 {
38 Argument.AssertNotNull(credential, nameof(credential));
39 options ??= new OpenAIClientOptions();
40
41 _pipeline = OpenAIClient.CreatePipeline(credential, options);
42 _endpoint = OpenAIClient.GetEndpoint(options);
43 }
44
45 // CUSTOM:
46 // - Used a custom pipeline.
47 // - Demoted the endpoint parameter to be a property in the options class.
48 // - Made protected.
49 /// <summary> Initializes a new instance of <see cref="InternalAssistantThreadClient">. </summary>
50 /// <param name="pipeline"> The HTTP pipeline to send and receive REST requests and responses. </param>
51 /// <param name="options"> The options to configure the client. </param>
52 /// <exception cref="ArgumentNullException"> <paramref name="pipeline"/> is null. </exception>
53 protected internal InternalAssistantThreadClient(ClientPipeline pipeline, OpenAIClientOptions options)
54 {
55 Argument.AssertNotNull(pipeline, nameof(pipeline));
56 options ??= new OpenAIClientOptions();
57
58 _pipeline = pipeline;
59 _endpoint = OpenAIClient.GetEndpoint(options);
60 }
61}
62