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;
49 references to Choices
Microsoft.Extensions.AI (7)
ChatCompletion\ChatCompletion{T}.cs (3)
34
: base(Throw.IfNull(completion).
Choices
)
119
var choice =
Choices
.Count == 1 ?
Choices
[0] : null;
ChatCompletion\FunctionInvokingChatClient.cs (2)
207
|| response.
Choices
.Count == 0
217
if (response.
Choices
.Count > 1)
ChatCompletion\OpenTelemetryChatClient.cs (2)
453
int choiceCount = completion.
Choices
.Count;
460
Message = CreateAssistantEvent(completion.
Choices
[choiceIndex]),
Microsoft.Extensions.AI.Abstractions (10)
ChatCompletion\ChatCompletion.cs (9)
44
/// If <see cref="
Choices
"/> is empty, this property will throw. Use <see cref="
Choices
"/> to access all choices directly.
51
var choices =
Choices
;
91
if (
Choices
.Count == 1)
93
return
Choices
[0].ToString();
97
for (int i = 0; i <
Choices
.Count; i++)
104
_ = sb.Append("Choice ").Append(i).AppendLine(":").Append(
Choices
[i]);
128
int choicesCount =
Choices
.Count;
133
ChatMessage choice =
Choices
[choiceIndex];
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (1)
164
completion.
Choices
.Add(entry.Value);
Microsoft.Extensions.AI.Abstractions.Tests (29)
ChatCompletion\ChatCompletionTests.cs (14)
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);
179
Assert.Equal(completion.
Choices
[0].Text, completion.ToString());
194
completion.
Choices
[0] + Environment.NewLine + Environment.NewLine +
197
completion.
Choices
[1] + Environment.NewLine + Environment.NewLine +
200
completion.
Choices
[2],
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (15)
69
Assert.Equal(3, completion.
Choices
.Count);
71
ChatMessage message = completion.
Choices
[0];
79
message = completion.
Choices
[1];
88
message = completion.
Choices
[2];
96
Assert.Equal("Hello, world!", completion.
Choices
[0].Text);
97
Assert.Equal("Hey, you!", completion.
Choices
[1].Text);
98
Assert.Null(completion.
Choices
[2].Text);
102
Assert.Equal("Hello", completion.
Choices
[0].Contents[0].ToString());
103
Assert.Equal(", ", completion.
Choices
[0].Contents[1].ToString());
104
Assert.Equal("world!", completion.
Choices
[0].Contents[2].ToString());
106
Assert.Equal("Hey", completion.
Choices
[1].Contents[0].ToString());
107
Assert.Equal(", ", completion.
Choices
[1].Contents[1].ToString());
108
Assert.Equal("you!", completion.
Choices
[1].Contents[2].ToString());
110
Assert.Null(completion.
Choices
[2].Text);
179
Assert.Single(completion.
Choices
);
Microsoft.Extensions.AI.Integration.Tests (1)
ChatClientIntegrationTests.cs (1)
105
Assert.Single(response.
Choices
);
Microsoft.Extensions.AI.Tests (2)
ChatCompletion\UseDelegateChatClientTests.cs (2)
111
cc.
Choices
[0].Text += " world";
214
cc.
Choices
[0].Text += " world (non-streaming)";