Skip to content

Add thread message delete operation #50665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/ai/Azure.AI.Agents.Persistent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.1.0-beta.3 (Unreleased)

### Features Added
- Added delete operation for `ThreadMessages`.

- Tracing for Agents

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,8 @@ protected ThreadMessages() { }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Agents.Persistent.PersistentThreadMessage>> CreateMessageAsync(string threadId, Azure.AI.Agents.Persistent.MessageRole role, System.Collections.Generic.IEnumerable<Azure.AI.Agents.Persistent.MessageInputContentBlock> contentBlocks, System.Collections.Generic.IEnumerable<Azure.AI.Agents.Persistent.MessageAttachment> attachments = null, System.Collections.Generic.IReadOnlyDictionary<string, string> metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Agents.Persistent.PersistentThreadMessage>> CreateMessageAsync(string threadId, Azure.AI.Agents.Persistent.MessageRole role, string content, System.Collections.Generic.IEnumerable<Azure.AI.Agents.Persistent.MessageAttachment> attachments = null, System.Collections.Generic.IReadOnlyDictionary<string, string> metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> CreateMessageAsync(string threadId, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response<bool> DeleteMessage(string threadId, string messageId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<bool>> DeleteMessageAsync(string threadId, string messageId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response GetMessage(string threadId, string messageId, Azure.RequestContext context) { throw null; }
public virtual Azure.Response<Azure.AI.Agents.Persistent.PersistentThreadMessage> GetMessage(string threadId, string messageId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetMessageAsync(string threadId, string messageId, Azure.RequestContext context) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,8 @@ protected ThreadMessages() { }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Agents.Persistent.PersistentThreadMessage>> CreateMessageAsync(string threadId, Azure.AI.Agents.Persistent.MessageRole role, System.Collections.Generic.IEnumerable<Azure.AI.Agents.Persistent.MessageInputContentBlock> contentBlocks, System.Collections.Generic.IEnumerable<Azure.AI.Agents.Persistent.MessageAttachment> attachments = null, System.Collections.Generic.IReadOnlyDictionary<string, string> metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Agents.Persistent.PersistentThreadMessage>> CreateMessageAsync(string threadId, Azure.AI.Agents.Persistent.MessageRole role, string content, System.Collections.Generic.IEnumerable<Azure.AI.Agents.Persistent.MessageAttachment> attachments = null, System.Collections.Generic.IReadOnlyDictionary<string, string> metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> CreateMessageAsync(string threadId, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response<bool> DeleteMessage(string threadId, string messageId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<bool>> DeleteMessageAsync(string threadId, string messageId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response GetMessage(string threadId, string messageId, Azure.RequestContext context) { throw null; }
public virtual Azure.Response<Azure.AI.Agents.Persistent.PersistentThreadMessage> GetMessage(string threadId, string messageId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetMessageAsync(string threadId, string messageId, Azure.RequestContext context) { throw null; }
Expand Down
2 changes: 1 addition & 1 deletion sdk/ai/Azure.AI.Agents.Persistent/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/ai/Azure.AI.Agents.Persistent",
"Tag": "net/ai/Azure.AI.Agents.Persistent_2b964340aa"
"Tag": "net/ai/Azure.AI.Agents.Persistent_b9c9676b2c"
}
1 change: 1 addition & 0 deletions sdk/ai/Azure.AI.Agents.Persistent/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ description: Samples for the Azure.AI.Agents.Persistent client library.
| [Sample17_PersistentAgents_ImageUrlInputs](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample17_PersistentAgents_ImageUrlInputs.md) | Sample using agents with Image URL as an input. |
| [Sample18_PersistentAgents_ImageFileInputs](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample18_PersistentAgents_ImageFileInputs.md) | Sample using agents with Image Fileas an input. |
| [Sample19_PersistentAgents_VectorStoreFile_WithSteps](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample19_PersistentAgents_VectorStoreFile_WithSteps.md) | Sample file search using `VectorStoreFile` and agents. |
| [Sample20_PersistentAgents_FileSearch_Steaming](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample20_PersistentAgents_FileSearch_Steaming.md) | Sample file search with agent and streaming. |


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sample file search with agent in Azure.AI.Agents.Persistent.
# Sample file search with agent and streaming in Azure.AI.Agents.Persistent.

In this example we will create the local file, upload it to the newly created `VectorStore`, which will be used in the file search. In this example we will stream the result.

Expand Down
52 changes: 52 additions & 0 deletions sdk/ai/Azure.AI.Agents.Persistent/src/Custom/ThreadMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,5 +457,57 @@ internal virtual Pageable<BinaryData> GetMessages(string threadId, string runId,
HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMessagesRequest(threadId, runId, limit, order, after, before, context);
return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ThreadMessagesClient.GetMessages", "data", null, context);
}

/// <summary> Deletes a thread message. </summary>
/// <param name="threadId"> The ID of the thread to delete. </param>
/// <param name="messageId">The ID of the message to delete. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="threadId"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
public virtual Response<bool> DeleteMessage(
string threadId,
string messageId,
CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = ClientDiagnostics.CreateScope("PersistentAgentsClient.DeleteThread");
scope.Start();
Response<MessageDeletionStatus> baseResponse
= InternalDeleteMessage(
threadId:threadId,
messageId: messageId,
cancellationToken: cancellationToken);
bool simplifiedValue =
baseResponse.GetRawResponse() != null
&& !baseResponse.GetRawResponse().IsError
&& baseResponse.Value != null
&& baseResponse.Value.Deleted;
return Response.FromValue(simplifiedValue, baseResponse.GetRawResponse());
}

/// <summary> Deletes a thread message. </summary>
/// <param name="threadId"> The ID of the thread to delete. </param>
/// <param name="messageId">The ID of the message to delete. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="threadId"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="threadId"/> is an empty string, and was expected to be non-empty. </exception>
public virtual async Task<Response<bool>> DeleteMessageAsync(
string threadId,
string messageId,
CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = ClientDiagnostics.CreateScope("PersistentAgentsClient.DeleteThread");
scope.Start();
Response<MessageDeletionStatus> baseResponse
= await InternalDeleteMessageAsync(
threadId: threadId,
messageId: messageId,
cancellationToken: cancellationToken).ConfigureAwait(false);
bool simplifiedValue =
baseResponse.GetRawResponse() != null
&& !baseResponse.GetRawResponse().IsError
&& baseResponse.Value != null
&& baseResponse.Value.Deleted;
return Response.FromValue(simplifiedValue, baseResponse.GetRawResponse());
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading