32 instantiations of TextContent
Microsoft.Extensions.AI.Abstractions (3)
ChatCompletion\ChatMessage.cs (1)
71Contents.Add(new TextContent(value));
ChatCompletion\StreamingChatCompletionUpdate.cs (1)
77Contents.Add(new TextContent(value));
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (1)
217contents[start] = new TextContent(coalescedText.ToString())
Microsoft.Extensions.AI.Abstractions.Tests (15)
ChatCompletion\ChatCompletionTests.cs (2)
241new TextContent("Hello, "), 243new TextContent("world!"),
ChatCompletion\ChatMessageTests.cs (5)
72content.Add(new TextContent($"text-{i}")); 130new TextContent("text-1"), 131new TextContent("text-2"), 264new TextContent("content-1") 284new TextContent("content-6")
ChatCompletion\StreamingChatCompletionUpdateTests.cs (6)
44update.Contents.Add(new TextContent("text")); 48IList<AIContent> newList = [new TextContent("text")]; 97new TextContent("text-1"), 98new TextContent("text-2"), 171new TextContent("text-1"), 175new TextContent("text-2"),
Contents\TextContentTests.cs (2)
16TextContent c = new(text); 25TextContent c = new(null);
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
183completionUpdate.Contents.Add(new TextContent(update));
Microsoft.Extensions.AI.Integration.Tests (3)
ChatClientIntegrationTests.cs (1)
149new TextContent("What does this logo say?"),
PromptBasedFunctionCallingChatClient.cs (2)
67message.Contents[itemIndex] = new TextContent( 74message.Contents[itemIndex] = new TextContent(
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
251contents.Insert(0, new TextContent(message.Content));
Microsoft.Extensions.AI.OpenAI (1)
OpenAIChatClient.cs (1)
547aiContent = new TextContent(contentPart.Text);
Microsoft.Extensions.AI.OpenAI.Tests (3)
OpenAIChatClientTests.cs (3)
456new(ChatRole.System, [new TextContent("You are a really nice friend."), new TextContent("Really nice.")]), 891new TextContent("hi, how are you?"),
Microsoft.Extensions.AI.Tests (5)
ChatCompletion\FunctionInvokingChatClientTests.cs (5)
272new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 276new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 287new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new TextContent("stuff")]),
51 references to TextContent
Microsoft.Extensions.AI (2)
ChatCompletion\ChatCompletion{T}.cs (1)
121return (content as TextContent)?.Text;
ChatCompletion\OpenTelemetryChatClient.cs (1)
505string content = string.Concat(message.Contents.OfType<TextContent>());
Microsoft.Extensions.AI.Abstractions (19)
ChatCompletion\ChatMessage.cs (5)
53/// Gets or sets the text of the first <see cref="TextContent"/> instance in <see cref="Contents" />. 56/// If there is no <see cref="TextContent"/> instance in <see cref="Contents" />, then the getter returns <see langword="null" />, 57/// and the setter adds a new <see cref="TextContent"/> instance with the provided value. 62get => Contents.FindFirst<TextContent>()?.Text; 65if (Contents.FindFirst<TextContent>() is { } textContent)
ChatCompletion\StreamingChatCompletionUpdate.cs (5)
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" />, 63/// and the setter will add new <see cref="TextContent"/> instance with the provided value. 68get => Contents.FindFirst<TextContent>()?.Text; 71if (Contents.FindFirst<TextContent>() is { } textContent)
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (4)
182/// <summary>Coalesces sequential <see cref="TextContent"/> content elements.</summary> 192if (contents[start] is not TextContent firstText) 198if (contents[start + 1] is not TextContent secondText) 210for (; i < contents.Count && contents[i] is TextContent next; i++)
Contents\AIContent.cs (1)
15[JsonDerivedType(typeof(TextContent), typeDiscriminator: "text")]
Contents\AIContentExtensions.cs (3)
33/// <summary>Concatenates the text of all <see cref="TextContent"/> instances in the list.</summary> 43return contents[0] is TextContent tc ? tc.Text : string.Empty; 50if (contents[i] is TextContent text)
Contents\TextContent.cs (1)
16/// Initializes a new instance of the <see cref="TextContent"/> class.
Microsoft.Extensions.AI.Abstractions.Tests (26)
ChatCompletion\ChatCompletionTests.cs (2)
277Assert.Equal("Hello, ", Assert.IsType<TextContent>(update0.Contents[0]).Text); 279Assert.Equal("world!", Assert.IsType<TextContent>(update0.Contents[2]).Text);
ChatCompletion\ChatMessageTests.cs (11)
47TextContent tc = Assert.IsType<TextContent>(message.Contents[0]); 90TextContent tc = Assert.IsType<TextContent>(message.Contents[i]); 135TextContent textContent = Assert.IsType<TextContent>(message.Contents[3]); 157TextContent textContent = Assert.IsType<TextContent>(message.Contents[0]); 312var textContent = deserializedMessage.Contents[0] as TextContent; 351textContent = deserializedMessage.Contents[5] as TextContent;
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (3)
184TextContent[] contents = message.Contents.OfType<TextContent>().ToArray(); 209Assert.Equal("Hello, world!", Assert.IsType<TextContent>(Assert.Single(completion.Message.Contents)).Text);
ChatCompletion\StreamingChatCompletionUpdateTests.cs (8)
103TextContent textContent = Assert.IsType<TextContent>(update.Contents[3]); 128TextContent textContent = Assert.IsType<TextContent>(update.Contents[0]); 192Assert.IsType<TextContent>(result.Contents[0]); 193Assert.Equal("text-1", ((TextContent)result.Contents[0]).Text); 204Assert.IsType<TextContent>(result.Contents[4]); 205Assert.Equal("text-2", ((TextContent)result.Contents[4]).Text);
Contents\TextContentTests.cs (2)
16TextContent c = new(text); 25TextContent c = new(null);
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
477case TextContent textContent:
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
364case TextContent textContent:
Microsoft.Extensions.AI.Ollama.Tests (1)
OllamaChatClientTests.cs (1)
197Assert.IsType<TextContent>(updates[updates.Count - 1].Contents[0]);
Microsoft.Extensions.AI.OpenAI (1)
OpenAIChatClient.cs (1)
653case TextContent textContent: