2 writes to Choices
Microsoft.Extensions.AI.Abstractions.Tests (2)
ChatCompletion\ChatCompletionTests.cs (2)
81
Assert.Throws<ArgumentNullException>("value", () => completion.
Choices
= null!);
121
completion.
Choices
= newChoices;
23 references to Choices
Microsoft.Extensions.AI (8)
ChatCompletion\ChatCompletion{T}.cs (3)
34
: base(Throw.IfNull(completion).
Choices
)
108
var choice =
Choices
.Count == 1 ?
Choices
[0] : null;
ChatCompletion\FunctionInvokingChatClient.cs (3)
189
|| response.
Choices
.Count == 0
199
if (response.
Choices
.Count > 1)
201
throw new InvalidOperationException($"Automatic function call invocation only accepts a single choice, but {response.
Choices
.Count} choices were received.");
ChatCompletion\OpenTelemetryChatClient.cs (2)
491
int choiceCount = completion.
Choices
.Count;
498
Message = CreateAssistantEvent(completion.
Choices
[choiceIndex]),
Microsoft.Extensions.AI.Abstractions (4)
ChatCompletion\ChatCompletion.cs (4)
43
/// If <see cref="
Choices
"/> is empty, this will throw. Use <see cref="
Choices
"/> to access all choices directly."/>.
49
var choices =
Choices
;
88
Choices
is { Count: > 0 } choices ? string.Join(Environment.NewLine, choices) : string.Empty;
Microsoft.Extensions.AI.Abstractions.Tests (10)
ChatCompletion\ChatCompletionTests.cs (10)
27
Assert.Same(message, Assert.Single(completion.
Choices
));
41
Assert.Same(messages, completion.
Choices
);
50
Assert.Empty(completion.
Choices
);
61
Assert.Same(message, completion.
Choices
[0]);
74
Assert.Same(first, completion.
Choices
[0]);
122
Assert.Same(newChoices, completion.
Choices
);
150
Assert.Equal(4, result.
Choices
.Count);
152
for (int i = 0; i < original.
Choices
.Count; i++)
154
Assert.Equal(ChatRole.Assistant, result.
Choices
[i].Role);
155
Assert.Equal($"Choice{i + 1}", result.
Choices
[i].Text);
Microsoft.Extensions.AI.Integration.Tests (1)
ChatClientIntegrationTests.cs (1)
101
Assert.Single(response.
Choices
);