2 writes to Choices
Microsoft.Extensions.AI.Abstractions.Tests (2)
ChatCompletion\ChatResponseTests.cs (2)
81Assert.Throws<ArgumentNullException>("value", () => response.Choices = null!); 121response.Choices = newChoices;
53 references to Choices
Microsoft.Extensions.AI (7)
ChatCompletion\ChatResponse{T}.cs (3)
34: base(Throw.IfNull(response).Choices) 119var choice = Choices.Count == 1 ? Choices[0] : null;
ChatCompletion\FunctionInvokingChatClient.cs (2)
240|| response.Choices.Count == 0 250if (response.Choices.Count > 1)
ChatCompletion\OpenTelemetryChatClient.cs (2)
485int choiceCount = response.Choices.Count; 492Message = CreateAssistantEvent(response.Choices[choiceIndex]),
Microsoft.Extensions.AI.Abstractions (13)
ChatCompletion\ChatResponse.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; 101if (Choices.Count == 1) 103return Choices[0].ToString(); 107for (int i = 0; i < Choices.Count; i++) 114_ = sb.Append("Choice ").Append(i).AppendLine(":").Append(Choices[i]); 138int choicesCount = Choices.Count; 143ChatMessage choice = Choices[choiceIndex];
ChatCompletion\ChatResponseUpdateExtensions.cs (4)
164if (response.Choices.Count == 1 && 165response.Choices[0].AdditionalProperties is { } messageProps) 167response.Choices[0].AdditionalProperties = null; 196response.Choices.Add(entry.Value);
Microsoft.Extensions.AI.Abstractions.Tests (29)
ChatCompletion\ChatResponseTests.cs (14)
27Assert.Same(message, Assert.Single(response.Choices)); 41Assert.Same(messages, response.Choices); 50Assert.Empty(response.Choices); 61Assert.Same(message, response.Choices[0]); 74Assert.Same(first, response.Choices[0]); 122Assert.Same(newChoices, response.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(response.Choices[0].Text, response.ToString()); 194response.Choices[0] + Environment.NewLine + Environment.NewLine + 197response.Choices[1] + Environment.NewLine + Environment.NewLine + 200response.Choices[2],
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (15)
74Assert.Equal(3, response.Choices.Count); 76ChatMessage message = response.Choices[0]; 84message = response.Choices[1]; 93message = response.Choices[2]; 101Assert.Equal("Hello, world!", response.Choices[0].Text); 102Assert.Equal("Hey, you!", response.Choices[1].Text); 103Assert.Null(response.Choices[2].Text); 107Assert.Equal("Hello", response.Choices[0].Contents[0].ToString()); 108Assert.Equal(", ", response.Choices[0].Contents[1].ToString()); 109Assert.Equal("world!", response.Choices[0].Contents[2].ToString()); 111Assert.Equal("Hey", response.Choices[1].Contents[0].ToString()); 112Assert.Equal(", ", response.Choices[1].Contents[1].ToString()); 113Assert.Equal("you!", response.Choices[1].Contents[2].ToString()); 115Assert.Null(response.Choices[2].Text); 184Assert.Single(response.Choices);
Microsoft.Extensions.AI.Integration.Tests (1)
ChatClientIntegrationTests.cs (1)
104Assert.Single(response.Choices);
Microsoft.Extensions.AI.OpenAI (1)
OpenAIModelMapper.ChatCompletion.cs (1)
33if (response.Choices.Count > 1)
Microsoft.Extensions.AI.Tests (2)
ChatCompletion\UseDelegateChatClientTests.cs (2)
111cc.Choices[0].Text += " world"; 214cc.Choices[0].Text += " world (non-streaming)";