28 instantiations of TextContent
Microsoft.Extensions.AI (1)
ChatCompletion\CachingChatClient.cs (1)
130TextContent coalescedContent = new(null) // will patch the text after examining all items in the run
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatMessage.cs (1)
72Contents.Add(new TextContent(value));
ChatCompletion\StreamingChatCompletionUpdate.cs (1)
57Contents.Add(new TextContent(value));
Microsoft.Extensions.AI.Abstractions.Tests (13)
ChatCompletion\ChatMessageTests.cs (5)
71content.Add(new TextContent($"text-{i}")); 129new TextContent("text-1"), 130new TextContent("text-2"), 263new TextContent("content-1") 288new 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); 26TextContent c = new(null);
Microsoft.Extensions.AI.AzureAIInference (2)
AzureAIInferenceChatClient.cs (2)
110returnMessage.Contents.Add(new TextContent(choice.Message.Content) 183completionUpdate.Contents.Add(new TextContent(update)
Microsoft.Extensions.AI.Integration.Tests (2)
PromptBasedFunctionCallingChatClient.cs (2)
67message.Contents[itemIndex] = new TextContent( 74message.Contents[itemIndex] = new TextContent(
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
140update.Contents.Add(new TextContent(message.Content) { ModelId = modelId }); 223contents.Insert(0, new TextContent(message.Content));
Microsoft.Extensions.AI.OpenAI (1)
OpenAIChatClient.cs (1)
544aiContent = new TextContent(contentPart.Text);
Microsoft.Extensions.AI.Tests (5)
ChatCompletion\FunctionInvokingChatClientTests.cs (5)
216new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 220new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 228new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new TextContent("stuff")]),
44 references to TextContent
Microsoft.Extensions.AI (7)
ChatCompletion\CachingChatClient.cs (5)
98update.Contents[0] is not TextContent textContent) 110next.Contents[0] is not TextContent || 130TextContent coalescedContent = new(null) // will patch the text after examining all items in the run 163TextContent nextContent = (TextContent)next.Contents[0];
ChatCompletion\ChatCompletion{T}.cs (1)
110return (content as TextContent)?.Text;
ChatCompletion\OpenTelemetryChatClient.cs (1)
543string content = string.Concat(message.Contents.OfType<TextContent>().Select(c => c.Text));
Microsoft.Extensions.AI.Abstractions (12)
ChatCompletion\ChatMessage.cs (5)
54/// Gets or sets the text of the first <see cref="TextContent"/> instance in <see cref="Contents" />. 57/// If there is no <see cref="TextContent"/> instance in <see cref="Contents" />, then the getter returns <see langword="null" />, 58/// and the setter will add a new <see cref="TextContent"/> instance with the provided value. 63get => Contents.OfType<TextContent>().FirstOrDefault()?.Text; 66if (Contents.OfType<TextContent>().FirstOrDefault() is { } textContent)
ChatCompletion\StreamingChatCompletionUpdate.cs (5)
39/// Gets or sets the text of the first <see cref="TextContent"/> instance in <see cref="Contents" />. 42/// If there is no <see cref="TextContent"/> instance in <see cref="Contents" />, then the getter returns <see langword="null" />, 43/// and the setter will add new <see cref="TextContent"/> instance with the provided value. 48get => Contents.OfType<TextContent>().FirstOrDefault()?.Text; 51if (Contents.OfType<TextContent>().FirstOrDefault() is { } textContent)
Contents\AIContent.cs (1)
15[JsonDerivedType(typeof(TextContent), typeDiscriminator: "text")]
Contents\TextContent.cs (1)
12/// Initializes a new instance of the <see cref="TextContent"/> class.
Microsoft.Extensions.AI.Abstractions.Tests (21)
ChatCompletion\ChatMessageTests.cs (11)
46TextContent tc = Assert.IsType<TextContent>(message.Contents[0]); 89TextContent tc = Assert.IsType<TextContent>(message.Contents[i]); 134TextContent textContent = Assert.IsType<TextContent>(message.Contents[3]); 156TextContent textContent = Assert.IsType<TextContent>(message.Contents[0]); 317var textContent = deserializedMessage.Contents[0] as TextContent; 361textContent = deserializedMessage.Contents[5] as TextContent;
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); 26TextContent c = new(null);
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
455TextContent textContent => new ChatMessageTextContentItem(textContent.Text),
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
332case TextContent textContent:
Microsoft.Extensions.AI.Ollama.Tests (1)
OllamaChatClientTests.cs (1)
182Assert.IsType<TextContent>(updates[updates.Count - 1].Contents[0]);
Microsoft.Extensions.AI.OpenAI (1)
OpenAIChatClient.cs (1)
615TextContent textContent => ChatMessageContentPart.CreateTextPart(textContent.Text),