openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
mailinhphan/clientOptions

Branches

Tags

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

Clone

HTTPS

Download ZIP

OpenAI/src/Custom/Assistants/Internal/InternalAssistantThreadClient.Protocol.cs

143lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.Threading.Tasks;
5
6namespace OpenAI.Assistants;
7
8internal partial class InternalAssistantThreadClient
9{
10 /// <summary>
11 /// [Protocol Method] Create a thread.
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> CreateThreadAsync(BinaryContent content, RequestOptions options = null)
19 {
20 using PipelineMessage message = CreateCreateThreadRequest(content, options);
21 return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
22 }
23
24 /// <summary>
25 /// [Protocol Method] Create a thread.
26 /// </summary>
27 /// <param name="content"> The content to send as the body of the request. </param>
28 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
29 /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
30 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
31 /// <returns> The response returned from the service. </returns>
32 public virtual ClientResult CreateThread(BinaryContent content, RequestOptions options = null)
33 {
34 using PipelineMessage message = CreateCreateThreadRequest(content, options);
35 return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
36 }
37
38 /// <summary>
39 /// [Protocol Method] Retrieves a thread.
40 /// </summary>
41 /// <param name="threadId"> The ID of the thread to retrieve. </param>
42 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
43 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> is null. </exception>
44 /// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
45 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
46 /// <returns> The response returned from the service. </returns>
47 public virtual async Task<ClientResult> GetThreadAsync(string threadId, RequestOptions options)
48 {
49 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
50
51 using PipelineMessage message = CreateGetThreadRequest(threadId, options);
52 return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
53 }
54
55 /// <summary>
56 /// [Protocol Method] Retrieves a thread.
57 /// </summary>
58 /// <param name="threadId"> The ID of the thread to retrieve. </param>
59 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
60 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> is null. </exception>
61 /// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
62 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
63 /// <returns> The response returned from the service. </returns>
64 public virtual ClientResult GetThread(string threadId, RequestOptions options)
65 {
66 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
67
68 using PipelineMessage message = CreateGetThreadRequest(threadId, options);
69 return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
70 }
71
72 /// <summary>
73 /// [Protocol Method] Modifies a thread.
74 /// </summary>
75 /// <param name="threadId"> The ID of the thread to modify. Only the `metadata` can be modified. </param>
76 /// <param name="content"> The content to send as the body of the request. </param>
77 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
78 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> or <paramref name="content"/> is null. </exception>
79 /// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
80 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
81 /// <returns> The response returned from the service. </returns>
82 public virtual async Task<ClientResult> ModifyThreadAsync(string threadId, BinaryContent content, RequestOptions options = null)
83 {
84 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
85 Argument.AssertNotNull(content, nameof(content));
86
87 using PipelineMessage message = CreateModifyThreadRequest(threadId, content, options);
88 return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
89 }
90
91 /// <summary>
92 /// [Protocol Method] Modifies a thread.
93 /// </summary>
94 /// <param name="threadId"> The ID of the thread to modify. Only the `metadata` can be modified. </param>
95 /// <param name="content"> The content to send as the body of the request. </param>
96 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
97 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> or <paramref name="content"/> is null. </exception>
98 /// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
99 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
100 /// <returns> The response returned from the service. </returns>
101 public virtual ClientResult ModifyThread(string threadId, BinaryContent content, RequestOptions options = null)
102 {
103 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
104 Argument.AssertNotNull(content, nameof(content));
105
106 using PipelineMessage message = CreateModifyThreadRequest(threadId, content, options);
107 return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
108 }
109
110 /// <summary>
111 /// [Protocol Method] Delete a thread.
112 /// </summary>
113 /// <param name="threadId"> The ID of the thread to delete. </param>
114 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
115 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> is null. </exception>
116 /// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
117 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
118 /// <returns> The response returned from the service. </returns>
119 public virtual async Task<ClientResult> DeleteThreadAsync(string threadId, RequestOptions options)
120 {
121 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
122
123 using PipelineMessage message = CreateDeleteThreadRequest(threadId, options);
124 return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
125 }
126
127 /// <summary>
128 /// [Protocol Method] Delete a thread.
129 /// </summary>
130 /// <param name="threadId"> The ID of the thread to delete. </param>
131 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
132 /// <exception cref="ArgumentNullException"> <paramref name="threadId"/> is null. </exception>
133 /// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
134 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
135 /// <returns> The response returned from the service. </returns>
136 public virtual ClientResult DeleteThread(string threadId, RequestOptions options)
137 {
138 Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
139
140 using PipelineMessage message = CreateDeleteThreadRequest(threadId, options);
141 return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
142 }
143}