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/AssistantClient.Protocol.cs

349lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.Threading.Tasks;
5
6namespace OpenAI.Assistants;
7
8public partial class AssistantClient
9{
10 /// <summary>
11 /// [Protocol Method] Create an assistant with a model and instructions.
12 /// </summary>
13 /// <param name="content"> The content to send as the body of the request. </param>
14 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
15 /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
16 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
17 /// <returns> The response returned from the service. </returns>
18 public virtual async Task<ClientResult> CreateAssistantAsync(BinaryContent content, RequestOptions options = null)
19 {
20 Argument.AssertNotNull(content, nameof(content));
21
22 using PipelineMessage message = CreateCreateAssistantRequest(content, options);
23 return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
24 }
25
26 /// <summary>
27 /// [Protocol Method] Create an assistant with a model and instructions.
28 /// </summary>
29 /// <param name="content"> The content to send as the body of the request. </param>
30 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
31 /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
32 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
33 /// <returns> The response returned from the service. </returns>
34 public virtual ClientResult CreateAssistant(BinaryContent content, RequestOptions options = null)
35 {
36 Argument.AssertNotNull(content, nameof(content));
37
38 using PipelineMessage message = CreateCreateAssistantRequest(content, options);
39 return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options));
40 }
41
42 /// <summary>
43 /// [Protocol Method] Returns a list of assistants.
44 /// </summary>
45 /// <param name="limit">
46 /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
47 /// default is 20.
48 /// </param>
49 /// <param name="order">
50 /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
51 /// for descending order. Allowed values: "asc" | "desc"
52 /// </param>
53 /// <param name="after">
54 /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
55 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
56 /// subsequent call can include after=obj_foo in order to fetch the next page of the list.
57 /// </param>
58 /// <param name="before">
59 /// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
60 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
61 /// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
62 /// </param>
63 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
64 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
65 /// <returns> The response returned from the service. </returns>
66 public virtual async Task<ClientResult> GetAssistantsAsync(int? limit, string order, string after, string before, RequestOptions options)
67 {
68 using PipelineMessage message = CreateGetAssistantsRequest(limit, order, after, before, options);
69 return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
70 }
71
72 /// <summary>
73 /// [Protocol Method] Returns a list of assistants.
74 /// </summary>
75 /// <param name="limit">
76 /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
77 /// default is 20.
78 /// </param>
79 /// <param name="order">
80 /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
81 /// for descending order. Allowed values: "asc" | "desc"
82 /// </param>
83 /// <param name="after">
84 /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
85 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
86 /// subsequent call can include after=obj_foo in order to fetch the next page of the list.
87 /// </param>
88 /// <param name="before">
89 /// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
90 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
91 /// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
92 /// </param>
93 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
94 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
95 /// <returns> The response returned from the service. </returns>
96 public virtual ClientResult GetAssistants(int? limit, string order, string after, string before, RequestOptions options)
97 {
98 using PipelineMessage message = CreateGetAssistantsRequest(limit, order, after, before, options);
99 return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options));
100 }
101
102 /// <summary>
103 /// [Protocol Method] Retrieves an assistant.
104 /// </summary>
105 /// <param name="assistantId"> The ID of the assistant to retrieve. </param>
106 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
107 /// <exception cref="ArgumentNullException"> <paramref name="assistantId"/> is null. </exception>
108 /// <exception cref="ArgumentException"> <paramref name="assistantId"/> is an empty string, and was expected to be non-empty. </exception>
109 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
110 /// <returns> The response returned from the service. </returns>
111 public virtual async Task<ClientResult> GetAssistantAsync(string assistantId, RequestOptions options)
112 {
113 Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
114
115 using PipelineMessage message = CreateGetAssistantRequest(assistantId, options);
116 return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
117 }
118
119 /// <summary>
120 /// [Protocol Method] Retrieves an assistant.
121 /// </summary>
122 /// <param name="assistantId"> The ID of the assistant to retrieve. </param>
123 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
124 /// <exception cref="ArgumentNullException"> <paramref name="assistantId"/> is null. </exception>
125 /// <exception cref="ArgumentException"> <paramref name="assistantId"/> is an empty string, and was expected to be non-empty. </exception>
126 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
127 /// <returns> The response returned from the service. </returns>
128 public virtual ClientResult GetAssistant(string assistantId, RequestOptions options)
129 {
130 Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
131
132 using PipelineMessage message = CreateGetAssistantRequest(assistantId, options);
133 return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options));
134 }
135
136 /// <summary>
137 /// [Protocol Method] Modifies an assistant.
138 /// </summary>
139 /// <param name="assistantId"> The ID of the assistant to modify. </param>
140 /// <param name="content"> The content to send as the body of the request. </param>
141 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
142 /// <exception cref="ArgumentNullException"> <paramref name="assistantId"/> or <paramref name="content"/> is null. </exception>
143 /// <exception cref="ArgumentException"> <paramref name="assistantId"/> is an empty string, and was expected to be non-empty. </exception>
144 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
145 /// <returns> The response returned from the service. </returns>
146 public virtual async Task<ClientResult> ModifyAssistantAsync(string assistantId, BinaryContent content, RequestOptions options = null)
147 {
148 Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
149 Argument.AssertNotNull(content, nameof(content));
150
151 using PipelineMessage message = CreateModifyAssistantRequest(assistantId, content, options);
152 return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
153 }
154
155 /// <summary>
156 /// [Protocol Method] Modifies an assistant.
157 /// </summary>
158 /// <param name="assistantId"> The ID of the assistant to modify. </param>
159 /// <param name="content"> The content to send as the body of the request. </param>
160 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
161 /// <exception cref="ArgumentNullException"> <paramref name="assistantId"/> or <paramref name="content"/> is null. </exception>
162 /// <exception cref="ArgumentException"> <paramref name="assistantId"/> is an empty string, and was expected to be non-empty. </exception>
163 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
164 /// <returns> The response returned from the service. </returns>
165 public virtual ClientResult ModifyAssistant(string assistantId, BinaryContent content, RequestOptions options = null)
166 {
167 Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
168 Argument.AssertNotNull(content, nameof(content));
169
170 using PipelineMessage message = CreateModifyAssistantRequest(assistantId, content, options);
171 return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options));
172 }
173
174 /// <summary>
175 /// [Protocol Method] Delete an assistant.
176 /// </summary>
177 /// <param name="assistantId"> The ID of the assistant to delete. </param>
178 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
179 /// <exception cref="ArgumentNullException"> <paramref name="assistantId"/> is null. </exception>
180 /// <exception cref="ArgumentException"> <paramref name="assistantId"/> is an empty string, and was expected to be non-empty. </exception>
181 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
182 /// <returns> The response returned from the service. </returns>
183 public virtual async Task<ClientResult> DeleteAssistantAsync(string assistantId, RequestOptions options)
184 {
185 Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
186
187 using PipelineMessage message = CreateDeleteAssistantRequest(assistantId, options);
188 return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
189 }
190
191 /// <summary>
192 /// [Protocol Method] Delete an assistant.
193 /// </summary>
194 /// <param name="assistantId"> The ID of the assistant to delete. </param>
195 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
196 /// <exception cref="ArgumentNullException"> <paramref name="assistantId"/> is null. </exception>
197 /// <exception cref="ArgumentException"> <paramref name="assistantId"/> is an empty string, and was expected to be non-empty. </exception>
198 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
199 /// <returns> The response returned from the service. </returns>
200 public virtual ClientResult DeleteAssistant(string assistantId, RequestOptions options)
201 {
202 Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
203
204 using PipelineMessage message = CreateDeleteAssistantRequest(assistantId, options);
205 return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options));
206 }
207
208 /// <inheritdoc cref="InternalAssistantMessageClient.CreateMessageAsync"/>
209 public virtual Task<ClientResult> CreateMessageAsync(string threadId, BinaryContent content, RequestOptions options = null)
210 => _messageSubClient.CreateMessageAsync(threadId, content, options);
211
212 /// <inheritdoc cref="InternalAssistantMessageClient.CreateMessage"/>
213 public virtual ClientResult CreateMessage(string threadId, BinaryContent content, RequestOptions options = null)
214 => _messageSubClient.CreateMessage(threadId, content, options);
215
216 /// <inheritdoc cref="InternalAssistantMessageClient.GetMessagesAsync"/>
217 public virtual Task<ClientResult> GetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options)
218 => _messageSubClient.GetMessagesAsync(threadId, limit, order, after, before, options);
219
220 /// <inheritdoc cref="InternalAssistantMessageClient.GetMessages"/>
221 public virtual ClientResult GetMessages(string threadId, int? limit, string order, string after, string before, RequestOptions options)
222 => _messageSubClient.GetMessages(threadId, limit, order, after, before, options);
223
224 /// <inheritdoc cref="InternalAssistantMessageClient.GetMessageAsync"/>
225 public virtual Task<ClientResult> GetMessageAsync(string threadId, string messageId, RequestOptions options)
226 => _messageSubClient.GetMessageAsync(threadId, messageId, options);
227
228 /// <inheritdoc cref="InternalAssistantMessageClient.GetMessage"/>
229 public virtual ClientResult GetMessage(string threadId, string messageId, RequestOptions options)
230 => _messageSubClient.GetMessage(threadId, messageId, options);
231 /// <inheritdoc cref="InternalAssistantMessageClient.ModifyMessageAsync"/>
232 public virtual Task<ClientResult> ModifyMessageAsync(string threadId, string messageId, BinaryContent content, RequestOptions options = null)
233 => _messageSubClient.ModifyMessageAsync(threadId, messageId, content, options);
234
235 /// <inheritdoc cref="InternalAssistantMessageClient.ModifyMessage"/>
236 public virtual ClientResult ModifyMessage(string threadId, string messageId, BinaryContent content, RequestOptions options = null)
237 => _messageSubClient.ModifyMessage(threadId, messageId, content, options);
238 /// <inheritdoc cref="InternalAssistantMessageClient.DeleteMessageAsync"/>
239 public virtual Task<ClientResult> DeleteMessageAsync(string threadId, string messageId, RequestOptions options)
240 => _messageSubClient.DeleteMessageAsync(threadId, messageId, options);
241
242 /// <inheritdoc cref="InternalAssistantMessageClient.DeleteMessage"/>
243 public virtual ClientResult DeleteMessage(string threadId, string messageId, RequestOptions options)
244 => _messageSubClient.DeleteMessage(threadId, messageId, options);
245
246 /// <inheritdoc cref="InternalAssistantRunClient.CreateThreadAndRunAsync"/>
247 public virtual Task<ClientResult> CreateThreadAndRunAsync(BinaryContent content, RequestOptions options = null)
248 => _runSubClient.CreateThreadAndRunAsync(content, options);
249
250 /// <inheritdoc cref="InternalAssistantRunClient.CreateThreadAndRun"/>
251 public virtual ClientResult CreateThreadAndRun(BinaryContent content, RequestOptions options = null)
252 => _runSubClient.CreateThreadAndRun(content, options = null);
253
254 /// <inheritdoc cref="InternalAssistantRunClient.CreateRunAsync"/>
255 public virtual Task<ClientResult> CreateRunAsync(string threadId, BinaryContent content, RequestOptions options = null)
256 => _runSubClient.CreateRunAsync(threadId, content, options);
257
258 /// <inheritdoc cref="InternalAssistantRunClient.CreateRun"/>
259 public virtual ClientResult CreateRun(string threadId, BinaryContent content, RequestOptions options = null)
260 => _runSubClient.CreateRun(threadId, content, options);
261
262 /// <inheritdoc cref="InternalAssistantRunClient.GetRunsAsync"/>
263 public virtual Task<ClientResult> GetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options)
264 => _runSubClient.GetRunsAsync(threadId, limit, order, after, before, options);
265
266 /// <inheritdoc cref="InternalAssistantRunClient.GetRuns"/>
267 public virtual ClientResult GetRuns(string threadId, int? limit, string order, string after, string before, RequestOptions options)
268 => _runSubClient.GetRuns(threadId, limit, order, after, before, options);
269
270 /// <inheritdoc cref="InternalAssistantRunClient.GetRunAsync"/>
271 public virtual Task<ClientResult> GetRunAsync(string threadId, string runId, RequestOptions options)
272 => _runSubClient.GetRunAsync(threadId, runId, options);
273
274 /// <inheritdoc cref="InternalAssistantRunClient.GetRun"/>
275 public virtual ClientResult GetRun(string threadId, string runId, RequestOptions options)
276 => _runSubClient.GetRun(threadId, runId, options);
277
278 /// <inheritdoc cref="InternalAssistantRunClient.ModifyRunAsync"/>
279 public virtual Task<ClientResult> ModifyRunAsync(string threadId, string runId, BinaryContent content, RequestOptions options = null)
280 => _runSubClient.ModifyRunAsync(threadId, runId, content, options);
281
282 /// <inheritdoc cref="InternalAssistantRunClient.ModifyRun"/>
283 public virtual ClientResult ModifyRun(string threadId, string runId, BinaryContent content, RequestOptions options = null)
284 => _runSubClient.ModifyRun(threadId, runId, content, options);
285
286 /// <inheritdoc cref="InternalAssistantRunClient.CancelRunAsync"/>
287 public virtual Task<ClientResult> CancelRunAsync(string threadId, string runId, RequestOptions options)
288 => _runSubClient.CancelRunAsync(threadId, runId, options);
289
290 /// <inheritdoc cref="InternalAssistantRunClient.CancelRun"/>
291 public virtual ClientResult CancelRun(string threadId, string runId, RequestOptions options)
292 => _runSubClient.CancelRun(threadId, runId, options);
293
294 /// <inheritdoc cref="InternalAssistantRunClient.SubmitToolOutputsToRunAsync"/>
295 public virtual Task<ClientResult> SubmitToolOutputsToRunAsync(string threadId, string runId, BinaryContent content, RequestOptions options = null)
296 => _runSubClient.SubmitToolOutputsToRunAsync(threadId, runId, content, options);
297
298 /// <inheritdoc cref="InternalAssistantRunClient.SubmitToolOutputsToRun"/>
299 public virtual ClientResult SubmitToolOutputsToRun(string threadId, string runId, BinaryContent content, RequestOptions options = null)
300 => _runSubClient.SubmitToolOutputsToRun(threadId, runId, content, options);
301
302 /// <inheritdoc cref="InternalAssistantRunClient.GetRunStepsAsync"/>
303 public virtual Task<ClientResult> GetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options)
304 => _runSubClient.GetRunStepsAsync(threadId, runId, limit, order, after, before, options);
305
306 /// <inheritdoc cref="InternalAssistantRunClient.GetRunSteps"/>
307 public virtual ClientResult GetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options)
308 => _runSubClient.GetRunSteps(threadId, runId, limit, order, after, before, options);
309
310 /// <inheritdoc cref="InternalAssistantRunClient.GetRunStepAsync"/>
311 public virtual Task<ClientResult> GetRunStepAsync(string threadId, string runId, string stepId, RequestOptions options)
312 => _runSubClient.GetRunStepAsync(threadId, runId, stepId, options);
313
314 /// <inheritdoc cref="InternalAssistantRunClient.GetRunStep"/>
315 public virtual ClientResult GetRunStep(string threadId, string runId, string stepId, RequestOptions options)
316 => _runSubClient.GetRunStep(threadId, runId, stepId, options);
317
318 /// <inheritdoc cref="InternalAssistantThreadClient.CreateThreadAsync"/>
319 public virtual Task<ClientResult> CreateThreadAsync(BinaryContent content, RequestOptions options = null)
320 => _threadSubClient.CreateThreadAsync(content, options);
321
322 /// <inheritdoc cref="InternalAssistantThreadClient.CreateThread"/>
323 public virtual ClientResult CreateThread(BinaryContent content, RequestOptions options = null)
324 => _threadSubClient.CreateThread(content, options);
325
326 /// <inheritdoc cref="InternalAssistantThreadClient.GetThreadAsync"/>
327 public virtual Task<ClientResult> GetThreadAsync(string threadId, RequestOptions options)
328 => _threadSubClient.GetThreadAsync(threadId, options);
329
330 /// <inheritdoc cref="InternalAssistantThreadClient.GetThread"/>
331 public virtual ClientResult GetThread(string threadId, RequestOptions options)
332 => _threadSubClient.GetThread(threadId, options);
333
334 /// <inheritdoc cref="InternalAssistantThreadClient.ModifyThreadAsync"/>
335 public virtual Task<ClientResult> ModifyThreadAsync(string threadId, BinaryContent content, RequestOptions options = null)
336 => _threadSubClient.ModifyThreadAsync(threadId, content, options);
337
338 /// <inheritdoc cref="InternalAssistantThreadClient.ModifyThread"/>
339 public virtual ClientResult ModifyThread(string threadId, BinaryContent content, RequestOptions options = null)
340 => _threadSubClient.ModifyThread(threadId, content, options);
341
342 /// <inheritdoc cref="InternalAssistantThreadClient.DeleteThreadAsync"/>
343 public virtual Task<ClientResult> DeleteThreadAsync(string threadId, RequestOptions options)
344 => _threadSubClient.DeleteThreadAsync(threadId, options);
345
346 /// <inheritdoc cref="InternalAssistantThreadClient.DeleteThread"/>
347 public virtual ClientResult DeleteThread(string threadId, RequestOptions options)
348 => _threadSubClient.DeleteThread(threadId, options);
349}
350