15 writes to Contents
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
345update.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.OpenAI.Tests (2)
OpenAISerializationTests.cs (2)
600Contents = contents, 702Contents = [fcc],
Microsoft.Extensions.AI.Tests (4)
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
525new StreamingChatCompletionUpdate { Contents = [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["text"] = "Input 1" })] }, 526new StreamingChatCompletionUpdate { Contents = [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["text"] = "Input 2" })] }) 528new StreamingChatCompletionUpdate { Contents = [new TextContent("OK bye")] });
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
85Contents = [new UsageContent(new()
74 references to Contents
Microsoft.Extensions.AI (3)
ChatCompletion\FunctionInvokingChatClient.cs (3)
338functionCallContents.AddRange(update.Contents.OfType<FunctionCallContent>()); 345update.Contents = addedFccs == update.Contents.Count ? 346[] : 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)
185completionUpdate.Contents.Add(new TextContent(update)); 218completionUpdate.Contents.Add(new UsageContent(new() 251completionUpdate.Contents.Add(callContent);
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (2)
240Assert.Equal(i is < 10 or 11 ? 1 : 0, updates[i].Contents.Count); 875FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
Microsoft.Extensions.AI.Integration.Tests (1)
ChatClientIntegrationTests.cs (1)
131UsageContent usage = chunks.SelectMany(c => c.Contents).OfType<UsageContent>().Single();
Microsoft.Extensions.AI.Ollama (4)
OllamaChatClient.cs (4)
159update.Contents.Add(ToFunctionCallContent(function)); 165if (message.Content?.Length > 0 || update.Contents.Count == 0) 167update.Contents.Insert(0, new TextContent(message.Content)); 173update.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 (5)
OpenAIModelMappers.StreamingChatCompletion.cs (5)
31foreach (var content in chatCompletionUpdate.Contents) 54contentUpdate: [.. ToOpenAIChatContent(chatCompletionUpdate.Contents)], 122completionUpdate.Contents.Add(aiContent); 157completionUpdate.Contents.Add(new UsageContent(usageDetails)); 185completionUpdate.Contents.Add(callContent);
Microsoft.Extensions.AI.OpenAI.Tests (4)
OpenAIChatClientTests.cs (4)
276Assert.Equal(i == 10 ? 0 : 1, updates[i].Contents.Count); 280UsageContent usage = updates.SelectMany(u => u.Contents).OfType<UsageContent>().Single(); 870FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents)); 875UsageContent usage = updates.SelectMany(u => u.Contents).OfType<UsageContent>().Single();
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
551var allUpdateContents = updates.SelectMany(updates => updates.Contents).ToList();