Partager via


OpenAIAssistantAgent.InvokeStreamingAsync Method

Definition

Overloads

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

Invoke the agent with the provided message and arguments.

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

Invoke the agent with the provided message and arguments.

InvokeStreamingAsync(String, KernelArguments, Kernel, ChatHistory, CancellationToken)
Obsolete.

Invokes the assistant on the specified thread with streaming response.

InvokeStreamingAsync(String, RunCreationOptions, KernelArguments, Kernel, ChatHistory, CancellationToken)
Obsolete.

Invokes the assistant on the specified thread with streaming response.

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

Invoke the agent with the provided message and arguments.

public override 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);
override this.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 Overrides 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.

Applies to

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

Invoke the agent with the provided message and arguments.

public 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.OpenAI.OpenAIAssistantAgentInvokeOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
override this.InvokeStreamingAsync : System.Collections.Generic.ICollection<Microsoft.SemanticKernel.ChatMessageContent> * Microsoft.SemanticKernel.Agents.AgentThread * Microsoft.SemanticKernel.Agents.OpenAI.OpenAIAssistantAgentInvokeOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.Agents.AgentResponseItem<Microsoft.SemanticKernel.StreamingChatMessageContent>>
Public Function InvokeStreamingAsync (messages As ICollection(Of ChatMessageContent), Optional thread As AgentThread = Nothing, Optional options As OpenAIAssistantAgentInvokeOptions = 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
OpenAIAssistantAgentInvokeOptions

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, KernelArguments, Kernel, ChatHistory, CancellationToken)

Caution

Use InvokeStreamingAsync with AgentThread instead. This method will be removed after May 1st 2025.

Invokes the assistant on the specified thread with streaming response.

[System.Obsolete("Use InvokeStreamingAsync with AgentThread instead. This method will be removed after May 1st 2025.")]
public System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.StreamingChatMessageContent> InvokeStreamingAsync(string threadId, Microsoft.SemanticKernel.KernelArguments? arguments = default, Microsoft.SemanticKernel.Kernel? kernel = default, Microsoft.SemanticKernel.ChatCompletion.ChatHistory? messages = default, System.Threading.CancellationToken cancellationToken = default);
[<System.Obsolete("Use InvokeStreamingAsync with AgentThread instead. This method will be removed after May 1st 2025.")>]
override this.InvokeStreamingAsync : string * Microsoft.SemanticKernel.KernelArguments * Microsoft.SemanticKernel.Kernel * Microsoft.SemanticKernel.ChatCompletion.ChatHistory * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.StreamingChatMessageContent>
Public Function InvokeStreamingAsync (threadId As String, Optional arguments As KernelArguments = Nothing, Optional kernel As Kernel = Nothing, Optional messages As ChatHistory = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of StreamingChatMessageContent)

Parameters

threadId
String

The thread identifier.

arguments
KernelArguments

Optional arguments to pass to the agents's invocation, including any PromptExecutionSettings.

kernel
Kernel

The Kernel containing services, plugins, and other state for use by the agent.

messages
ChatHistory

Optional receiver of the completed messages that are generated.

cancellationToken
CancellationToken

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

Returns

An asynchronous enumeration of messages.

Attributes

Remarks

The "arguments" parameter is not currently used by the agent, but is provided for future extensibility.

Applies to

InvokeStreamingAsync(String, RunCreationOptions, KernelArguments, Kernel, ChatHistory, CancellationToken)

Caution

Use InvokeStreamingAsync with AgentThread instead. This method will be removed after May 1st 2025.

Invokes the assistant on the specified thread with streaming response.

[System.Obsolete("Use InvokeStreamingAsync with AgentThread instead. This method will be removed after May 1st 2025.")]
public System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.StreamingChatMessageContent> InvokeStreamingAsync(string threadId, OpenAI.Assistants.RunCreationOptions? options, Microsoft.SemanticKernel.KernelArguments? arguments = default, Microsoft.SemanticKernel.Kernel? kernel = default, Microsoft.SemanticKernel.ChatCompletion.ChatHistory? messages = default, System.Threading.CancellationToken cancellationToken = default);
[<System.Obsolete("Use InvokeStreamingAsync with AgentThread instead. This method will be removed after May 1st 2025.")>]
override this.InvokeStreamingAsync : string * OpenAI.Assistants.RunCreationOptions * Microsoft.SemanticKernel.KernelArguments * Microsoft.SemanticKernel.Kernel * Microsoft.SemanticKernel.ChatCompletion.ChatHistory * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.SemanticKernel.StreamingChatMessageContent>
Public Function InvokeStreamingAsync (threadId As String, options As RunCreationOptions, Optional arguments As KernelArguments = Nothing, Optional kernel As Kernel = Nothing, Optional messages As ChatHistory = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of StreamingChatMessageContent)

Parameters

threadId
String

The thread identifier.

options
OpenAI.Assistants.RunCreationOptions

Optional invocation options.

arguments
KernelArguments

Optional arguments to pass to the agents's invocation, including any PromptExecutionSettings.

kernel
Kernel

The Kernel containing services, plugins, and other state for use by the agent.

messages
ChatHistory

Optional receiver of the completed messages that are generated.

cancellationToken
CancellationToken

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

Returns

An asynchronous enumeration of messages.

Attributes

Remarks

The "arguments" parameter is not currently used by the agent, but is provided for future extensibility.

Applies to