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