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

59lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4
5namespace OpenAI.Assistants;
6
7[CodeGenClient("Messages")]
8[CodeGenSuppress("InternalAssistantMessageClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))]
9[CodeGenSuppress("CreateMessageAsync", typeof(string), typeof(MessageCreationOptions))]
10[CodeGenSuppress("CreateMessage", typeof(string), typeof(MessageCreationOptions))]
11[CodeGenSuppress("GetMessagesAsync", typeof(string), typeof(int?), typeof(ListOrder?), typeof(string), typeof(string))]
12[CodeGenSuppress("GetMessages", typeof(string), typeof(int?), typeof(ListOrder?), typeof(string), typeof(string))]
13[CodeGenSuppress("GetMessageAsync", typeof(string), typeof(string))]
14[CodeGenSuppress("GetMessage", typeof(string), typeof(string))]
15[CodeGenSuppress("ModifyMessageAsync", typeof(string), typeof(string), typeof(MessageModificationOptions))]
16[CodeGenSuppress("ModifyMessage", typeof(string), typeof(string), typeof(MessageModificationOptions))]
17[CodeGenSuppress("DeleteMessageAsync", typeof(string), typeof(string))]
18[CodeGenSuppress("DeleteMessage", typeof(string), typeof(string))]
19internal partial class InternalAssistantMessageClient
20{
21 /// <summary>
22 /// Initializes a new instance of <see cref="InternalAssistantMessageClient"/> that will use an API key when authenticating.
23 /// </summary>
24 /// <param name="credential"> The API key used to authenticate with the service endpoint. </param>
25 /// <param name="options"> Additional options to customize the client. </param>
26 /// <exception cref="ArgumentNullException"> The provided <paramref name="credential"/> was null. </exception>
27 public InternalAssistantMessageClient(ApiKeyCredential credential, OpenAIClientOptions options = default)
28 : this(
29 OpenAIClient.CreatePipeline(OpenAIClient.GetApiKey(credential, requireExplicitCredential: true), options),
30 OpenAIClient.GetEndpoint(options),
31 options)
32 { }
33
34 /// <summary>
35 /// Initializes a new instance of <see cref="InternalAssistantMessageClient"/> that will use an API key from the OPENAI_API_KEY
36 /// environment variable when authenticating.
37 /// </summary>
38 /// <remarks>
39 /// To provide an explicit credential instead of using the environment variable, use an alternate constructor like
40 /// <see cref="InternalAssistantMessageClient(ApiKeyCredential,OpenAIClientOptions)"/>.
41 /// </remarks>
42 /// <param name="options"> Additional options to customize the client. </param>
43 /// <exception cref="InvalidOperationException"> The OPENAI_API_KEY environment variable was not found. </exception>
44 public InternalAssistantMessageClient(OpenAIClientOptions options = default)
45 : this(
46 OpenAIClient.CreatePipeline(OpenAIClient.GetApiKey(), options),
47 OpenAIClient.GetEndpoint(options),
48 options)
49 { }
50
51 /// <summary> Initializes a new instance of <see cref="InternalAssistantMessageClient"/>. </summary>
52 /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
53 /// <param name="endpoint"> OpenAI Endpoint. </param>
54 protected internal InternalAssistantMessageClient(ClientPipeline pipeline, Uri endpoint, OpenAIClientOptions options)
55 {
56 _pipeline = pipeline;
57 _endpoint = endpoint;
58 }
59}
60