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