39 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)
233contents[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)
185completionUpdate.Contents.Add(new TextContent(update));
Microsoft.Extensions.AI.AzureAIInference.Tests (3)
AzureAIInferenceChatClientTests.cs (3)
150[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] : 217[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] : 588new TextContent("Describe this picture."),
Microsoft.Extensions.AI.Integration.Tests (3)
ChatClientIntegrationTests.cs (1)
148new 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)
250contents.Insert(0, new TextContent(message.Content));
Microsoft.Extensions.AI.OpenAI (2)
OpenAIModelMapper.ChatCompletion.cs (1)
528aiContent = new TextContent(contentPart.Text);
OpenAIModelMapper.ChatMessage.cs (1)
194contents.Add(new TextContent(openAiContentPart.Text));
Microsoft.Extensions.AI.OpenAI.Tests (5)
OpenAIChatClientTests.cs (3)
530new(ChatRole.System, [new TextContent("You are a really nice friend."), new TextContent("Really nice.")]), 991new TextContent("hi, how are you?"),
OpenAISerializationTests.cs (2)
440new TextContent("Hello! How can I assist you today?"), 559List<AIContent> contents = [new TextContent($"Streaming update {i}")];
Microsoft.Extensions.AI.Tests (6)
ChatCompletion\FunctionInvokingChatClientTests.cs (6)
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")]), 528new StreamingChatCompletionUpdate { Contents = [new TextContent("OK bye")] });
74 references to TextContent
Microsoft.Extensions.AI (2)
ChatCompletion\ChatCompletion{T}.cs (1)
121return (content as TextContent)?.Text;
ChatCompletion\OpenTelemetryChatClient.cs (1)
535string 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)
198/// <summary>Coalesces sequential <see cref="TextContent"/> content elements.</summary> 208if (contents[start] is not TextContent firstText) 214if (contents[start + 1] is not TextContent secondText) 226for (; 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 (3)
AzureAIInferenceChatClient.cs (3)
446yield return input.Contents.All(c => c is TextContent) ? 454ChatRequestAssistantMessage message = new(string.Concat(input.Contents.Where(c => c is TextContent))); 483case TextContent textContent:
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
385case 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)
OpenAIModelMapper.ChatMessage.cs (1)
219case TextContent textContent:
Microsoft.Extensions.AI.OpenAI.Tests (18)
OpenAISerializationTests.cs (18)
49TextContent textContent = Assert.IsType<TextContent>(content); 82TextContent textContent = Assert.IsType<TextContent>(content); 157TextContent text = Assert.IsType<TextContent>(Assert.Single(msg.Contents)); 169TextContent text = Assert.IsType<TextContent>(Assert.Single(msg.Contents)); 181TextContent text = Assert.IsType<TextContent>(Assert.Single(msg.Contents)); 193TextContent text = Assert.IsType<TextContent>(Assert.Single(msg.Contents)); 254TextContent text = Assert.IsType<TextContent>(content); 262TextContent text = Assert.IsType<TextContent>(content); 275TextContent text = Assert.IsType<TextContent>(Assert.Single(msg.Contents));
Microsoft.Extensions.AI.Tests (3)
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
542m => Assert.Equal("Hello", Assert.IsType<TextContent>(Assert.Single(m.Contents)).Text), 552var singleUpdateContent = Assert.IsType<TextContent>(Assert.Single(allUpdateContents));