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

67lines · 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: Remove virtual keyword.
20 /// <summary>
21 /// The HTTP pipeline for sending and receiving REST requests and responses.
22 /// </summary>
23 public ClientPipeline Pipeline => _pipeline;
24
25 // CUSTOM:
26 // - Used a custom pipeline.
27 // - Demoted the endpoint parameter to be a property in the options class.
28 /// <summary> Initializes a new instance of <see cref="InternalAssistantThreadClient">. </summary>
29 /// <param name="credential"> The API key to authenticate with the service. </param>
30 /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
31 public InternalAssistantThreadClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions())
32 {
33 }
34
35 // CUSTOM:
36 // - Used a custom pipeline.
37 // - Demoted the endpoint parameter to be a property in the options class.
38 /// <summary> Initializes a new instance of <see cref="InternalAssistantThreadClient">. </summary>
39 /// <param name="credential"> The API key to authenticate with the service. </param>
40 /// <param name="options"> The options to configure the client. </param>
41 /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
42 public InternalAssistantThreadClient(ApiKeyCredential credential, OpenAIClientOptions options)
43 {
44 Argument.AssertNotNull(credential, nameof(credential));
45 options ??= new OpenAIClientOptions();
46
47 _pipeline = OpenAIClient.CreatePipeline(credential, options);
48 _endpoint = OpenAIClient.GetEndpoint(options);
49 }
50
51 // CUSTOM:
52 // - Used a custom pipeline.
53 // - Demoted the endpoint parameter to be a property in the options class.
54 // - Made protected.
55 /// <summary> Initializes a new instance of <see cref="InternalAssistantThreadClient">. </summary>
56 /// <param name="pipeline"> The HTTP pipeline to send and receive REST requests and responses. </param>
57 /// <param name="options"> The options to configure the client. </param>
58 /// <exception cref="ArgumentNullException"> <paramref name="pipeline"/> is null. </exception>
59 protected internal InternalAssistantThreadClient(ClientPipeline pipeline, OpenAIClientOptions options)
60 {
61 Argument.AssertNotNull(pipeline, nameof(pipeline));
62 options ??= new OpenAIClientOptions();
63
64 _pipeline = pipeline;
65 _endpoint = OpenAIClient.GetEndpoint(options);
66 }
67}
68