172 instantiations of TextContent
Microsoft.Extensions.AI (2)
ChatCompletion\ImageGeneratingChatClient.cs (1)
179newContents.Add(new TextContent($"[{ImageKey}:{imageId}] available for edit.")
ChatCompletion\OpenTelemetryImageGenerator.cs (1)
189content.Add(new TextContent(request.Prompt));
Microsoft.Extensions.AI.Abstractions (7)
ChatCompletion\ChatMessage.cs (2)
31: this(role, content is null ? [] : [new TextContent(content)]) 116!string.IsNullOrWhiteSpace(text) ? new TextContent(text) :
ChatCompletion\ChatResponseExtensions.cs (1)
235static (contents, start, end) => new(MergeText(contents, start, end)) { AdditionalProperties = contents[start].AdditionalProperties?.Clone() });
ChatCompletion\ChatResponseUpdate.cs (2)
49: this(role, content is null ? null : [new TextContent(content)]) 186!string.IsNullOrWhiteSpace(text) ? new TextContent(text) :
SpeechToText\SpeechToTextResponse.cs (1)
36: this(content is null ? [] : [new TextContent(content)])
SpeechToText\SpeechToTextResponseUpdate.cs (1)
53: this(content is null ? [] : [new TextContent(content)])
Microsoft.Extensions.AI.Abstractions.Tests (54)
ChatCompletion\ChatMessageTests.cs (5)
90content.Add(new TextContent($"text-{i}")); 149new TextContent("text-1"), 150new TextContent("text-2"), 255new TextContent("content-1") 267new TextContent("content-4")
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (10)
767new() { Contents = [new TextContent("D") { Annotations = [new()] }] }, 768new() { Contents = [new TextContent("E") { Annotations = [new()] }] }, 769new() { Contents = [new TextContent("F") { Annotations = [new()] }] }, 770new() { Contents = [new TextContent("G") { Annotations = [] }] }, 771new() { Contents = [new TextContent("H") { Annotations = [] }] }, 772new() { Contents = [new TextContent("I") { Annotations = [new()] }] }, 773new() { Contents = [new TextContent("J") { Annotations = [new()] }] }, 775new() { Contents = [new TextContent("L") { Annotations = [new()] }] }, 778new() { Contents = [new TextContent("O") { Annotations = [new()] }] }, 779new() { Contents = [new TextContent("P") { Annotations = [new()] }] },
ChatCompletion\ChatResponseUpdateTests.cs (10)
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"), 176var originalContents = new List<AIContent> { new TextContent("text1"), new TextContent("text2") }; 306var sharedContents = new List<AIContent> { new TextContent("initial") }; 319sharedContents.Add(new TextContent("added"));
Contents\AIContentTests.cs (1)
63new TextContent("a"),
Contents\CodeInterpreterToolCallContentTests.cs (3)
32IList<AIContent> inputs = [new TextContent("print('hello')")]; 55new TextContent("import numpy as np"), 76new TextContent("print('hello')"),
Contents\CodeInterpreterToolResultContentTests.cs (3)
32IList<AIContent> output = [new TextContent("Hello, World!")]; 55new TextContent("Execution completed"), 78new TextContent("Hello, World!"),
Contents\McpServerToolResultContentTests.cs (1)
58Output = new List<AIContent> { new TextContent("result") }
Contents\TextContentTests.cs (3)
17TextContent c = new(text); 26TextContent c = new(null); 55var content = new TextContent("Hello, world!");
Image\ImageGenerationResponseTests.cs (1)
139new TextContent("Generated image description") // Edge case: text content in image response
SpeechToText\SpeechToTextClientExtensionsTests.cs (1)
65update.Contents.Add(new TextContent("world"));
SpeechToText\SpeechToTextResponseTests.cs (9)
76content.Add(new TextContent($"text-{i}")); 133List<AIContent> newContents = [new TextContent("text1"), new TextContent("text2")]; 150new TextContent("Text1"), 151new TextContent("Text2"), 152new TextContent("Text3"), 153new TextContent("Text4"), 210new TextContent("Hello, "), 212new TextContent("world!")
SpeechToText\SpeechToTextResponseUpdateExtensionsTests.cs (3)
52new([new TextContent("You?")]) { ModelId = "model123", StartTime = TimeSpan.FromSeconds(24), EndTime = TimeSpan.FromSeconds(25), AdditionalProperties = new() { ["c"] = "d" } }, 139new() { Contents = [new TextContent("Hello, ")] }, 141new() { Contents = [new TextContent("world!")] },
SpeechToText\SpeechToTextResponseUpdateTests.cs (4)
41List<AIContent> newList = [new TextContent("content1")]; 65new TextContent("text-1"), 66new TextContent("text-2"), 93new TextContent("text-1"),
Microsoft.Extensions.AI.Evaluation (1)
EvaluationContext.cs (1)
127: this(name, contents: new TextContent(content))
Microsoft.Extensions.AI.Evaluation.Integration.Tests (6)
SafetyEvaluatorTests.cs (6)
340new TextContent("What does this image depict?"), 378new TextContent("Here's an image pertaining to DotNet:"), 412new TextContent("What does this image depict?"), 425new TextContent("Here's an image pertaining to Microsoft Copilot:"), 461new TextContent("What does this image depict?"), 474new TextContent("Here's an image pertaining to Microsoft Copilot:"),
Microsoft.Extensions.AI.Evaluation.NLP (2)
BLEUEvaluatorContext.cs (1)
54contents: [.. references.Select(c => new TextContent(c))])
GLEUEvaluatorContext.cs (1)
54contents: [.. references.Select(c => new TextContent(c))])
Microsoft.Extensions.AI.Evaluation.Quality (4)
IntentResolutionEvaluatorContext.cs (1)
43: base(name: ToolDefinitionsContextName, contents: [new TextContent(toolDefinitions.RenderAsJson())])
RetrievalEvaluatorContext.cs (1)
47contents: [.. retrievedContextChunks.Select(c => new TextContent(c))])
TaskAdherenceEvaluatorContext.cs (1)
44: base(name: ToolDefinitionsContextName, contents: [new TextContent(toolDefinitions.RenderAsJson())])
ToolCallAccuracyEvaluatorContext.cs (1)
45: base(name: ToolDefinitionsContextName, contents: [new TextContent(toolDefinitions.RenderAsJson())])
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (7)
ScenarioRunResultTests.cs (6)
23var content1 = new TextContent("content1"); 24var content2 = new TextContent("content2"); 25var content3 = new TextContent("content3"); 115var content1 = new TextContent("content1"); 116var content2 = new TextContent("content2"); 117var content3 = new TextContent("content3");
SerializationChainingTests.cs (1)
31Contents = [new TextContent("A user message")]
Microsoft.Extensions.AI.Integration.Tests (6)
ChatClientIntegrationTests.cs (2)
195new TextContent("What does this logo say?"), 213new TextContent("What text does this document contain?"),
ImageGeneratingChatClientIntegrationTests.cs (2)
167[new ChatMessage(ChatRole.User, [new TextContent("Please edit this image to add a red border"), originalImageData])], 382new TextContent("Here's an image to process"),
ToolReductionTests.cs (2)
281new TextContent(answerLine) 312new TextContent(textOnly)
Microsoft.Extensions.AI.OpenAI (11)
OpenAIAssistantsChatClient.cs (2)
239(hcitrc.Outputs ??= []).Add(new TextContent(logs)); 287textUpdate.Contents.Add(new TextContent(string.Empty));
OpenAIChatClient.cs (2)
545annotationContent = new(null); 759aiContent = new TextContent(contentPart.Text);
OpenAIResponsesChatClient.cs (4)
403yield return CreateUpdate(new TextContent(outputTextDeltaUpdate.Delta)); 1262TextContent text = new(part.Text); 1382new TextContent(mtci.ToolOutput)], 1404CodeInterpreterCallLogsOutput ciclo => new TextContent(ciclo.Logs) { RawRepresentation = ciclo },
OpenAISpeechToTextClient.cs (3)
73response.Contents = [new TextContent(translation.Text)]; 87response.Contents = [new TextContent(transcription.Text)]; 145result.Contents = [new TextContent(deltaUpdate.Delta)];
Microsoft.Extensions.AI.OpenAI.Tests (28)
OpenAIChatClientTests.cs (5)
927new(ChatRole.System, [new TextContent("You are a really nice friend."), new TextContent("Really nice.")]), 1469new TextContent("hi, how are you?"), 1475new FunctionResultContent("12345", new TextContent("Said hello")), 1587new TextContent("What does this logo say?"),
OpenAIConversionTests.cs (12)
645new TextContent("Hi there!"), 714new TextContent("Hi there!"), 765new TextContent("Hello, "), 768new TextContent("World"), 769new TextContent("!"), 773new TextContent("Hi!"), 954new TextContent("I'll call a function."), 990new TextContent("Here's an image and some text."), 1059new TextContent("I'll process this complex data."), 1314new TextContent("Processing your request..."), 1556new TextContent("Third message with function call"), 1591new TextContent("I'll call a function"),
OpenAIResponseClientIntegrationTests.cs (5)
441Tools = [AIFunctionFactory.Create((int a, int b) => new TextContent($"The sum is {a + b}"), "AddNumbers", "Adds two numbers together")] 463new TextContent($"Weather in {city}: "), 464new TextContent("Sunny, 72°F") 539new TextContent("Analysis result: "), 541new TextContent(" - Image provided above")
OpenAIResponseClientTests.cs (6)
4191new ChatMessage(ChatRole.Tool, [new FunctionResultContent("call_123", new TextContent("Result text"))]) 4250new TextContent("First part. "), 4251new TextContent("Second part.") 4485new TextContent("Text result: "), 4487new TextContent(" - Image uploaded") 4936new TextContent("Check this image: "),
Microsoft.Extensions.AI.Tests (43)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (1)
200new TextContent("I'm going to invoke a function to get the data."),
ChatCompletion\DistributedCachingChatClientTest.cs (5)
369new() { Role = ChatRole.Assistant, Contents = [new TextContent("Hello")] }, 370new() { Role = ChatRole.Assistant, Contents = [new TextContent(" world, ")] }, 376new TextContent("how ") 387new TextContent("are you?") 745new ChatMessage(ChatRole.Assistant, [new TextContent("Hey")])));
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (2)
1048yield return new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Text 1")]) { MessageId = messageId }; 1050yield return new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Text 2")]) { MessageId = messageId };
ChatCompletion\FunctionInvokingChatClientTests.cs (5)
984new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 988new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 1198updates = [new() { Contents = [new TextContent("OK bye")] }]; 1362? [new TextContent($"The search results were '{string.Join(", ", frcs.Select(frc => frc.Result))}'")]
ChatCompletion\OpenTelemetryChatClientTests.cs (11)
358new TextContent("Assistant response text"), 396new TextContent("User request text"), 557new TextContent("Hello!"), 559new TextContent("How are you?"), 612new TextContent("Processing with tools..."), 613new CodeInterpreterToolCallContent { CallId = "ci-call-1", Inputs = [new TextContent("print('hello')")] }, 614new CodeInterpreterToolResultContent { CallId = "ci-call-1", Outputs = [new TextContent("hello")] }, 618new McpServerToolResultContent("mcp-call-1") { Output = [new TextContent("Tool result")] }, 629yield return new() { Contents = [new CodeInterpreterToolCallContent { CallId = "ci-call-1", Inputs = [new TextContent("print('hello')")] }] }; 630yield return new() { Contents = [new CodeInterpreterToolResultContent { CallId = "ci-call-1", Outputs = [new TextContent("hello")] }] }; 634yield return new() { Contents = [new McpServerToolResultContent("mcp-call-1") { Output = [new TextContent("Tool result")] }] };
Functions\AIFunctionFactoryTest.cs (18)
932AIFunctionFactory.Create(() => (AIContent)new TextContent("text")), 933AIFunctionFactory.Create(async () => (AIContent)new TextContent("text")), 934AIFunctionFactory.Create(async ValueTask<AIContent> () => (AIContent)new TextContent("text")), 935AIFunctionFactory.Create(() => new TextContent("text")), 936AIFunctionFactory.Create(async () => new TextContent("text")), 937AIFunctionFactory.Create(async ValueTask<AIContent> () => new TextContent("text")), 949AIFunctionFactory.Create(() => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 950AIFunctionFactory.Create(async () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 951AIFunctionFactory.Create(async ValueTask<IEnumerable<AIContent>> () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 956AIFunctionFactory.Create(() => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 957AIFunctionFactory.Create(async () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 958AIFunctionFactory.Create(async ValueTask<AIContent[]> () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 963AIFunctionFactory.Create(() => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 964AIFunctionFactory.Create(async () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 965AIFunctionFactory.Create(async ValueTask<List<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 970AIFunctionFactory.Create(() => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 971AIFunctionFactory.Create(async () => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 972AIFunctionFactory.Create(async ValueTask<IList<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
SpeechToText\OpenTelemetrySpeechToTextClientTests.cs (1)
73new TextContent(" text."),
Microsoft.Extensions.DataIngestion (1)
Utils\Batching.cs (1)
33contents.Add(new TextContent(chunk.Content));
172 references to TextContent
Aspire.Dashboard (3)
Model\Assistant\AIHelpers.cs (3)
328var newMessages = GetMessages(update, filter: c => c is not TextContent); 334foreach (var item in update.Contents.OfType<TextContent>())
Microsoft.Extensions.AI (3)
ChatCompletion\OpenTelemetryChatClient.cs (2)
253case TextContent tc when !string.IsNullOrWhiteSpace(tc.Text): 480if (input is TextContent tc && !string.IsNullOrEmpty(tc.Text))
ToolReduction\EmbeddingToolReductionStrategy.cs (1)
61case TextContent content:
Microsoft.Extensions.AI.Abstractions (24)
ChatCompletion\ChatMessage.cs (1)
77/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
ChatCompletion\ChatResponseExtensions.cs (9)
57/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 111/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 134/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 162/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 231Coalesce<TextContent>(
ChatCompletion\ChatResponseUpdate.cs (1)
97/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
Contents\AIAnnotation.cs (1)
26/// for <see cref="TextContent"/>.
Contents\AIContent.cs (1)
17[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\CodeInterpreterToolResultContent.cs (1)
33/// <see cref="DataContent"/> for binary data, <see cref="TextContent"/> for standard output text,
Contents\TextContent.cs (1)
16/// 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.
Contents\TextSpanAnnotatedRegion.cs (1)
10/// <remarks>This <see cref="AnnotatedRegion"/> typically applies to <see cref="TextContent"/>.</remarks>
SpeechToText\SpeechToTextResponse.cs (1)
66/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
SpeechToText\SpeechToTextResponseUpdate.cs (1)
86/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
Microsoft.Extensions.AI.Abstractions.Tests (63)
ChatCompletion\ChatMessageTests.cs (11)
48TextContent tc = Assert.IsType<TextContent>(message.Contents[0]); 108TextContent tc = Assert.IsType<TextContent>(message.Contents[i]); 154TextContent textContent = Assert.IsType<TextContent>(message.Contents[3]); 159((TextContent)message.Contents[3]).Text = "text-3"; 281((TextContent)chatMessage.Contents[0]).Text = "content-1-override"; // Override the content of the first text content item that has the "content-1" content 296var textContent = deserializedMessage.Contents[0] as TextContent; 319textContent = deserializedMessage.Contents[3] as TextContent;
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (20)
674TextContent[] contents = message.Contents.OfType<TextContent>().ToArray(); 710Assert.Equal("ABC", Assert.IsType<TextContent>(message.Contents[0]).Text); 712Assert.Equal("GH", Assert.IsType<TextContent>(message.Contents[2]).Text); 714Assert.Equal("K", Assert.IsType<TextContent>(message.Contents[4]).Text); 716Assert.Equal("MN", Assert.IsType<TextContent>(message.Contents[6]).Text); 785Assert.Equal("ABC", Assert.IsType<TextContent>(message.Contents[0]).Text); 786Assert.Equal("D", Assert.IsType<TextContent>(message.Contents[1]).Text); 787Assert.Equal("E", Assert.IsType<TextContent>(message.Contents[2]).Text); 788Assert.Equal("F", Assert.IsType<TextContent>(message.Contents[3]).Text); 789Assert.Equal("GH", Assert.IsType<TextContent>(message.Contents[4]).Text); 790Assert.Equal("I", Assert.IsType<TextContent>(message.Contents[5]).Text); 791Assert.Equal("J", Assert.IsType<TextContent>(message.Contents[6]).Text); 792Assert.Equal("K", Assert.IsType<TextContent>(message.Contents[7]).Text); 793Assert.Equal("L", Assert.IsType<TextContent>(message.Contents[8]).Text); 794Assert.Equal("MN", Assert.IsType<TextContent>(message.Contents[9]).Text); 795Assert.Equal("O", Assert.IsType<TextContent>(message.Contents[10]).Text); 796Assert.Equal("P", Assert.IsType<TextContent>(message.Contents[11]).Text); 816Assert.Equal("Hello, world!", Assert.IsType<TextContent>(Assert.Single(Assert.Single(response.Messages).Contents)).Text); 957Assert.IsType<TextContent>(message.Contents[0]).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\CodeInterpreterToolCallContentTests.cs (3)
63Assert.IsType<TextContent>(c.Inputs[0]); 88Assert.IsType<TextContent>(deserializedSut.Inputs[0]); 89Assert.Equal("print('hello')", ((TextContent)deserializedSut.Inputs[0]).Text);
Contents\CodeInterpreterToolResultContentTests.cs (3)
64Assert.IsType<TextContent>(c.Outputs[0]); 90Assert.IsType<TextContent>(deserializedSut.Outputs[0]); 91Assert.Equal("Hello, World!", ((TextContent)deserializedSut.Outputs[0]).Text);
Contents\TextContentTests.cs (5)
17TextContent c = new(text); 26TextContent c = new(null); 55var content = new TextContent("Hello, world!"); 58var deserializedContent = JsonSerializer.Deserialize<TextContent>(json, AIJsonUtilities.DefaultOptions);
Image\ImageGenerationResponseTests.cs (1)
152Assert.IsType<TextContent>(deserialized.Contents[2]);
SpeechToText\SpeechToTextResponseTests.cs (7)
52TextContent tc = Assert.IsType<TextContent>(response.Contents[0]); 92TextContent tc = Assert.IsType<TextContent>(response.Contents[i]); 173Assert.Equal($"Text{i + 1}", ((TextContent)result.Contents[i]).Text); 236Assert.Equal("Hello, ", Assert.IsType<TextContent>(update.Contents[0]).Text); 238Assert.Equal("world!", Assert.IsType<TextContent>(update.Contents[2]).Text);
SpeechToText\SpeechToTextResponseUpdateExtensionsTests.cs (3)
126TextContent[] contents = response.Contents.OfType<TextContent>().ToArray(); 153Assert.Equal("Hello, world!", Assert.IsType<TextContent>(Assert.Single(response.Contents)).Text);
SpeechToText\SpeechToTextResponseUpdateTests.cs (2)
71TextContent textContent = Assert.IsType<TextContent>(update.Contents[3]);
Utilities\AIJsonUtilitiesTests.cs (1)
1198Assert.Throws<ArgumentException>("contentType", () => options.AddAIContentType<TextContent>("discriminator"));
Microsoft.Extensions.AI.Evaluation (11)
ChatMessageExtensions.cs (6)
101/// <see cref="TextContent"/>s. If the <paramref name="message"/> does not contain any <see cref="TextContent"/>s 116if (!message.Contents.OfType<TextContent>().Any()) 140/// <see cref="TextContent"/>s. Any <paramref name="messages"/> that contain no <see cref="TextContent"/>s will be 142/// <see cref="TextContent"/>s then this function will return an empty string.
ChatResponseExtensions.cs (3)
22/// <see cref="TextContent"/>s. Any <see cref="ChatResponse.Messages"/> that contain no <see cref="TextContent"/>s 24/// <see cref="TextContent"/>s then this function will return an empty string.
EvaluationContext.cs (2)
59/// <see cref="TextContent"/> objects for text, <see cref="DataContent"/> or <see cref="UriContent"/> objects for 65/// <see cref="TextContent"/> object that includes the contained text.
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (8)
ScenarioRunResultTests.cs (8)
23var content1 = new TextContent("content1"); 24var content2 = new TextContent("content2"); 25var content3 = new TextContent("content3"); 115var content1 = new TextContent("content1"); 116var content2 = new TextContent("content2"); 117var content3 = new TextContent("content3"); 367if (x is TextContent xText && y is TextContent yText)
Microsoft.Extensions.AI.Evaluation.Safety (6)
AIContentExtensions.cs (1)
11=> content is TextContent || content is UsageContent;
ContentSafetyEvaluator.cs (2)
113contents.OfType<TextContent>() is IEnumerable<TextContent> textContents && textContents.Any() &&
ContentSafetyServicePayloadUtilities.cs (3)
320if (content is TextContent textContent) 515$"The current evaluation being performed by {evaluatorName} only supports content of type '{nameof(TextContent)}', '{nameof(UriContent)}' and '{nameof(DataContent)}'. " + 524$"The current evaluation being performed by {evaluatorName} only supports content of type '{nameof(TextContent)}'. " +
Microsoft.Extensions.AI.Integration.Tests (8)
ChatClientIntegrationTests.cs (4)
179var singleTextContent = (TextContent)history[1].Contents.Single(); 676((TextContent)message.Contents[0]).Text += "!"; 710((TextContent)message.Contents[0]).Text += "!";
ImageGeneratingChatClientIntegrationTests.cs (3)
100foreach (var textContent in contents.OfType<TextContent>()) 395var textContents = userMessage.Contents.OfType<TextContent>().ToList();
ReducingChatClientTests.cs (1)
100if (content is TextContent text)
Microsoft.Extensions.AI.OpenAI (12)
OpenAIAssistantsChatClient.cs (4)
290(((TextContent)textUpdate.Contents[0]).Annotations ??= []).Add(new CitationAnnotation 524foreach (var textContent in chatMessage.Contents.OfType<TextContent>()) 540case TextContent text:
OpenAIChatClient.cs (3)
286case TextContent textContent: 542TextContent? annotationContent = returnMessage.Contents.OfType<TextContent>().FirstOrDefault();
OpenAIResponsesChatClient.cs (5)
949case TextContent textContent: 1013case TextContent tc: 1138case TextContent textContent: 1185mtci.ToolOutput = string.Concat(mstrc.Output?.OfType<TextContent>() ?? []); 1262TextContent text = new(part.Text);
Microsoft.Extensions.AI.OpenAI.Tests (23)
OpenAIAssistantChatClientIntegrationTests.cs (1)
96if (toolResultContent.Outputs.OfType<TextContent>().FirstOrDefault() is { } resultOutput)
OpenAIChatClientTests.cs (4)
1251TextContent fcc = Assert.IsType<TextContent>(response.Messages.Single().Contents[0]); 1957var text = message.Contents.OfType<TextContent>().Single();
OpenAIConversionTests.cs (4)
823Assert.Equal("Hello, world!", Assert.IsType<TextContent>(message.Contents[0], exactMatch: false).Text); 854Assert.Equal("Hello, world!", Assert.IsType<TextContent>(message.Contents[0], exactMatch: false).Text); 967var textContent = message.Contents.OfType<TextContent>().FirstOrDefault();
OpenAIResponseClientIntegrationTests.cs (5)
67if (toolResultContent.Outputs.OfType<TextContent>().FirstOrDefault() is { } resultOutput) 84TextContent tc = m.Contents.OfType<TextContent>().First(); 429var content = Assert.IsType<TextContent>(Assert.Single(toolResult.Output!));
OpenAIResponseClientTests.cs (9)
1555Assert.StartsWith("The `README.md` file for `Microsoft.Extensions.AI.Abstractions` is located at", Assert.IsType<TextContent>(Assert.Single(result.Output)).Text); 1809Assert.StartsWith("Available pages for dotnet/extensions", Assert.IsType<TextContent>(Assert.Single(firstResult.Output)).Text); 1822Assert.StartsWith("The `README.md` file for `Microsoft.Extensions.AI.Abstractions` is located at", Assert.IsType<TextContent>(Assert.Single(secondResult.Output)).Text); 2222Assert.StartsWith("Available pages for dotnet/extensions", Assert.IsType<TextContent>(Assert.Single(firstResult.Output)).Text); 2235Assert.StartsWith("The path to the `README.md` file", Assert.IsType<TextContent>(Assert.Single(secondResult.Output)).Text); 2910var textContent = Assert.IsType<TextContent>(message.Contents[2]); 3130var textContent = Assert.IsType<TextContent>(message.Contents[2]);
Microsoft.Extensions.AI.Tests (11)
ChatCompletion\DistributedCachingChatClientTest.cs (4)
347c => Assert.Equal("This becomes one chunk", Assert.IsType<TextContent>(c).Text), 349c => Assert.Equal("... and this becomes another one.", Assert.IsType<TextContent>(c).Text)); 425var content = Assert.IsType<TextContent>(Assert.Single(item.Contents));
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (2)
1075Assert.Equal("Text 1", update.Contents.OfType<TextContent>().First().Text); 1081Assert.Equal("Text 2", update.Contents.OfType<TextContent>().First().Text);
ChatCompletion\FunctionInvokingChatClientTests.cs (2)
1222m => Assert.Equal("OK bye", Assert.IsType<TextContent>(Assert.Single(m.Contents)).Text)); 1262Assert.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)";
Functions\AIFunctionFactoryTest.cs (1)
930await ValidateAsync<TextContent>(