41 writes to Contents
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
415Contents = message.Contents,
Microsoft.Extensions.AI.Abstractions (1)
ChatCompletion\ChatResponse.cs (1)
135Contents = message.Contents,
Microsoft.Extensions.AI.Abstractions.Tests (26)
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (22)
35new() { Contents = [new UsageContent(new() { InputTokenCount = 1, OutputTokenCount = 2 })] }, 36new() { Contents = [new UsageContent(new() { InputTokenCount = 4, OutputTokenCount = 5 })] }, 187updates.Add(new() { Contents = [new DataContent("data:image/png;base64,aGVsbG8=")] }); 217new() { Contents = [new TextReasoningContent("D")] }, 218new() { Contents = [new TextReasoningContent("E")] }, 219new() { Contents = [new TextReasoningContent("F")] }, 222new() { Contents = [new TextReasoningContent("I")] }, 223new() { Contents = [new TextReasoningContent("J")] }, 225new() { Contents = [new TextReasoningContent("L")] }, 228new() { Contents = [new TextReasoningContent("O")] }, 229new() { Contents = [new TextReasoningContent("P")] }, 255new() { Contents = [new TextContent("D") { Annotations = [new()] }] }, 256new() { Contents = [new TextContent("E") { Annotations = [new()] }] }, 257new() { Contents = [new TextContent("F") { Annotations = [new()] }] }, 258new() { Contents = [new TextContent("G") { Annotations = [] }] }, 259new() { Contents = [new TextContent("H") { Annotations = [] }] }, 260new() { Contents = [new TextContent("I") { Annotations = [new()] }] }, 261new() { Contents = [new TextContent("J") { Annotations = [new()] }] }, 263new() { Contents = [new TextContent("L") { Annotations = [new()] }] }, 266new() { Contents = [new TextContent("O") { Annotations = [new()] }] }, 267new() { Contents = [new TextContent("P") { Annotations = [new()] }] }, 294new() { Contents = [new UsageContent(new() { TotalTokenCount = 42 })] },
ChatCompletion\ChatResponseUpdateTests.cs (4)
49update.Contents = newList; 51update.Contents = null; 90Contents = 119Contents =
Microsoft.Extensions.AI.OpenAI.Tests (1)
OpenAIConversionTests.cs (1)
622Contents =
Microsoft.Extensions.AI.Tests (12)
ChatCompletion\DistributedCachingChatClientTest.cs (8)
252Contents = 265Contents = [new FunctionCallContent("someCallId", "someFn", new Dictionary<string, object?> { ["arg1"] = "value1" })], 269Contents = [new UsageContent(new() { InputTokenCount = 123, OutputTokenCount = 456, TotalTokenCount = 99999 })], 315new() { Role = ChatRole.Assistant, Contents = [new FunctionCallContent("callId1", "separator")] }, 368new() { Role = ChatRole.Assistant, Contents = [new TextContent("Hello")] }, 369new() { Role = ChatRole.Assistant, Contents = [new TextContent(" world, ")] }, 373Contents = 384Contents =
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
743new() { Contents = [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["text"] = "Input 1" })] }, 744new() { Contents = [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["text"] = "Input 2" })] } 749updates = [new() { Contents = [new TextContent("OK bye")] }];
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
85Contents = [new UsageContent(new()
63 references to Contents
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvokingChatClient.cs (2)
359_ = CopyFunctionCalls(update.Contents, ref functionCallContents); 363IList<AIContent> contents = update.Contents;
Microsoft.Extensions.AI.Abstractions (5)
ChatCompletion\ChatResponse.cs (1)
120extra.Contents.Add(new UsageContent(usage));
ChatCompletion\ChatResponseExtensions.cs (3)
86var contentsList = filter is null ? update.Contents : update.Contents.Where(filter).ToList(); 357foreach (var content in update.Contents)
ChatCompletion\ChatResponseUpdate.cs (1)
78/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
Microsoft.Extensions.AI.Abstractions.Tests (23)
ChatCompletion\ChatResponseUpdateTests.cs (23)
20Assert.Empty(update.Contents); 43Assert.Empty(update.Contents); 44update.Contents.Add(new TextContent("text")); 45Assert.Single(update.Contents); 47Assert.Same(update.Contents, update.Contents); 50Assert.Same(newList, update.Contents); 52Assert.NotNull(update.Contents); 53Assert.Empty(update.Contents); 101TextContent textContent = Assert.IsType<TextContent>(update.Contents[3]); 106((TextContent)update.Contents[3]).Text = "text-3"; 108Assert.Same(textContent, update.Contents[3]); 140Assert.Equal(5, result.Contents.Count); 142Assert.IsType<TextContent>(result.Contents[0]); 143Assert.Equal("text-1", ((TextContent)result.Contents[0]).Text); 145Assert.IsType<DataContent>(result.Contents[1]); 146Assert.Equal("data:image/png;base64,aGVsbG8=", ((DataContent)result.Contents[1]).Uri); 148Assert.IsType<FunctionCallContent>(result.Contents[2]); 149Assert.Equal("fc1", ((FunctionCallContent)result.Contents[2]).Name); 151Assert.IsType<DataContent>(result.Contents[3]); 152Assert.Equal("data"u8.ToArray(), ((DataContent)result.Contents[3]).Data.ToArray()); 154Assert.IsType<TextContent>(result.Contents[4]); 155Assert.Equal("text-2", ((TextContent)result.Contents[4]).Text);
Microsoft.Extensions.AI.AzureAIInference (3)
AzureAIInferenceChatClient.cs (3)
180responseUpdate.Contents.Add(new TextContent(update)); 213responseUpdate.Contents.Add(new UsageContent(new() 247responseUpdate.Contents.Add(callContent);
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (2)
242Assert.Equal(i is < 10 or 11 ? 1 : 0, updates[i].Contents.Count); 1358FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
Microsoft.Extensions.AI.Integration.Tests (1)
ChatClientIntegrationTests.cs (1)
150UsageContent usage = chunks.SelectMany(c => c.Contents).OfType<UsageContent>().Single();
Microsoft.Extensions.AI.OpenAI (13)
MicrosoftExtensionsAIChatExtensions.cs (3)
134var usage = update.Contents.FirstOrDefault(c => c is UsageContent) is UsageContent usageContent ? 141var toolCallUpdates = update.Contents.OfType<FunctionCallContent>().Select((fcc, index) => 149new(OpenAIChatClient.ToOpenAIChatContent(update.Contents)),
OpenAIAssistantsChatClient.cs (5)
197ruUpdate.Contents.Add(new UsageContent(new() 212ruUpdate.Contents.Add(fcc); 248if (textUpdate.Contents.Count == 0) 251textUpdate.Contents.Add(new TextContent(string.Empty)); 254(((TextContent)textUpdate.Contents[0]).Annotations ??= []).Add(new CitationAnnotation
OpenAIChatClient.cs (5)
345ConvertContentParts(update.ContentUpdate, responseUpdate.Contents); 350responseUpdate.Contents.Add(new DataContent(audioUpdate.AudioBytesUpdate.ToMemory(), GetOutputAudioMimeType(options)) 385responseUpdate.Contents.Add(new UsageContent(FromOpenAIUsage(tokenUsage)) 417responseUpdate.Contents.Add(callContent); 425responseUpdate.Contents.Add(new ErrorContent(refusal.ToString()) { ErrorCode = "Refusal" });
Microsoft.Extensions.AI.OpenAI.Tests (6)
OpenAIChatClientTests.cs (4)
254Assert.Equal(i == 10 ? 0 : 1, updates[i].Contents.Count); 258UsageContent usage = updates.SelectMany(u => u.Contents).OfType<UsageContent>().Single(); 1330FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents)); 1335UsageContent usage = updates.SelectMany(u => u.Contents).OfType<UsageContent>().Single();
OpenAIResponseClientTests.cs (2)
271Assert.Equal((i >= 4 && i <= 12) || i == 16 ? 1 : 0, updates[i].Contents.Count); 280UsageContent usage = updates.SelectMany(u => u.Contents).OfType<UsageContent>().Single();
Microsoft.Extensions.AI.Tests (8)
ChatCompletion\DistributedCachingChatClientTest.cs (8)
345Assert.Collection(update.Contents, 355c => Assert.IsType<FunctionCallContent>(Assert.Single(c.Contents)), 424var content = Assert.IsType<TextContent>(Assert.Single(item.Contents)); 844Assert.Equal(expectedItem.Contents.Count, actualItem.Contents.Count); 846for (var itemIndex = 0; itemIndex < expectedItem.Contents.Count; itemIndex++) 848var expectedItemItem = expectedItem.Contents[itemIndex]; 849var actualItemItem = actualItem.Contents[itemIndex];