61 instantiations of TextContent
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatResponseExtensions.cs (1)
186Coalesce<TextContent>(contents, static text => new(text));
ChatCompletion\ChatResponseUpdate.cs (1)
51: this(role, content is null ? null : [new TextContent(content)])
Microsoft.Extensions.AI.Abstractions.Tests (28)
ChatCompletion\ChatMessageTests.cs (5)
89content.Add(new TextContent($"text-{i}")); 147new TextContent("text-1"), 148new TextContent("text-2"), 239new TextContent("content-1") 251new TextContent("content-4")
ChatCompletion\ChatResponseUpdateTests.cs (6)
44update.Contents.Add(new TextContent("text")); 48IList<AIContent> newList = [new TextContent("text")]; 95new TextContent("text-1"), 96new TextContent("text-2"), 121new TextContent("text-1"), 125new TextContent("text-2"),
Contents\TextContentTests.cs (2)
16TextContent c = new(text); 25TextContent c = new(null);
SpeechToText\SpeechToTextClientExtensionsTests.cs (1)
65update.Contents.Add(new TextContent("world"));
SpeechToText\SpeechToTextResponseTests.cs (9)
75content.Add(new TextContent($"text-{i}")); 132List<AIContent> newContents = [new TextContent("text1"), new TextContent("text2")]; 144new TextContent("Text1"), 145new TextContent("Text2"), 146new TextContent("Text3"), 147new TextContent("Text4"), 196new TextContent("Hello, "), 198new TextContent("world!")
SpeechToText\SpeechToTextResponseUpdateExtensionsTests.cs (1)
52new([new TextContent("You?")]) { ModelId = "model123", StartTime = TimeSpan.FromSeconds(24), EndTime = TimeSpan.FromSeconds(25), AdditionalProperties = new() { ["c"] = "d" } },
SpeechToText\SpeechToTextResponseUpdateTests.cs (4)
42newList.Add(new TextContent("content1")); 66new TextContent("text-1"), 67new TextContent("text-2"), 94new TextContent("text-1"),
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
170responseUpdate.Contents.Add(new TextContent(update));
Microsoft.Extensions.AI.AzureAIInference.Tests (3)
AzureAIInferenceChatClientTests.cs (3)
131[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] : 204[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] : 596new TextContent("Describe this picture."),
Microsoft.Extensions.AI.Evaluation.Integration.Tests (6)
SafetyEvaluatorTests.cs (6)
228new TextContent("What does this image depict?"), 257new TextContent("Here's an image pertaining to DotNet:"), 282new TextContent("What does this image depict?"), 295new TextContent("Here's an image pertaining to Microsoft Copilot:"), 322new TextContent("What does this image depict?"), 335new TextContent("Here's an image pertaining to Microsoft Copilot:"),
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (1)
SerializationChainingTests.cs (1)
34new TextContent("A user message"),
Microsoft.Extensions.AI.Integration.Tests (1)
ChatClientIntegrationTests.cs (1)
177new TextContent("What does this logo say?"),
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
274contents.Insert(0, new TextContent(message.Content));
Microsoft.Extensions.AI.OpenAI (4)
OpenAIChatClient.cs (1)
694aiContent = new TextContent(contentPart.Text);
OpenAIResponseChatClient.cs (1)
549results.Add(new TextContent(part.Text));
OpenAISpeechToTextClient.cs (2)
171response.Contents = [new TextContent(audioTranscription.Text)]; 239response.Contents = [new TextContent(audioTranslation.Text)];
Microsoft.Extensions.AI.OpenAI.Tests (4)
OpenAIChatClientTests.cs (4)
521new(ChatRole.System, [new TextContent("You are a really nice friend."), new TextContent("Really nice.")]), 1079new TextContent("hi, how are you?"), 1200new TextContent("What does this logo say?"),
Microsoft.Extensions.AI.Tests (10)
ChatCompletion\DistributedCachingChatClientTest.cs (5)
338new() { Role = ChatRole.Assistant, Contents = [new TextContent("Hello")] }, 339new() { Role = ChatRole.Assistant, Contents = [new TextContent(" world, ")] }, 345new TextContent("how ") 356new TextContent("are you?") 668new ChatMessage(ChatRole.Assistant, [new TextContent("Hey")])));
ChatCompletion\FunctionInvokingChatClientTests.cs (5)
407new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 411new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 603updates = [new() { Contents = [new TextContent("OK bye")] }]; 767? [new TextContent($"The search results were '{string.Join(", ", frcs.Select(frc => frc.Result))}'")]
89 references to TextContent
Microsoft.Extensions.AI (1)
ChatCompletion\OpenTelemetryChatClient.cs (1)
545string content = string.Concat(contents.OfType<TextContent>());
Microsoft.Extensions.AI.Abstractions (21)
ChatCompletion\ChatMessage.cs (1)
73/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
ChatCompletion\ChatResponseExtensions.cs (9)
54/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 107/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 130/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 158/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 186Coalesce<TextContent>(contents, static text => new(text));
ChatCompletion\ChatResponseUpdate.cs (1)
76/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
Contents\AIContent.cs (1)
14[JsonDerivedType(typeof(TextContent), typeDiscriminator: "text")]
Contents\AIContentExtensions.cs (4)
18/// <summary>Concatenates the text of all <see cref="TextContent"/> instances in the list.</summary> 30return (list[0] as TextContent)?.Text ?? string.Empty; 37if (list[i] is TextContent text) 59return string.Concat(contents.OfType<TextContent>());
Contents\TextContent.cs (1)
18/// Initializes a new instance of the <see cref="TextContent"/> class.
Contents\TextReasoningContent.cs (2)
13/// <see cref="TextReasoningContent"/> is distinct from <see cref="TextContent"/>. <see cref="TextReasoningContent"/> 15/// the model, which is represented by <see cref="TextContent"/>. Neither types derives from the other.
SpeechToText\SpeechToTextResponse.cs (1)
67/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
SpeechToText\SpeechToTextResponseUpdate.cs (1)
87/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
Microsoft.Extensions.AI.Abstractions.Tests (39)
ChatCompletion\ChatMessageTests.cs (11)
48TextContent tc = Assert.IsType<TextContent>(message.Contents[0]); 107TextContent tc = Assert.IsType<TextContent>(message.Contents[i]); 152TextContent textContent = Assert.IsType<TextContent>(message.Contents[3]); 157((TextContent)message.Contents[3]).Text = "text-3"; 265((TextContent)chatMessage.Contents[0]).Text = "content-1-override"; // Override the content of the first text content item that has the "content-1" content 280var textContent = deserializedMessage.Contents[0] as TextContent; 303textContent = deserializedMessage.Contents[3] as TextContent;
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (7)
140TextContent[] contents = message.Contents.OfType<TextContent>().ToArray(); 176Assert.Equal("ABC", Assert.IsType<TextContent>(message.Contents[0]).Text); 178Assert.Equal("GH", Assert.IsType<TextContent>(message.Contents[2]).Text); 180Assert.Equal("K", Assert.IsType<TextContent>(message.Contents[4]).Text); 182Assert.Equal("MN", Assert.IsType<TextContent>(message.Contents[6]).Text); 203Assert.Equal("Hello, world!", Assert.IsType<TextContent>(Assert.Single(Assert.Single(response.Messages).Contents)).Text);
ChatCompletion\ChatResponseUpdateTests.cs (7)
101TextContent textContent = Assert.IsType<TextContent>(update.Contents[3]); 106((TextContent)update.Contents[3]).Text = "text-3"; 142Assert.IsType<TextContent>(result.Contents[0]); 143Assert.Equal("text-1", ((TextContent)result.Contents[0]).Text); 154Assert.IsType<TextContent>(result.Contents[4]); 155Assert.Equal("text-2", ((TextContent)result.Contents[4]).Text);
Contents\TextContentTests.cs (2)
16TextContent c = new(text); 25TextContent c = new(null);
SpeechToText\SpeechToTextResponseTests.cs (7)
51TextContent tc = Assert.IsType<TextContent>(response.Contents[0]); 91TextContent tc = Assert.IsType<TextContent>(response.Contents[i]); 166Assert.Equal($"Text{i + 1}", ((TextContent)result.Contents[i]).Text); 221Assert.Equal("Hello, ", Assert.IsType<TextContent>(update.Contents[0]).Text); 223Assert.Equal("world!", Assert.IsType<TextContent>(update.Contents[2]).Text);
SpeechToText\SpeechToTextResponseUpdateExtensionsTests.cs (2)
124TextContent[] contents = response.Contents.OfType<TextContent>().ToArray();
SpeechToText\SpeechToTextResponseUpdateTests.cs (2)
72TextContent textContent = Assert.IsType<TextContent>(update.Contents[3]);
Utilities\AIJsonUtilitiesTests.cs (1)
486Assert.Throws<ArgumentException>(() => options.AddAIContentType<TextContent>("discriminator"));
Microsoft.Extensions.AI.AzureAIInference (3)
AzureAIInferenceChatClient.cs (3)
448if (input.Contents.All(c => c is TextContent)) 465ChatRequestAssistantMessage message = new(string.Concat(input.Contents.Where(c => c is TextContent))); 494case TextContent textContent:
Microsoft.Extensions.AI.Evaluation (2)
EvaluationContext.cs (2)
23/// <see cref="TextContent"/> objects for text, <see cref="DataContent"/> or <see cref="UriContent"/> objects for 29/// <see cref="TextContent"/> object that includes the contained text.
Microsoft.Extensions.AI.Evaluation.Safety (3)
AIContentExtensions.cs (1)
10=> content is TextContent || content is UsageContent;
ContentSafetyEvaluator.cs (2)
130content.OfType<TextContent>() is IEnumerable<TextContent> textContent && textContent.Any() &&
Microsoft.Extensions.AI.Integration.Tests (5)
ChatClientIntegrationTests.cs (4)
161var singleTextContent = (TextContent)history[1].Contents.Single(); 498((TextContent)message.Contents[0]).Text += "!"; 532((TextContent)message.Contents[0]).Text += "!";
ReducingChatClientTests.cs (1)
160if (content is TextContent text)
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
435case TextContent textContent:
Microsoft.Extensions.AI.Ollama.Tests (1)
OllamaChatClientTests.cs (1)
202Assert.IsType<TextContent>(updates[updates.Count - 1].Contents[0]);
Microsoft.Extensions.AI.OpenAI (3)
OpenAIChatClient.cs (1)
188case TextContent textContent:
OpenAIResponseChatClient.cs (2)
495case TextContent textContent: 564case TextContent textContent:
Microsoft.Extensions.AI.OpenAI.Tests (2)
OpenAIChatClientTests.cs (2)
855TextContent fcc = Assert.IsType<TextContent>(response.Messages.Single().Contents[0]);
Microsoft.Extensions.AI.Tests (8)
ChatCompletion\DistributedCachingChatClientTest.cs (4)
316c => Assert.Equal("This becomes one chunk", Assert.IsType<TextContent>(c).Text), 318c => Assert.Equal("... and this becomes another one.", Assert.IsType<TextContent>(c).Text)); 394var content = Assert.IsType<TextContent>(Assert.Single(item.Contents));
ChatCompletion\FunctionInvokingChatClientTests.cs (2)
627m => Assert.Equal("OK bye", Assert.IsType<TextContent>(Assert.Single(m.Contents)).Text)); 667Assert.IsType<TextContent>(Assert.Single(response.Messages[4].Contents));
ChatCompletion\UseDelegateChatClientTests.cs (2)
103cc.Messages.SelectMany(c => c.Contents).OfType<TextContent>().Last().Text += " world"; 206cc.Messages.SelectMany(c => c.Contents).OfType<TextContent>().Last().Text += " world (non-streaming)";