OpenAIRealtimeExtensions.HandleToolCallsAsync Method

Definition

Handles tool calls.

If the update represents a tool call, calls the corresponding tool and adds the result to the session.

If the update represents the end of a response, checks if this was due to a tool call and if so, instructs the session to begin responding to it.

public static System.Threading.Tasks.Task HandleToolCallsAsync (this OpenAI.RealtimeConversation.RealtimeConversationSession session, OpenAI.RealtimeConversation.ConversationUpdate update, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.AIFunction> tools, bool? detailedErrors = False, System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = default, System.Threading.CancellationToken cancellationToken = default);
static member HandleToolCallsAsync : OpenAI.RealtimeConversation.RealtimeConversationSession * OpenAI.RealtimeConversation.ConversationUpdate * System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.AIFunction> * Nullable<bool> * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function HandleToolCallsAsync (session As RealtimeConversationSession, update As ConversationUpdate, tools As IReadOnlyList(Of AIFunction), Optional detailedErrors As Nullable(Of Boolean) = False, Optional jsonSerializerOptions As JsonSerializerOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

session
OpenAI.RealtimeConversation.RealtimeConversationSession

The OpenAI.RealtimeConversation.RealtimeConversationSession.

update
OpenAI.RealtimeConversation.ConversationUpdate

The OpenAI.RealtimeConversation.ConversationUpdate being processed.

tools
IReadOnlyList<AIFunction>

The available tools.

detailedErrors
Nullable<Boolean>

An optional flag specifying whether to disclose detailed exception information to the model. The default value is false.

jsonSerializerOptions
JsonSerializerOptions

An optional JsonSerializerOptions that controls JSON handling.

cancellationToken
CancellationToken

An optional CancellationToken.

Returns

A Task that represents the completion of processing, including invoking any asynchronous tools.

Applies to