openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Assistants/Internal/InternalAssistantMessageClient.cs

81lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.Threading;
5
6namespace OpenAI.Assistants;
7
8[CodeGenType("Messages")]
9[CodeGenSuppress("InternalAssistantMessageClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))]
10[CodeGenSuppress("CreateMessageAsync", typeof(string), typeof(MessageCreationOptions), typeof(CancellationToken))]
11[CodeGenSuppress("CreateMessage", typeof(string), typeof(MessageCreationOptions), typeof(CancellationToken))]
12[CodeGenSuppress("GetMessagesAsync", typeof(string), typeof(int?), typeof(OpenAI.VectorStores.VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
13[CodeGenSuppress("GetMessages", typeof(string), typeof(int?), typeof(OpenAI.VectorStores.VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
14[CodeGenSuppress("GetMessageAsync", typeof(string), typeof(string), typeof(CancellationToken))]
15[CodeGenSuppress("GetMessage", typeof(string), typeof(string), typeof(CancellationToken))]
16[CodeGenSuppress("ModifyMessageAsync", typeof(string), typeof(string), typeof(MessageModificationOptions), typeof(CancellationToken))]
17[CodeGenSuppress("ModifyMessage", typeof(string), typeof(string), typeof(MessageModificationOptions), typeof(CancellationToken))]
18[CodeGenSuppress("DeleteMessageAsync", typeof(string), typeof(string), typeof(CancellationToken))]
19[CodeGenSuppress("DeleteMessage", typeof(string), typeof(string), typeof(CancellationToken))]
20internal partial class InternalAssistantMessageClient
21{
22 // CUSTOM:
23 // - Used a custom pipeline.
24 // - Demoted the endpoint parameter to be a property in the options class.
25 /// <summary> Initializes a new instance of <see cref="InternalAssistantMessageClient"/>. </summary>
26 /// <param name="credential"> The API key to authenticate with the service. </param>
27 /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
28 public InternalAssistantMessageClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions())
29 {
30 }
31
32 // CUSTOM:
33 // - Used a custom pipeline.
34 // - Demoted the endpoint parameter to be a property in the options class.
35 /// <summary> Initializes a new instance of <see cref="InternalAssistantMessageClient"/>. </summary>
36 /// <param name="credential"> The API key to authenticate with the service. </param>
37 /// <param name="options"> The options to configure the client. </param>
38 /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
39 public InternalAssistantMessageClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options)
40 {
41 }
42
43 // CUSTOM: Added as a convenience.
44 /// <summary> Initializes a new instance of <see cref="InternalAssistantMessageClient"/>. </summary>
45 /// <param name="authenticationPolicy"> The authentication policy used to authenticate with the service. </param>
46 /// <exception cref="ArgumentNullException"> <paramref name="authenticationPolicy"/> is null. </exception>
47 public InternalAssistantMessageClient(AuthenticationPolicy authenticationPolicy) : this(authenticationPolicy, new OpenAIClientOptions())
48 {
49 }
50
51 // CUSTOM: Added as a convenience.
52 /// <summary> Initializes a new instance of <see cref="InternalAssistantMessageClient"/>. </summary>
53 /// <param name="authenticationPolicy"> The authentication policy used to authenticate with the service. </param>
54 /// <param name="options"> The options to configure the client. </param>
55 /// <exception cref="ArgumentNullException"> <paramref name="authenticationPolicy"/> is null. </exception>
56 public InternalAssistantMessageClient(AuthenticationPolicy authenticationPolicy, OpenAIClientOptions options)
57 {
58 Argument.AssertNotNull(authenticationPolicy, nameof(authenticationPolicy));
59 options ??= new OpenAIClientOptions();
60
61 Pipeline = OpenAIClient.CreatePipeline(authenticationPolicy, options);
62 _endpoint = OpenAIClient.GetEndpoint(options);
63 }
64
65 // CUSTOM:
66 // - Used a custom pipeline.
67 // - Demoted the endpoint parameter to be a property in the options class.
68 // - Made protected.
69 /// <summary> Initializes a new instance of <see cref="InternalAssistantMessageClient"/>. </summary>
70 /// <param name="pipeline"> The HTTP pipeline to send and receive REST requests and responses. </param>
71 /// <param name="options"> The options to configure the client. </param>
72 /// <exception cref="ArgumentNullException"> <paramref name="pipeline"/> is null. </exception>
73 protected internal InternalAssistantMessageClient(ClientPipeline pipeline, OpenAIClientOptions options)
74 {
75 Argument.AssertNotNull(pipeline, nameof(pipeline));
76 options ??= new OpenAIClientOptions();
77
78 Pipeline = pipeline;
79 _endpoint = OpenAIClient.GetEndpoint(options);
80 }
81}
82