ChatMessageExtensions.TryGetUserRequest Method

Definition

Overloads

TryGetUserRequest(IEnumerable<ChatMessage>, ChatMessage)

Given a collection of messages representing an LLM chat conversation, returns a single ChatMessage representing the last userRequest in this conversation.

TryGetUserRequest(IEnumerable<ChatMessage>, ChatMessage, IReadOnlyList<ChatMessage>)

Decomposes the supplied collection of messages representing an LLM chat conversation into a single ChatMessage representing the last userRequest in this conversation and a collection of remainingMessages representing the rest of the conversation history.

TryGetUserRequest(IEnumerable<ChatMessage>, ChatMessage)

Source:
ChatMessageExtensions.cs

Given a collection of messages representing an LLM chat conversation, returns a single ChatMessage representing the last userRequest in this conversation.

public:
[System::Runtime::CompilerServices::Extension]
 static bool TryGetUserRequest(System::Collections::Generic::IEnumerable<Microsoft::Extensions::AI::ChatMessage ^> ^ messages, [Runtime::InteropServices::Out] Microsoft::Extensions::AI::ChatMessage ^ % userRequest);
public static bool TryGetUserRequest(this System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages, out Microsoft.Extensions.AI.ChatMessage? userRequest);
static member TryGetUserRequest : seq<Microsoft.Extensions.AI.ChatMessage> * ChatMessage -> bool
<Extension()>
Public Function TryGetUserRequest (messages As IEnumerable(Of ChatMessage), ByRef userRequest As ChatMessage) As Boolean

Parameters

messages
IEnumerable<ChatMessage>

A collection of ChatMessages representing an LLM chat conversation history.

userRequest
ChatMessage

Returns the last ChatMessage in the supplied collection of messages if this last ChatMessage has Role set to User; null otherwise.

Returns

true if the last ChatMessage in the supplied collection of messages has Role set to User; false otherwise.

Applies to

TryGetUserRequest(IEnumerable<ChatMessage>, ChatMessage, IReadOnlyList<ChatMessage>)

Source:
ChatMessageExtensions.cs

Decomposes the supplied collection of messages representing an LLM chat conversation into a single ChatMessage representing the last userRequest in this conversation and a collection of remainingMessages representing the rest of the conversation history.

public:
[System::Runtime::CompilerServices::Extension]
 static bool TryGetUserRequest(System::Collections::Generic::IEnumerable<Microsoft::Extensions::AI::ChatMessage ^> ^ messages, [Runtime::InteropServices::Out] Microsoft::Extensions::AI::ChatMessage ^ % userRequest, [Runtime::InteropServices::Out] System::Collections::Generic::IReadOnlyList<Microsoft::Extensions::AI::ChatMessage ^> ^ % remainingMessages);
public static bool TryGetUserRequest(this System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages, out Microsoft.Extensions.AI.ChatMessage? userRequest, out System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage> remainingMessages);
static member TryGetUserRequest : seq<Microsoft.Extensions.AI.ChatMessage> * ChatMessage * IReadOnlyList -> bool
<Extension()>
Public Function TryGetUserRequest (messages As IEnumerable(Of ChatMessage), ByRef userRequest As ChatMessage, ByRef remainingMessages As IReadOnlyList(Of ChatMessage)) As Boolean

Parameters

messages
IEnumerable<ChatMessage>

A collection of ChatMessages representing an LLM chat conversation history.

userRequest
ChatMessage

Returns the last ChatMessage in the supplied collection of messages if this last ChatMessage has Role set to User; null otherwise.

remainingMessages
IReadOnlyList<ChatMessage>

Returns the remaining ChatMessages in the conversation history excluding userRequest.

Returns

true if the last ChatMessage in the supplied collection of messages has Role set to User; false otherwise.

Applies to