138 references to TextContent
Microsoft.Extensions.AI (1)
ChatCompletion\OpenTelemetryImageGenerator.cs (1)
192content.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)
190static (contents, start, end) => new(MergeText(contents, start, end)) { AdditionalProperties = contents[start].AdditionalProperties?.Clone() });
ChatCompletion\ChatResponseUpdate.cs (2)
48: this(role, content is null ? null : [new TextContent(content)]) 162!string.IsNullOrWhiteSpace(text) ? new TextContent(text) :
SpeechToText\SpeechToTextResponse.cs (1)
35: this(content is null ? [] : [new TextContent(content)])
SpeechToText\SpeechToTextResponseUpdate.cs (1)
52: this(content is null ? [] : [new TextContent(content)])
Microsoft.Extensions.AI.Abstractions.Tests (42)
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)
681new() { Contents = [new TextContent("D") { Annotations = [new()] }] }, 682new() { Contents = [new TextContent("E") { Annotations = [new()] }] }, 683new() { Contents = [new TextContent("F") { Annotations = [new()] }] }, 684new() { Contents = [new TextContent("G") { Annotations = [] }] }, 685new() { Contents = [new TextContent("H") { Annotations = [] }] }, 686new() { Contents = [new TextContent("I") { Annotations = [new()] }] }, 687new() { Contents = [new TextContent("J") { Annotations = [new()] }] }, 689new() { Contents = [new TextContent("L") { Annotations = [new()] }] }, 692new() { Contents = [new TextContent("O") { Annotations = [new()] }] }, 693new() { Contents = [new TextContent("P") { Annotations = [new()] }] },
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\AIContentTests.cs (1)
63new TextContent("a"),
Contents\TextContentTests.cs (2)
16TextContent c = new(text); 25TextContent c = new(null);
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)
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)
179responseUpdate.Contents.Add(new TextContent(update));
Microsoft.Extensions.AI.AzureAIInference.Tests (3)
AzureAIInferenceChatClientTests.cs (3)
145[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] : 218[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] : 1069new TextContent("Describe this picture."),
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)
34new TextContent("A user message"),
Microsoft.Extensions.AI.Integration.Tests (4)
ChatClientIntegrationTests.cs (2)
195new TextContent("What does this logo say?"), 213new TextContent("What text does this document contain?"),
ToolReductionTests.cs (2)
281new TextContent(answerLine) 312new TextContent(textOnly)
Microsoft.Extensions.AI.OpenAI (9)
OpenAIAssistantsChatClient.cs (1)
232textUpdate.Contents.Add(new TextContent(string.Empty));
OpenAIChatClient.cs (2)
518annotationContent = new(null); 706aiContent = new TextContent(contentPart.Text);
OpenAIResponsesChatClient.cs (3)
358yield return CreateUpdate(new TextContent(outputTextDeltaUpdate.Delta)); 909TextContent text = new(part.Text) { RawRepresentation = part }; 1002new TextContent(mtci.ToolOutput)],
OpenAISpeechToTextClient.cs (3)
72response.Contents = [new TextContent(translation.Text)]; 86response.Contents = [new TextContent(transcription.Text)]; 144result.Contents = [new TextContent(deltaUpdate.Delta)];
Microsoft.Extensions.AI.OpenAI.Tests (17)
OpenAIChatClientTests.cs (5)
926new(ChatRole.System, [new TextContent("You are a really nice friend."), new TextContent("Really nice.")]), 1468new TextContent("hi, how are you?"), 1474new FunctionResultContent("12345", new TextContent("Said hello")), 1586new TextContent("What does this logo say?"),
OpenAIConversionTests.cs (12)
165new TextContent("Hi there!"), 234new TextContent("Hi there!"), 285new TextContent("Hello, "), 288new TextContent("World"), 289new TextContent("!"), 293new TextContent("Hi!"), 474new TextContent("I'll call a function."), 510new TextContent("Here's an image and some text."), 579new TextContent("I'll process this complex data."), 834new TextContent("Processing your request..."), 1076new TextContent("Third message with function call"), 1111new TextContent("I'll call a function"),
Microsoft.Extensions.AI.Tests (34)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (1)
200new TextContent("I'm going to invoke a function to get the data."),
ChatCompletion\DistributedCachingChatClientTest.cs (5)
368new() { Role = ChatRole.Assistant, Contents = [new TextContent("Hello")] }, 369new() { Role = ChatRole.Assistant, Contents = [new TextContent(" world, ")] }, 375new TextContent("how ") 386new TextContent("are you?") 744new ChatMessage(ChatRole.Assistant, [new TextContent("Hey")])));
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (2)
779yield return new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Text 1")]) { MessageId = messageId }; 781yield return new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Text 2")]) { MessageId = messageId };
ChatCompletion\FunctionInvokingChatClientTests.cs (5)
552new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 556new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 766updates = [new() { Contents = [new TextContent("OK bye")] }]; 930? [new TextContent($"The search results were '{string.Join(", ", frcs.Select(frc => frc.Result))}'")]
ChatCompletion\OpenTelemetryChatClientTests.cs (2)
366new TextContent("Hello!"), 368new TextContent("How are you?"),
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."),