using System; using System.ClientModel; using System.ClientModel.Primitives; using System.Threading.Tasks; namespace OpenAI.Assistants; internal partial class InternalAssistantThreadClient { /// /// [Protocol Method] Create a thread. /// /// The content to send as the body of the request. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// Service returned a non-success status code. /// The response returned from the service. public virtual async Task CreateThreadAsync(BinaryContent content, RequestOptions options = null) { using PipelineMessage message = CreateCreateThreadRequest(content, options); return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// /// [Protocol Method] Create a thread. /// /// The content to send as the body of the request. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// Service returned a non-success status code. /// The response returned from the service. public virtual ClientResult CreateThread(BinaryContent content, RequestOptions options = null) { using PipelineMessage message = CreateCreateThreadRequest(content, options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// /// [Protocol Method] Retrieves a thread. /// /// The ID of the thread to retrieve. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. public virtual async Task GetThreadAsync(string threadId, RequestOptions options) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); using PipelineMessage message = CreateGetThreadRequest(threadId, options); return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// /// [Protocol Method] Retrieves a thread. /// /// The ID of the thread to retrieve. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. public virtual ClientResult GetThread(string threadId, RequestOptions options) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); using PipelineMessage message = CreateGetThreadRequest(threadId, options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// /// [Protocol Method] Modifies a thread. /// /// The ID of the thread to modify. Only the `metadata` can be modified. /// The content to send as the body of the request. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. public virtual async Task ModifyThreadAsync(string threadId, BinaryContent content, RequestOptions options = null) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNull(content, nameof(content)); using PipelineMessage message = CreateModifyThreadRequest(threadId, content, options); return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// /// [Protocol Method] Modifies a thread. /// /// The ID of the thread to modify. Only the `metadata` can be modified. /// The content to send as the body of the request. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. public virtual ClientResult ModifyThread(string threadId, BinaryContent content, RequestOptions options = null) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNull(content, nameof(content)); using PipelineMessage message = CreateModifyThreadRequest(threadId, content, options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// /// [Protocol Method] Delete a thread. /// /// The ID of the thread to delete. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. public virtual async Task DeleteThreadAsync(string threadId, RequestOptions options) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); using PipelineMessage message = CreateDeleteThreadRequest(threadId, options); return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// /// [Protocol Method] Delete a thread. /// /// The ID of the thread to delete. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. public virtual ClientResult DeleteThread(string threadId, RequestOptions options) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); using PipelineMessage message = CreateDeleteThreadRequest(threadId, options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } }