Share via


AgentsClient.CreateMessageAsync Method

Definition

Overloads

CreateMessageAsync(String, MessageRole, String, IEnumerable<MessageAttachment>, IReadOnlyDictionary<String,String>, CancellationToken)

Creates a new message on a specified thread.

CreateMessageAsync(String, RequestContent, RequestContext)

[Protocol Method] Creates a new message on a specified thread.

CreateMessageAsync(String, MessageRole, String, IEnumerable<MessageAttachment>, IReadOnlyDictionary<String,String>, CancellationToken)

Source:
AgentsClient.cs

Creates a new message on a specified thread.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Projects.ThreadMessage>> CreateMessageAsync (string threadId, Azure.AI.Projects.MessageRole role, string content, System.Collections.Generic.IEnumerable<Azure.AI.Projects.MessageAttachment> attachments = default, System.Collections.Generic.IReadOnlyDictionary<string,string> metadata = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateMessageAsync : string * Azure.AI.Projects.MessageRole * string * seq<Azure.AI.Projects.MessageAttachment> * System.Collections.Generic.IReadOnlyDictionary<string, string> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Projects.ThreadMessage>>
override this.CreateMessageAsync : string * Azure.AI.Projects.MessageRole * string * seq<Azure.AI.Projects.MessageAttachment> * System.Collections.Generic.IReadOnlyDictionary<string, string> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Projects.ThreadMessage>>
Public Overridable Function CreateMessageAsync (threadId As String, role As MessageRole, content As String, Optional attachments As IEnumerable(Of MessageAttachment) = Nothing, Optional metadata As IReadOnlyDictionary(Of String, String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of ThreadMessage))

Parameters

threadId
String

Identifier of the thread.

role
MessageRole

The role of the entity that is creating the message. Allowed values include:

  • user: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.
  • assistant: Indicates the message is generated by the agent. Use this value to insert messages from the agent into the conversation.
content
String

The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via a separate call to the create message API.

attachments
IEnumerable<MessageAttachment>

A list of files attached to the message, and the tools they should be added to.

metadata
IReadOnlyDictionary<String,String>

A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

threadId or content is null.

threadId is an empty string, and was expected to be non-empty.

Applies to

CreateMessageAsync(String, RequestContent, RequestContext)

Source:
AgentsClient.cs

[Protocol Method] Creates a new message on a specified thread.

public virtual System.Threading.Tasks.Task<Azure.Response> CreateMessageAsync (string threadId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateMessageAsync : string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.CreateMessageAsync : string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function CreateMessageAsync (threadId As String, content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Response)

Parameters

threadId
String

Identifier of the thread.

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

threadId or content is null.

threadId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Applies to