Share via


Agent.InvokeStreamingAsync Method

Definition

Overloads

InvokeStreamingAsync(AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with no message assuming that all required instructions are already provided to the agent or on the thread.

InvokeStreamingAsync(ChatMessageContent, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

InvokeStreamingAsync(ICollection<ChatMessageContent>, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

InvokeStreamingAsync(String, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

InvokeStreamingAsync(AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with no message assuming that all required instructions are already provided to the agent or on the thread.

public virtual System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>> InvokeStreamingAsync(Microsoft.SemanticKernel.Agents.AgentThread? thread = default, Microsoft.SemanticKernel.Agents.AgentInvokeOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member InvokeStreamingAsync : Microsoft.SemanticKernel.Agents.AgentThread * Microsoft.SemanticKernel.Agents.AgentInvokeOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>>
override this.InvokeStreamingAsync : Microsoft.SemanticKernel.Agents.AgentThread * Microsoft.SemanticKernel.Agents.AgentInvokeOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>>
Public Overridable Function InvokeStreamingAsync (Optional thread As AgentThread = Nothing, Optional options As AgentInvokeOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of AgentResponseItem(Of StreamingChatMessageContent))

Parameters

thread
AgentThread

The conversation thread to continue with this invocation. If not provided, creates a new thread.

options
AgentInvokeOptions

Optional parameters for agent invocation.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

An async list of response items that each contain a ChatMessageContent and an AgentThread.

Remarks

To continue this thread in the future, use an AgentThread returned in one of the response items.

Applies to

InvokeStreamingAsync(ChatMessageContent, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

public virtual System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>> InvokeStreamingAsync(Microsoft.SemanticKernel.ChatMessageContent message, Microsoft.SemanticKernel.Agents.AgentThread? thread = default, Microsoft.SemanticKernel.Agents.AgentInvokeOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member InvokeStreamingAsync : Microsoft.SemanticKernel.ChatMessageContent * Microsoft.SemanticKernel.Agents.AgentThread * Microsoft.SemanticKernel.Agents.AgentInvokeOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>>
override this.InvokeStreamingAsync : Microsoft.SemanticKernel.ChatMessageContent * Microsoft.SemanticKernel.Agents.AgentThread * Microsoft.SemanticKernel.Agents.AgentInvokeOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>>
Public Overridable Function InvokeStreamingAsync (message As ChatMessageContent, Optional thread As AgentThread = Nothing, Optional options As AgentInvokeOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of AgentResponseItem(Of StreamingChatMessageContent))

Parameters

message
ChatMessageContent

The message to pass to the agent.

thread
AgentThread

The conversation thread to continue with this invocation. If not provided, creates a new thread.

options
AgentInvokeOptions

Optional parameters for agent invocation.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

An async list of response items that each contain a StreamingChatMessageContent and an AgentThread.

Remarks

To continue this thread in the future, use an AgentThread returned in one of the response items.

Applies to

InvokeStreamingAsync(ICollection<ChatMessageContent>, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

public abstract System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>> InvokeStreamingAsync(System.Collections.Generic.ICollection<Microsoft.SemanticKernel.ChatMessageContent> messages, Microsoft.SemanticKernel.Agents.AgentThread? thread = default, Microsoft.SemanticKernel.Agents.AgentInvokeOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member InvokeStreamingAsync : System.Collections.Generic.ICollection<Microsoft.SemanticKernel.ChatMessageContent> * Microsoft.SemanticKernel.Agents.AgentThread * Microsoft.SemanticKernel.Agents.AgentInvokeOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>>
Public MustOverride Function InvokeStreamingAsync (messages As ICollection(Of ChatMessageContent), Optional thread As AgentThread = Nothing, Optional options As AgentInvokeOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of AgentResponseItem(Of StreamingChatMessageContent))

Parameters

messages
ICollection<ChatMessageContent>

The messages to pass to the agent.

thread
AgentThread

The conversation thread to continue with this invocation. If not provided, creates a new thread.

options
AgentInvokeOptions

Optional parameters for agent invocation.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

An async list of response items that each contain a StreamingChatMessageContent and an AgentThread.

Remarks

To continue this thread in the future, use an AgentThread returned in one of the response items.

Applies to

InvokeStreamingAsync(String, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

public virtual System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>> InvokeStreamingAsync(string message, Microsoft.SemanticKernel.Agents.AgentThread? thread = default, Microsoft.SemanticKernel.Agents.AgentInvokeOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member InvokeStreamingAsync : string * Microsoft.SemanticKernel.Agents.AgentThread * Microsoft.SemanticKernel.Agents.AgentInvokeOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>>
override this.InvokeStreamingAsync : string * Microsoft.SemanticKernel.Agents.AgentThread * Microsoft.SemanticKernel.Agents.AgentInvokeOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>>
Public Overridable Function InvokeStreamingAsync (message As String, Optional thread As AgentThread = Nothing, Optional options As AgentInvokeOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of AgentResponseItem(Of StreamingChatMessageContent))

Parameters

message
String

The message to pass to the agent.

thread
AgentThread

The conversation thread to continue with this invocation. If not provided, creates a new thread.

options
AgentInvokeOptions

Optional parameters for agent invocation.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

An async list of response items that each contain a ChatMessageContent and an AgentThread.

Remarks

The provided message string will be treated as a user message.

To continue this thread in the future, use an AgentThread returned in one of the response items.

Applies to