74 references to new
Microsoft.Extensions.AI.Abstractions.Tests (47)
ChatCompletion\ChatClientExtensionsTests.cs (1)
146return YieldAsync([new ChatResponseUpdate(ChatRole.Assistant, "world")]);
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (44)
30new(ChatRole.Assistant, "Hello") { ResponseId = "someResponse", MessageId = "12345", CreatedAt = new DateTimeOffset(1, 2, 3, 4, 5, 6, TimeSpan.Zero), ModelId = "model123" }, 31new(ChatRole.Assistant, ", ") { AuthorName = "Someone", AdditionalProperties = new() { ["a"] = "b" } }, 32new(null, "world!") { CreatedAt = new DateTimeOffset(2, 2, 3, 4, 5, 6, TimeSpan.Zero), ConversationId = "123", AdditionalProperties = new() { ["c"] = "d" } }, 74new(null, "!") { MessageId = "1" }, 75new(ChatRole.Assistant, "a") { MessageId = "1" }, 76new(ChatRole.Assistant, "b") { MessageId = "2" }, 77new(ChatRole.User, "c") { MessageId = "2" }, 78new(ChatRole.User, "d") { MessageId = "2" }, 79new(ChatRole.Assistant, "e") { MessageId = "3" }, 80new(ChatRole.Tool, "f") { MessageId = "4" }, 81new(ChatRole.Tool, "g") { MessageId = "4" }, 82new(ChatRole.Tool, "h") { MessageId = "5" }, 83new(new("human"), "i") { MessageId = "6" }, 84new(new("human"), "j") { MessageId = "7" }, 85new(new("human"), "k") { MessageId = "7" }, 86new(null, "l") { MessageId = "7" }, 87new(null, "m") { MessageId = "8" }, 132new(null, "Hi! ") { CreatedAt = new DateTimeOffset(2023, 1, 1, 10, 0, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 133new(ChatRole.Assistant, "Hello") { MessageId = "msg1", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 0, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 134new(null, " from") { MessageId = "msg1", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 1, 0, TimeSpan.Zero) }, // Later CreatedAt should win 135new(null, " AI") { MessageId = "msg1", AuthorName = "AI Assistant" }, // Later AuthorName should win 138new(ChatRole.User, "How") { MessageId = "msg2", CreatedAt = new DateTimeOffset(2024, 1, 1, 11, 0, 0, TimeSpan.Zero), AuthorName = "User" }, 139new(null, " are") { MessageId = "msg2", CreatedAt = new DateTimeOffset(2024, 1, 1, 11, 1, 0, TimeSpan.Zero) }, 140new(null, " you?") { MessageId = "msg2", AuthorName = "Human User" }, // Later AuthorName should win 143new(ChatRole.Assistant, "I'm doing well,") { MessageId = "msg3", CreatedAt = new DateTimeOffset(2024, 1, 1, 12, 0, 0, TimeSpan.Zero) }, 144new(null, " thank you!") { MessageId = "msg3", CreatedAt = new DateTimeOffset(2024, 1, 1, 12, 2, 0, TimeSpan.Zero) }, // Later CreatedAt should win 147new(null, " How can I help?"), 221updates.Add(new(null, text)); 269new(null, "A"), 270new(null, "B"), 271new(null, "C"), 275new(null, "G"), 276new(null, "H"), 279new(null, "K"), 281new(null, "M"), 282new(null, "N"), 307new(null, "A"), 308new(null, "B"), 309new(null, "C"), 317new(null, "K"), 319new(null, "M"), 320new(null, "N"), 347new(null, "Hello, "), 348new(null, "world!"),
ChatCompletion\DelegatingChatClientTests.cs (2)
61new(ChatRole.User, "Message 1"), 62new(ChatRole.User, "Message 2")
Microsoft.Extensions.AI.Evaluation.Safety (1)
ContentSafetyChatClient.cs (1)
100yield return new ChatResponseUpdate(ChatRole.Assistant, annotationResult)
Microsoft.Extensions.AI.OpenAI (1)
OpenAIAssistantsChatClient.cs (1)
204ChatResponseUpdate textUpdate = new(mcu.Role == MessageRole.User ? ChatRole.User : ChatRole.Assistant, mcu.Text)
Microsoft.Extensions.AI.OpenAI.Tests (6)
OpenAIConversionTests.cs (6)
646var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Hello") 664var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Hello, world!") 843var responseUpdate = new ChatResponseUpdate(inputRole, "Test message"); 869var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Test") 890new ChatResponseUpdate(ChatRole.Assistant, "Hello, ") 897new ChatResponseUpdate(ChatRole.Assistant, "world!")
Microsoft.Extensions.AI.Tests (18)
ChatCompletion\DistributedCachingChatClientTest.cs (8)
313new(ChatRole.Assistant, "This"), 314new(ChatRole.Assistant, " becomes one chunk"), 316new(ChatRole.Assistant, "... and this"), 317new(ChatRole.Assistant, " becomes another"), 318new(ChatRole.Assistant, " one."), 436new(ChatRole.Assistant, "Chunk 1"), 484() => new(ChatRole.Assistant, "Chunk 1"), 523[() => new(ChatRole.Assistant, "A good result")]);
ChatCompletion\LoggingChatClientTests.cs (2)
108yield return new(ChatRole.Assistant, "blue "); 109yield return new(ChatRole.Assistant, "whale");
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
69yield return new ChatResponseUpdate(ChatRole.Assistant, text)
ChatCompletion\ReducingChatClientTests.cs (2)
50var expectedUpdates = new[] { new ChatResponseUpdate(ChatRole.Assistant, "It's"), new ChatResponseUpdate(null, " sunny!") };
ChatCompletion\UseDelegateChatClientTests.cs (5)
51return YieldUpdates(new ChatResponseUpdate(null, "world")); 133return YieldUpdates(new ChatResponseUpdate(null, "hello")); 154yield return new(null, " world"); 193return YieldUpdates(new ChatResponseUpdate(null, "streaming hello")); 225yield return new(null, " world (streaming)");
Microsoft.ML.GenAI.Core (1)
CausalLMPipelineChatClient.cs (1)
73yield return new(ChatRole.Assistant, output)