10 writes to Contents
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
330update.Contents = addedFccs == update.Contents.Count ?
Microsoft.Extensions.AI.Abstractions (1)
ChatCompletion\ChatCompletion.cs (1)
140Contents = choice.Contents,
Microsoft.Extensions.AI.Abstractions.Tests (7)
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (2)
174updates.Add(new() { Contents = [new ImageContent("https://uri")] }); 199new() { Contents = [new UsageContent(new() { TotalTokenCount = 42 })] },
ChatCompletion\StreamingChatCompletionUpdateTests.cs (5)
49update.Contents = newList; 51update.Contents = null; 92Contents = 137Contents = 169Contents =
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
80Contents = [new UsageContent(new()
69 references to Contents
Microsoft.Extensions.AI (3)
ChatCompletion\FunctionInvokingChatClient.cs (3)
323functionCallContents.AddRange(update.Contents.OfType<FunctionCallContent>()); 330update.Contents = addedFccs == update.Contents.Count ? 331[] : update.Contents.Where(c => c is not FunctionCallContent).ToList();
Microsoft.Extensions.AI.Abstractions (8)
ChatCompletion\ChatCompletion.cs (1)
124extra.Contents.Add(new UsageContent(usage));
ChatCompletion\StreamingChatCompletionUpdate.cs (6)
59/// Gets or sets the text of the first <see cref="TextContent"/> instance in <see cref="Contents" />. 62/// If there is no <see cref="TextContent"/> instance in <see cref="Contents" />, then the getter returns <see langword="null" />, 68get => Contents.FindFirst<TextContent>()?.Text; 71if (Contents.FindFirst<TextContent>() is { } textContent) 77Contents.Add(new TextContent(value)); 118public override string ToString() => Contents.ConcatText();
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (1)
106((List<AIContent>)message.Contents).AddRange(update.Contents);
Microsoft.Extensions.AI.Abstractions.Tests (39)
ChatCompletion\ChatCompletionTests.cs (6)
277Assert.Equal("Hello, ", Assert.IsType<TextContent>(update0.Contents[0]).Text); 278Assert.IsType<ImageContent>(update0.Contents[1]); 279Assert.Equal("world!", Assert.IsType<TextContent>(update0.Contents[2]).Text); 288Assert.IsType<FunctionCallContent>(update1.Contents[0]); 289Assert.IsType<FunctionResultContent>(update1.Contents[1]); 295Assert.Equal(123, Assert.IsType<UsageContent>(Assert.Single(update2.Contents)).Details.TotalTokenCount);
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (2)
67Assert.Same(Assert.IsType<UsageContent>(updates[6].Contents[0]).Details, completion.Usage); 92Assert.Same(updates[7].Contents[0], Assert.Single(message.Contents));
ChatCompletion\StreamingChatCompletionUpdateTests.cs (31)
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); 103TextContent textContent = Assert.IsType<TextContent>(update.Contents[3]); 111Assert.Same(textContent, update.Contents[3]); 122Assert.Empty(update.Contents); 127Assert.Single(update.Contents); 128TextContent textContent = Assert.IsType<TextContent>(update.Contents[0]); 144Assert.Equal(3, update.Contents.Count); 148Assert.Equal(4, update.Contents.Count); 152Assert.Equal(4, update.Contents.Count); 154update.Contents.RemoveAt(3); 155Assert.Equal(3, update.Contents.Count); 159Assert.Equal(4, update.Contents.Count); 190Assert.Equal(5, result.Contents.Count); 192Assert.IsType<TextContent>(result.Contents[0]); 193Assert.Equal("text-1", ((TextContent)result.Contents[0]).Text); 195Assert.IsType<ImageContent>(result.Contents[1]); 196Assert.Equal("http://localhost/image", ((ImageContent)result.Contents[1]).Uri); 198Assert.IsType<FunctionCallContent>(result.Contents[2]); 199Assert.Equal("fc1", ((FunctionCallContent)result.Contents[2]).Name); 201Assert.IsType<DataContent>(result.Contents[3]); 202Assert.Equal("data"u8.ToArray(), ((DataContent)result.Contents[3]).Data?.ToArray()); 204Assert.IsType<TextContent>(result.Contents[4]); 205Assert.Equal("text-2", ((TextContent)result.Contents[4]).Text);
Microsoft.Extensions.AI.AzureAIInference (3)
AzureAIInferenceChatClient.cs (3)
183completionUpdate.Contents.Add(new TextContent(update)); 216completionUpdate.Contents.Add(new UsageContent(new() 249completionUpdate.Contents.Add(callContent);
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (2)
221Assert.Equal(i is < 10 or 11 ? 1 : 0, updates[i].Contents.Count); 623FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
Microsoft.Extensions.AI.Integration.Tests (1)
ChatClientIntegrationTests.cs (1)
132UsageContent usage = chunks.SelectMany(c => c.Contents).OfType<UsageContent>().Single();
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
163update.Contents.Add(new TextContent(message.Content)); 168update.Contents.Add(new UsageContent(usage));
Microsoft.Extensions.AI.Ollama.Tests (4)
OllamaChatClientTests.cs (4)
188Assert.Equal(i < updates.Count - 1 ? 1 : 2, updates[i].Contents.Count); 196Assert.Equal(2, updates[updates.Count - 1].Contents.Count); 197Assert.IsType<TextContent>(updates[updates.Count - 1].Contents[0]); 198UsageContent usage = Assert.IsType<UsageContent>(updates[updates.Count - 1].Contents[1]);
Microsoft.Extensions.AI.OpenAI (3)
OpenAIChatClient.cs (3)
259completionUpdate.Contents.Add(aiContent); 310completionUpdate.Contents.Add(new UsageContent(usageDetails)); 338completionUpdate.Contents.Add(callContent);
Microsoft.Extensions.AI.OpenAI.Tests (4)
OpenAIChatClientTests.cs (4)
270Assert.Equal(i == 10 ? 0 : 1, updates[i].Contents.Count); 274UsageContent usage = updates.SelectMany(u => u.Contents).OfType<UsageContent>().Single(); 776FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents)); 781UsageContent usage = updates.SelectMany(u => u.Contents).OfType<UsageContent>().Single();