Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,20 @@ private IEnumerable<ChatRequestMessage> ToAzureAIInferenceChatMessages(IEnumerab
}
else if (input.Role == ChatRole.User)
{
yield return input.Contents.All(c => c is TextContent) ?
new ChatRequestUserMessage(string.Concat(input.Contents)) :
new ChatRequestUserMessage(GetContentParts(input.Contents));
if (input.Contents.Count > 0)
{
if (input.Contents.All(c => c is TextContent))
{
if (string.Concat(input.Contents) is { Length: > 0 } text)
{
yield return new ChatRequestUserMessage(text);
}
}
else if (GetContentParts(input.Contents) is { Count: > 0 } parts)
{
yield return new ChatRequestUserMessage(parts);
}
}
}
else if (input.Role == ChatRole.Assistant)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ public virtual async Task GetResponseAsync_MultipleRequestMessages()
Assert.Contains("Asia", response.Text);
}

[ConditionalFact]
public virtual async Task GetResponseAsync_WithEmptyMessage()
{
SkipIfNotEnabled();

var response = await _chatClient.GetResponseAsync(
[
new(ChatRole.User, []),
new(ChatRole.User, "What is 1 + 2? Reply with a single number."),
]);

Assert.Contains("3", response.Text);
}

[ConditionalFact]
public virtual async Task GetStreamingResponseAsync()
{
Expand Down
Loading