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

398lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.ComponentModel;
5using System.Threading.Tasks;
6
7namespace OpenAI.Assistants;
8
9[CodeGenSuppress("GetAssistantsAsync", typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
10[CodeGenSuppress("GetAssistants", typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
11public partial class AssistantClient
12{
13 /// <summary>
14 /// [Protocol Method] Returns a paginated collection of assistants.
15 /// </summary>
16 /// <param name="limit">
17 /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
18 /// default is 20.
19 /// </param>
20 /// <param name="order">
21 /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
22 /// for descending order. Allowed values: "asc" | "desc"
23 /// </param>
24 /// <param name="after">
25 /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
26 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
27 /// subsequent call can include after=obj_foo in order to fetch the next page of the list.
28 /// </param>
29 /// <param name="before">
30 /// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
31 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
32 /// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
33 /// </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="ClientResultException"> Service returned a non-success status code. </exception>
36 /// <returns> A collection of service responses, each holding a page of values. </returns>
37 public virtual AsyncCollectionResult GetAssistantsAsync(int? limit, string order, string after, string before, RequestOptions options)
38 {
39 return new AsyncAssistantCollectionResult(this, Pipeline, options, limit, order, after, before);
40 }
41
42 /// <summary>
43 /// [Protocol Method] Returns a paginated collection 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> A collection of service responses, each holding a page of values. </returns>
66 public virtual CollectionResult GetAssistants(int? limit, string order, string after, string before, RequestOptions options)
67 {
68 return new AssistantCollectionResult(this, Pipeline, options, limit, order, after, before);
69 }
70
71 /// <inheritdoc cref="InternalAssistantMessageClient.CreateMessageAsync"/>
72 public virtual Task<ClientResult> CreateMessageAsync(string threadId, BinaryContent content, RequestOptions options = null)
73 => _messageSubClient.CreateMessageAsync(threadId, content, options);
74
75 /// <inheritdoc cref="InternalAssistantMessageClient.CreateMessage"/>
76 public virtual ClientResult CreateMessage(string threadId, BinaryContent content, RequestOptions options = null)
77 => _messageSubClient.CreateMessage(threadId, content, options);
78
79 /// <summary>
80 /// [Protocol Method] Returns a paginated collection of messages for a given thread.
81 /// </summary>
82 /// <param name="threadId"> The ID of the [thread](/docs/api-reference/threads) the messages belong to. </param>
83 /// <param name="limit">
84 /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
85 /// default is 20.
86 /// </param>
87 /// <param name="order">
88 /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
89 /// for descending order. Allowed values: "asc" | "desc"
90 /// </param>
91 /// <param name="after">
92 /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
93 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
94 /// subsequent call can include after=obj_foo in order to fetch the next page of the list.
95 /// </param>
96 /// <param name="before">
97 /// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
98 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
99 /// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
100 /// </param>
101 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
102 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> is null. </exception>
103 /// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
104 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
105 /// <returns> A collection of service responses, each holding a page of values. </returns>
106 public virtual AsyncCollectionResult GetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options)
107 {
108 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
109
110 return new AsyncMessageCollectionResult(_messageSubClient, options, threadId, limit, order, after, before);
111 }
112
113 /// <summary>
114 /// [Protocol Method] Returns a paginated collection of messages for a given thread.
115 /// </summary>
116 /// <param name="threadId"> The ID of the [thread](/docs/api-reference/threads) the messages belong to. </param>
117 /// <param name="limit">
118 /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
119 /// default is 20.
120 /// </param>
121 /// <param name="order">
122 /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
123 /// for descending order. Allowed values: "asc" | "desc"
124 /// </param>
125 /// <param name="after">
126 /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
127 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
128 /// subsequent call can include after=obj_foo in order to fetch the next page of the list.
129 /// </param>
130 /// <param name="before">
131 /// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
132 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
133 /// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
134 /// </param>
135 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
136 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> is null. </exception>
137 /// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
138 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
139 /// <returns> A collection of service responses, each holding a page of values. </returns>
140 public virtual CollectionResult GetMessages(string threadId, int? limit, string order, string after, string before, RequestOptions options)
141 {
142 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
143
144 return new MessageCollectionResult(_messageSubClient, options, threadId, limit, order, after, before);
145 }
146
147 /// <inheritdoc cref="InternalAssistantMessageClient.GetMessageAsync"/>
148 public virtual Task<ClientResult> GetMessageAsync(string threadId, string messageId, RequestOptions options)
149 => _messageSubClient.GetMessageAsync(threadId, messageId, options);
150
151 /// <inheritdoc cref="InternalAssistantMessageClient.GetMessage"/>
152 public virtual ClientResult GetMessage(string threadId, string messageId, RequestOptions options)
153 => _messageSubClient.GetMessage(threadId, messageId, options);
154
155 /// <inheritdoc cref="InternalAssistantMessageClient.ModifyMessageAsync"/>
156 public virtual Task<ClientResult> ModifyMessageAsync(string threadId, string messageId, BinaryContent content, RequestOptions options = null)
157 => _messageSubClient.ModifyMessageAsync(threadId, messageId, content, options);
158
159 /// <inheritdoc cref="InternalAssistantMessageClient.ModifyMessage"/>
160 public virtual ClientResult ModifyMessage(string threadId, string messageId, BinaryContent content, RequestOptions options = null)
161 => _messageSubClient.ModifyMessage(threadId, messageId, content, options);
162
163 /// <inheritdoc cref="InternalAssistantMessageClient.DeleteMessageAsync"/>
164 public virtual Task<ClientResult> DeleteMessageAsync(string threadId, string messageId, RequestOptions options)
165 => _messageSubClient.DeleteMessageAsync(threadId, messageId, options);
166
167 /// <inheritdoc cref="InternalAssistantMessageClient.DeleteMessage"/>
168 public virtual ClientResult DeleteMessage(string threadId, string messageId, RequestOptions options)
169 => _messageSubClient.DeleteMessage(threadId, messageId, options);
170
171 /// <inheritdoc cref="InternalAssistantRunClient.CreateThreadAndRunAsync"/>
172 public virtual Task<ClientResult> CreateThreadAndRunAsync(BinaryContent content, RequestOptions options = null)
173 => _runSubClient.CreateThreadAndRunAsync(content, options);
174
175 /// <inheritdoc cref="InternalAssistantRunClient.CreateThreadAndRun"/>
176 public virtual ClientResult CreateThreadAndRun(BinaryContent content, RequestOptions options = null)
177 => _runSubClient.CreateThreadAndRun(content, options = null);
178
179 /// <inheritdoc cref="InternalAssistantRunClient.CreateRunAsync"/>
180 public virtual Task<ClientResult> CreateRunAsync(string threadId, BinaryContent content, RequestOptions options = null)
181 => _runSubClient.CreateRunAsync(threadId, content, options);
182
183 /// <inheritdoc cref="InternalAssistantRunClient.CreateRun"/>
184 public virtual ClientResult CreateRun(string threadId, BinaryContent content, RequestOptions options = null)
185 => _runSubClient.CreateRun(threadId, content, options);
186
187 /// <summary>
188 /// [Protocol Method] Returns a paginated collection of runs belonging to a thread.
189 /// </summary>
190 /// <param name="threadId"> The ID of the thread the run belongs to. </param>
191 /// <param name="limit">
192 /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
193 /// default is 20.
194 /// </param>
195 /// <param name="order">
196 /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
197 /// for descending order. Allowed values: "asc" | "desc"
198 /// </param>
199 /// <param name="after">
200 /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
201 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
202 /// subsequent call can include after=obj_foo in order to fetch the next page of the list.
203 /// </param>
204 /// <param name="before">
205 /// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
206 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
207 /// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
208 /// </param>
209 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
210 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> is null. </exception>
211 /// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
212 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
213 /// <returns> A collection of service responses, each holding a page of values. </returns>
214 public virtual AsyncCollectionResult GetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options)
215 {
216 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
217
218 return new AsyncRunCollectionResult(_runSubClient, options, threadId, limit, order, after, before);
219 }
220
221 /// <summary>
222 /// [Protocol Method] Returns a paginated collection of runs belonging to a thread.
223 /// </summary>
224 /// <param name="threadId"> The ID of the thread the run belongs to. </param>
225 /// <param name="limit">
226 /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
227 /// default is 20.
228 /// </param>
229 /// <param name="order">
230 /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
231 /// for descending order. Allowed values: "asc" | "desc"
232 /// </param>
233 /// <param name="after">
234 /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
235 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
236 /// subsequent call can include after=obj_foo in order to fetch the next page of the list.
237 /// </param>
238 /// <param name="before">
239 /// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
240 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
241 /// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
242 /// </param>
243 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
244 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> is null. </exception>
245 /// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
246 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
247 /// <returns> A collection of service responses, each holding a page of values. </returns>
248 public virtual CollectionResult GetRuns(string threadId, int? limit, string order, string after, string before, RequestOptions options)
249 {
250 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
251
252 return new RunCollectionResult(_runSubClient, options, threadId, limit, order, after, before);
253 }
254
255 /// <inheritdoc cref="InternalAssistantRunClient.GetRunAsync"/>
256 public virtual Task<ClientResult> GetRunAsync(string threadId, string runId, RequestOptions options)
257 => _runSubClient.GetRunAsync(threadId, runId, options);
258
259 /// <inheritdoc cref="InternalAssistantRunClient.GetRun"/>
260 public virtual ClientResult GetRun(string threadId, string runId, RequestOptions options)
261 => _runSubClient.GetRun(threadId, runId, options);
262
263 /// <inheritdoc cref="InternalAssistantRunClient.ModifyRunAsync"/>
264 public virtual Task<ClientResult> ModifyRunAsync(string threadId, string runId, BinaryContent content, RequestOptions options = null)
265 => _runSubClient.ModifyRunAsync(threadId, runId, content, options);
266
267 /// <inheritdoc cref="InternalAssistantRunClient.ModifyRun"/>
268 public virtual ClientResult ModifyRun(string threadId, string runId, BinaryContent content, RequestOptions options = null)
269 => _runSubClient.ModifyRun(threadId, runId, content, options);
270
271 /// <inheritdoc cref="InternalAssistantRunClient.CancelRunAsync"/>
272 public virtual Task<ClientResult> CancelRunAsync(string threadId, string runId, RequestOptions options)
273 => _runSubClient.CancelRunAsync(threadId, runId, options);
274
275 /// <inheritdoc cref="InternalAssistantRunClient.CancelRun"/>
276 public virtual ClientResult CancelRun(string threadId, string runId, RequestOptions options)
277 => _runSubClient.CancelRun(threadId, runId, options);
278
279 /// <inheritdoc cref="InternalAssistantRunClient.SubmitToolOutputsToRunAsync"/>
280 public virtual Task<ClientResult> SubmitToolOutputsToRunAsync(string threadId, string runId, BinaryContent content, RequestOptions options = null)
281 => _runSubClient.SubmitToolOutputsToRunAsync(threadId, runId, content, options);
282
283 /// <inheritdoc cref="InternalAssistantRunClient.SubmitToolOutputsToRun"/>
284 public virtual ClientResult SubmitToolOutputsToRun(string threadId, string runId, BinaryContent content, RequestOptions options = null)
285 => _runSubClient.SubmitToolOutputsToRun(threadId, runId, content, options);
286
287 /// <summary>
288 /// [Protocol Method] Returns a paginated collection of run steps belonging to a run.
289 /// </summary>
290 /// <param name="threadId"> The ID of the thread the run and run steps belong to. </param>
291 /// <param name="runId"> The ID of the run the run steps belong to. </param>
292 /// <param name="limit">
293 /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
294 /// default is 20.
295 /// </param>
296 /// <param name="order">
297 /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
298 /// for descending order. Allowed values: "asc" | "desc"
299 /// </param>
300 /// <param name="after">
301 /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
302 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
303 /// subsequent call can include after=obj_foo in order to fetch the next page of the list.
304 /// </param>
305 /// <param name="before">
306 /// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
307 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
308 /// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
309 /// </param>
310 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
311 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> or <paramref name="runId"/> is null. </exception>
312 /// <exception cref="ArgumentException"> <paramref name="threadId"/> or <paramref name="runId"/> is an empty string, and was expected to be non-empty. </exception>
313 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
314 /// <returns> A collection of service responses, each holding a page of values. </returns>
315 public virtual AsyncCollectionResult GetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options)
316 {
317 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
318 Argument.AssertNotNullOrEmpty(runId, nameof(runId));
319
320 return new AsyncRunStepCollectionResult(_runSubClient, options, threadId, runId, limit, order, after, before);
321 }
322
323 /// <summary>
324 /// [Protocol Method] Returns a paginated collection of run steps belonging to a run.
325 /// </summary>
326 /// <param name="threadId"> The ID of the thread the run and run steps belong to. </param>
327 /// <param name="runId"> The ID of the run the run steps belong to. </param>
328 /// <param name="limit">
329 /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
330 /// default is 20.
331 /// </param>
332 /// <param name="order">
333 /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
334 /// for descending order. Allowed values: "asc" | "desc"
335 /// </param>
336 /// <param name="after">
337 /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
338 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
339 /// subsequent call can include after=obj_foo in order to fetch the next page of the list.
340 /// </param>
341 /// <param name="before">
342 /// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
343 /// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
344 /// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
345 /// </param>
346 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
347 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> or <paramref name="runId"/> is null. </exception>
348 /// <exception cref="ArgumentException"> <paramref name="threadId"/> or <paramref name="runId"/> is an empty string, and was expected to be non-empty. </exception>
349 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
350 /// <returns> A collection of service responses, each holding a page of values. </returns>
351 public virtual CollectionResult GetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options)
352 {
353 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
354 Argument.AssertNotNullOrEmpty(runId, nameof(runId));
355
356 return new RunStepCollectionResult(_runSubClient, options, threadId, runId, limit, order, after, before);
357 }
358
359 /// <inheritdoc cref="InternalAssistantRunClient.GetRunStepAsync"/>
360 public virtual Task<ClientResult> GetRunStepAsync(string threadId, string runId, string stepId, RequestOptions options)
361 => _runSubClient.GetRunStepAsync(threadId, runId, stepId, options);
362
363 /// <inheritdoc cref="InternalAssistantRunClient.GetRunStep"/>
364 public virtual ClientResult GetRunStep(string threadId, string runId, string stepId, RequestOptions options)
365 => _runSubClient.GetRunStep(threadId, runId, stepId, options);
366
367 /// <inheritdoc cref="InternalAssistantThreadClient.CreateThreadAsync"/>
368 public virtual Task<ClientResult> CreateThreadAsync(BinaryContent content, RequestOptions options = null)
369 => _threadSubClient.CreateThreadAsync(content, options);
370
371 /// <inheritdoc cref="InternalAssistantThreadClient.CreateThread"/>
372 public virtual ClientResult CreateThread(BinaryContent content, RequestOptions options = null)
373 => _threadSubClient.CreateThread(content, options);
374
375 /// <inheritdoc cref="InternalAssistantThreadClient.GetThreadAsync"/>
376 public virtual Task<ClientResult> GetThreadAsync(string threadId, RequestOptions options)
377 => _threadSubClient.GetThreadAsync(threadId, options);
378
379 /// <inheritdoc cref="InternalAssistantThreadClient.GetThread"/>
380 public virtual ClientResult GetThread(string threadId, RequestOptions options)
381 => _threadSubClient.GetThread(threadId, options);
382
383 /// <inheritdoc cref="InternalAssistantThreadClient.ModifyThreadAsync"/>
384 public virtual Task<ClientResult> ModifyThreadAsync(string threadId, BinaryContent content, RequestOptions options = null)
385 => _threadSubClient.ModifyThreadAsync(threadId, content, options);
386
387 /// <inheritdoc cref="InternalAssistantThreadClient.ModifyThread"/>
388 public virtual ClientResult ModifyThread(string threadId, BinaryContent content, RequestOptions options = null)
389 => _threadSubClient.ModifyThread(threadId, content, options);
390
391 /// <inheritdoc cref="InternalAssistantThreadClient.DeleteThreadAsync"/>
392 public virtual Task<ClientResult> DeleteThreadAsync(string threadId, RequestOptions options)
393 => _threadSubClient.DeleteThreadAsync(threadId, options);
394
395 /// <inheritdoc cref="InternalAssistantThreadClient.DeleteThread"/>
396 public virtual ClientResult DeleteThread(string threadId, RequestOptions options)
397 => _threadSubClient.DeleteThread(threadId, options);
398}
399