216 references to TextContent
Microsoft.Extensions.AI (2)
ChatCompletion\ImageGeneratingChatClient.cs (1)
179newContents.Add(new TextContent($"[{ImageKey}:{imageId}] available for edit.")
ChatCompletion\OpenTelemetryImageGenerator.cs (1)
180content.Add(new TextContent(request.Prompt));
Microsoft.Extensions.AI.Abstractions (8)
ChatCompletion\ChatMessage.cs (2)
31: this(role, content is null ? [] : [new TextContent(content)]) 116!string.IsNullOrWhiteSpace(text) ? new TextContent(text) :
ChatCompletion\ChatResponseExtensions.cs (1)
288static (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)]) 183!string.IsNullOrWhiteSpace(text) ? new TextContent(text) :
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.TextContent.g.cs (1)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.TextContent((string)args[0]),
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 (70)
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 (12)
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"), 184new TextContent("text-1"), 188new TextContent("text-2"), 246var originalContents = new List<AIContent> { new TextContent("text1"), new TextContent("text2") }; 376var sharedContents = new List<AIContent> { new TextContent("initial") }; 389sharedContents.Add(new TextContent("added"));
Contents\AIContentTests.cs (1)
67new TextContent("a"),
Contents\CodeInterpreterToolCallContentTests.cs (3)
30IList<AIContent> inputs = [new TextContent("print('hello')")]; 52new TextContent("import numpy as np"), 72new TextContent("print('hello')"),
Contents\CodeInterpreterToolResultContentTests.cs (3)
30IList<AIContent> output = [new TextContent("Hello, World!")]; 52new TextContent("Execution completed"), 74new TextContent("Hello, World!"),
Contents\McpServerToolResultContentTests.cs (2)
41IList<AIContent> outputs = [new TextContent("test result")]; 58Outputs = [new TextContent("result")]
Contents\TextContentTests.cs (3)
17TextContent c = new(text); 26TextContent c = new(null); 55var content = new TextContent("Hello, world!");
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestJsonSerializerContext.TextContent.g.cs (1)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.TextContent((string)args[0]),
Image\ImageGenerationResponseTests.cs (1)
139new TextContent("Generated image description") // Edge case: text content in image response
Realtime\RealtimeClientMessageTests.cs (5)
40var contents = new List<AIContent> { new TextContent("Hello") }; 51var item = new RealtimeConversationItem([new TextContent("Hello")]); 54var newItem = new RealtimeConversationItem([new TextContent("World")]); 63var item = new RealtimeConversationItem([new TextContent("Hello")]); 140new RealtimeConversationItem([new TextContent("Hello")], "item_1", ChatRole.User),
Realtime\RealtimeConversationItemTests.cs (5)
16IList<AIContent> contents = [new TextContent("Hello")]; 28IList<AIContent> contents = [new TextContent("Hello"), new TextContent("World")]; 39IList<AIContent> contents = [new TextContent("Initial")]; 42IList<AIContent> newContents = [new TextContent("Updated")];
Realtime\RealtimeServerMessageTests.cs (2)
194new RealtimeConversationItem([new TextContent("response")], "item_1"), 248var item = new RealtimeConversationItem([new TextContent("output")], "item_out_1", ChatRole.Assistant);
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)
339new TextContent("What does this image depict?"), 377new TextContent("Here's an image pertaining to DotNet:"), 411new TextContent("What does this image depict?"), 424new TextContent("Here's an image pertaining to Microsoft Copilot:"), 460new TextContent("What does this image depict?"), 473new 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 (1)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.TextContent.g.cs (1)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.TextContent((string)args[0]),
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (1)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.TextContent.g.cs (1)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.TextContent((string)args[0]),
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (7)
ScenarioRunResultTests.cs (6)
24var content1 = new TextContent("content1"); 25var content2 = new TextContent("content2"); 26var content3 = new TextContent("content3"); 116var content1 = new TextContent("content1"); 117var content2 = new TextContent("content2"); 118var content3 = new TextContent("content3");
SerializationChainingTests.cs (1)
31Contents = [new TextContent("A user message")]
Microsoft.Extensions.AI.Integration.Tests (4)
ChatClientIntegrationTests.cs (2)
185new TextContent("What does this logo say?"), 203new TextContent("What text does this document contain?"),
ImageGeneratingChatClientIntegrationTests.cs (2)
166[new ChatMessage(ChatRole.User, [new TextContent("Please edit this image to add a red border"), originalImageData])], 381new TextContent("Here's an image to process"),
Microsoft.Extensions.AI.OpenAI (15)
OpenAIAssistantsChatClient.cs (2)
237(hcitrc.Outputs ??= []).Add(new TextContent(logs)); 285textUpdate.Contents.Add(new TextContent(string.Empty));
OpenAIChatClient.cs (2)
561annotationContent = new(null); 789aiContent = new TextContent(contentPart.Text);
OpenAIRealtimeClientSession.cs (4)
1130contents.Add(new TextContent(textPart.Text)); 1134contents.Add(new TextContent(outputTextPart.Text)); 1147contents.Add(new TextContent(outputAudioPart.Transcript)); 1197: new TextContent(mcpItem.ToolOutput);
OpenAIResponsesChatClient.cs (4)
476yield return CreateUpdate(new TextContent(outputTextDeltaUpdate.Delta)); 1690TextContent text = new(part.Text); 1856new TextContent(mtci.ToolOutput)], 1886outputContents.Add(new TextContent(ciclo.Logs) { RawRepresentation = ciclo });
OpenAISpeechToTextClient.cs (3)
69response.Contents = [new TextContent(translation.Text)]; 83response.Contents = [new TextContent(transcription.Text)]; 144result.Contents = [new TextContent(deltaUpdate.Delta)];
Microsoft.Extensions.AI.OpenAI.Tests (30)
OpenAIChatClientTests.cs (5)
928new(ChatRole.System, [new TextContent("You are a really nice friend."), new TextContent("Really nice.")]), 1471new TextContent("hi, how are you?"), 1477new FunctionResultContent("12345", new TextContent("Said hello")), 1589new TextContent("What does this logo say?"),
OpenAIConversionTests.cs (13)
730new TextContent("Hi there!"), 799new TextContent("Hi there!"), 850new TextContent("Hello, "), 853new TextContent("World"), 854new TextContent("!"), 858new TextContent("Hi!"), 1219new TextContent("I'll call a function."), 1490var mcpToolResult = new McpServerToolResultContent("call_123") { Outputs = isError ? [new ErrorContent("error")] : [new TextContent("sunny")] }; 1521new TextContent("Here's an image and some text."), 1590new TextContent("I'll process this complex data."), 1845new TextContent("Processing your request..."), 2086new TextContent("Third message with function call"), 2121new TextContent("I'll call a function"),
OpenAIResponseClientIntegrationTests.cs (5)
567Tools = [AIFunctionFactory.Create((int a, int b) => new TextContent($"The sum is {a + b}"), "AddNumbers", "Adds two numbers together")] 589new TextContent($"Weather in {city}: "), 590new TextContent("Sunny, 72°F") 665new TextContent("Analysis result: "), 667new TextContent(" - Image provided above")
OpenAIResponseClientTests.cs (7)
1760? new TextContent("hello") 4823new ChatMessage(ChatRole.Tool, [new FunctionResultContent("call_123", new TextContent("Result text"))]) 4882new TextContent("First part. "), 4883new TextContent("Second part.") 5117new TextContent("Text result: "), 5119new TextContent(" - Image uploaded") 5570new TextContent("Check this image: "),
Microsoft.Extensions.AI.Stabilization.Tests (8)
AIContentSerializationRegressionTests.cs (1)
23new TextContent("hello"),
Generated\361d1da7f942c932\AIContentSerializationRegressionContext.TextContent.g.cs (1)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.TextContent((string)args[0]),
parent\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolCallContentTests.cs (3)
30IList<AIContent> inputs = [new TextContent("print('hello')")]; 52new TextContent("import numpy as np"), 72new TextContent("print('hello')"),
parent\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolResultContentTests.cs (3)
30IList<AIContent> output = [new TextContent("Hello, World!")]; 52new TextContent("Execution completed"), 74new TextContent("Hello, World!"),
Microsoft.Extensions.AI.Tests (56)
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 (12)
1257new TextContent("please proceed"), 1362new TextContent("please proceed"), 1558yield return new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Text 1")]) { MessageId = messageId }; 1560yield return new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Text 2")]) { MessageId = messageId }; 1816new McpServerToolResultContent("callId2") { Outputs = [new TextContent("Result 2")] }, 1817new TextContent("world") 1832new McpServerToolResultContent("callId2") { Outputs = [new TextContent("Result 2")] }, 1833new TextContent("world") 1901new TextContent("world"), 1903[new McpServerToolResultContent("callId2") { Outputs = [new TextContent("Result 2")] }] : 1920new TextContent("world"), 1922[new McpServerToolResultContent("callId2") { Outputs = [new TextContent("Result 2")] }] :
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)
406new TextContent("Assistant response text"), 444new TextContent("User request text"), 605new TextContent("Hello!"), 607new TextContent("How are you?"), 660new TextContent("Processing with tools..."), 661new CodeInterpreterToolCallContent("ci-call-1") { Inputs = [new TextContent("print('hello')")] }, 662new CodeInterpreterToolResultContent("ci-call-1") { Outputs = [new TextContent("hello")] }, 666new McpServerToolResultContent("mcp-call-1") { Outputs = [new TextContent("Tool result")] }, 677yield return new() { Contents = [new CodeInterpreterToolCallContent("ci-call-1") { Inputs = [new TextContent("print('hello')")] }] }; 678yield return new() { Contents = [new CodeInterpreterToolResultContent("ci-call-1") { Outputs = [new TextContent("hello")] }] }; 691yield return new() { Contents = [new McpServerToolResultContent("mcp-call-1") { Outputs = [new TextContent("Tool result")] }] };
Functions\AIFunctionFactoryTest.cs (18)
1162AIFunctionFactory.Create(() => (AIContent)new TextContent("text")), 1163AIFunctionFactory.Create(async () => (AIContent)new TextContent("text")), 1164AIFunctionFactory.Create(async ValueTask<AIContent> () => (AIContent)new TextContent("text")), 1165AIFunctionFactory.Create(() => new TextContent("text")), 1166AIFunctionFactory.Create(async () => new TextContent("text")), 1167AIFunctionFactory.Create(async ValueTask<AIContent> () => new TextContent("text")), 1179AIFunctionFactory.Create(() => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1180AIFunctionFactory.Create(async () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1181AIFunctionFactory.Create(async ValueTask<IEnumerable<AIContent>> () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1186AIFunctionFactory.Create(() => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1187AIFunctionFactory.Create(async () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1188AIFunctionFactory.Create(async ValueTask<AIContent[]> () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1193AIFunctionFactory.Create(() => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1194AIFunctionFactory.Create(async () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1195AIFunctionFactory.Create(async ValueTask<List<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1200AIFunctionFactory.Create(() => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1201AIFunctionFactory.Create(async () => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1202AIFunctionFactory.Create(async ValueTask<IList<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestJsonSerializerContext.TextContent.g.cs (1)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.TextContent((string)args[0]),
Realtime\OpenTelemetryRealtimeClientTests.cs (2)
1001var item = new RealtimeConversationItem([new TextContent("Hello from client")], role: ChatRole.User); 1010var item = new RealtimeConversationItem([new TextContent("User text message")], role: ChatRole.User);
SpeechToText\OpenTelemetrySpeechToTextClientTests.cs (1)
75new TextContent(" text."),
Microsoft.Extensions.DataIngestion (1)
Utils\Batching.cs (1)
33contents.Add(new TextContent(chunk.Content));