openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.2.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Assistants/Internal/InternalAssistantMessageClient.Protocol.cs

165lines · modeblame

9f9f2936Jose Arriaga Maldonado2 years ago1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.Threading.Tasks;
5
6namespace OpenAI.Assistants;
7
8internal partial class InternalAssistantMessageClient
9{
10/// <summary>
11/// [Protocol Method] Create a message.
12/// </summary>
13/// <param name="threadId"> The ID of the [thread](/docs/api-reference/threads) to create a message for. </param>
14/// <param name="content"> The content to send as the body of the request. </param>
15/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
16/// <exception cref="ArgumentNullException"> <paramref name="threadId"/> or <paramref name="content"/> is null. </exception>
17/// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
18/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
19/// <returns> The response returned from the service. </returns>
20public virtual async Task<ClientResult> CreateMessageAsync(string threadId, BinaryContent content, RequestOptions options = null)
21{
22Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
23Argument.AssertNotNull(content, nameof(content));
24
25using PipelineMessage message = CreateCreateMessageRequest(threadId, content, options);
e0fee603Jose Arriaga Maldonado1 years ago26return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago27}
28
29/// <summary>
30/// [Protocol Method] Create a message.
31/// </summary>
32/// <param name="threadId"> The ID of the [thread](/docs/api-reference/threads) to create a message for. </param>
33/// <param name="content"> The content to send as the body of the request. </param>
34/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
35/// <exception cref="ArgumentNullException"> <paramref name="threadId"/> or <paramref name="content"/> is null. </exception>
36/// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
37/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
38/// <returns> The response returned from the service. </returns>
39public virtual ClientResult CreateMessage(string threadId, BinaryContent content, RequestOptions options = null)
40{
41Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
42Argument.AssertNotNull(content, nameof(content));
43
44using PipelineMessage message = CreateCreateMessageRequest(threadId, content, options);
e0fee603Jose Arriaga Maldonado1 years ago45return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago46}
47
48/// <summary>
49/// [Protocol Method] Retrieve a message.
50/// </summary>
51/// <param name="threadId"> The ID of the [thread](/docs/api-reference/threads) to which this message belongs. </param>
52/// <param name="messageId"> The ID of the message to retrieve. </param>
53/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
54/// <exception cref="ArgumentNullException"> <paramref name="threadId"/> or <paramref name="messageId"/> is null. </exception>
55/// <exception cref="ArgumentException"> <paramref name="threadId"/> or <paramref name="messageId"/> is an empty string, and was expected to be non-empty. </exception>
56/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
57/// <returns> The response returned from the service. </returns>
58public virtual async Task<ClientResult> GetMessageAsync(string threadId, string messageId, RequestOptions options)
59{
60Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
61Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
62
63using PipelineMessage message = CreateGetMessageRequest(threadId, messageId, options);
e0fee603Jose Arriaga Maldonado1 years ago64return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago65}
66
67/// <summary>
68/// [Protocol Method] Retrieve a message.
69/// </summary>
70/// <param name="threadId"> The ID of the [thread](/docs/api-reference/threads) to which this message belongs. </param>
71/// <param name="messageId"> The ID of the message to retrieve. </param>
72/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
73/// <exception cref="ArgumentNullException"> <paramref name="threadId"/> or <paramref name="messageId"/> is null. </exception>
74/// <exception cref="ArgumentException"> <paramref name="threadId"/> or <paramref name="messageId"/> is an empty string, and was expected to be non-empty. </exception>
75/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
76/// <returns> The response returned from the service. </returns>
77public virtual ClientResult GetMessage(string threadId, string messageId, RequestOptions options)
78{
79Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
80Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
81
82using PipelineMessage message = CreateGetMessageRequest(threadId, messageId, options);
e0fee603Jose Arriaga Maldonado1 years ago83return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago84}
85
86/// <summary>
87/// [Protocol Method] Modifies a message.
88/// </summary>
89/// <param name="threadId"> The ID of the thread to which this message belongs. </param>
90/// <param name="messageId"> The ID of the message to modify. </param>
91/// <param name="content"> The content to send as the body of the request. </param>
92/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
93/// <exception cref="ArgumentNullException"> <paramref name="threadId"/>, <paramref name="messageId"/> or <paramref name="content"/> is null. </exception>
94/// <exception cref="ArgumentException"> <paramref name="threadId"/> or <paramref name="messageId"/> is an empty string, and was expected to be non-empty. </exception>
95/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
96/// <returns> The response returned from the service. </returns>
97public virtual async Task<ClientResult> ModifyMessageAsync(string threadId, string messageId, BinaryContent content, RequestOptions options = null)
98{
99Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
100Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
101Argument.AssertNotNull(content, nameof(content));
102
103using PipelineMessage message = CreateModifyMessageRequest(threadId, messageId, content, options);
e0fee603Jose Arriaga Maldonado1 years ago104return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago105}
106
107/// <summary>
108/// [Protocol Method] Modifies a message.
109/// </summary>
110/// <param name="threadId"> The ID of the thread to which this message belongs. </param>
111/// <param name="messageId"> The ID of the message to modify. </param>
112/// <param name="content"> The content to send as the body of the request. </param>
113/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
114/// <exception cref="ArgumentNullException"> <paramref name="threadId"/>, <paramref name="messageId"/> or <paramref name="content"/> is null. </exception>
115/// <exception cref="ArgumentException"> <paramref name="threadId"/> or <paramref name="messageId"/> is an empty string, and was expected to be non-empty. </exception>
116/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
117/// <returns> The response returned from the service. </returns>
118public virtual ClientResult ModifyMessage(string threadId, string messageId, BinaryContent content, RequestOptions options = null)
119{
120Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
121Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
122Argument.AssertNotNull(content, nameof(content));
123
124using PipelineMessage message = CreateModifyMessageRequest(threadId, messageId, content, options);
e0fee603Jose Arriaga Maldonado1 years ago125return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago126}
127
128/// <summary>
129/// [Protocol Method] Deletes a message.
130/// </summary>
131/// <param name="threadId"> The ID of the thread to which this message belongs. </param>
132/// <param name="messageId"> The ID of the message to delete. </param>
133/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
134/// <exception cref="ArgumentNullException"> <paramref name="threadId"/> or <paramref name="messageId"/> is null. </exception>
135/// <exception cref="ArgumentException"> <paramref name="threadId"/> or <paramref name="messageId"/> is an empty string, and was expected to be non-empty. </exception>
136/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
137/// <returns> The response returned from the service. </returns>
138public virtual async Task<ClientResult> DeleteMessageAsync(string threadId, string messageId, RequestOptions options)
139{
140Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
141Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
142
143using PipelineMessage message = CreateDeleteMessageRequest(threadId, messageId, options);
e0fee603Jose Arriaga Maldonado1 years ago144return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
9f9f2936Jose Arriaga Maldonado2 years ago145}
146
147/// <summary>
148/// [Protocol Method] Deletes a message.
149/// </summary>
150/// <param name="threadId"> The ID of the thread to which this message belongs. </param>
151/// <param name="messageId"> The ID of the message to delete. </param>
152/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
153/// <exception cref="ArgumentNullException"> <paramref name="threadId"/> or <paramref name="messageId"/> is null. </exception>
154/// <exception cref="ArgumentException"> <paramref name="threadId"/> or <paramref name="messageId"/> is an empty string, and was expected to be non-empty. </exception>
155/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
156/// <returns> The response returned from the service. </returns>
157public virtual ClientResult DeleteMessage(string threadId, string messageId, RequestOptions options)
158{
159Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
160Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
161
162using PipelineMessage message = CreateDeleteMessageRequest(threadId, messageId, options);
e0fee603Jose Arriaga Maldonado1 years ago163return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
9f9f2936Jose Arriaga Maldonado2 years ago164}
165}