144 references to new
Microsoft.Extensions.AI.Abstractions.Tests (115)
ChatCompletion\ChatClientExtensionsTests.cs (2)
146return YieldAsync([new ChatResponseUpdate(ChatRole.Assistant, "world")]); 233return YieldAsync([new ChatResponseUpdate(ChatRole.Assistant, "world")]);
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (111)
32new(ChatRole.Assistant, "Hello") { ResponseId = "someResponse", MessageId = "12345", CreatedAt = new DateTimeOffset(2024, 2, 3, 4, 5, 6, TimeSpan.Zero), ModelId = "model123" }, 33new(ChatRole.Assistant, ", ") { AuthorName = "Someone", AdditionalProperties = new() { ["a"] = "b" } }, 34new(null, "world!") { CreatedAt = new DateTimeOffset(2025, 2, 3, 4, 5, 6, TimeSpan.Zero), ConversationId = "123", AdditionalProperties = new() { ["c"] = "d" } }, 76new(null, "!") { MessageId = "1" }, 77new(ChatRole.Assistant, "a") { MessageId = "1" }, 78new(ChatRole.Assistant, "b") { MessageId = "2" }, 79new(ChatRole.User, "c") { MessageId = "2" }, 80new(ChatRole.User, "d") { MessageId = "2" }, 81new(ChatRole.Assistant, "e") { MessageId = "3" }, 82new(ChatRole.Tool, "f") { MessageId = "4" }, 83new(ChatRole.Tool, "g") { MessageId = "4" }, 84new(ChatRole.Tool, "h") { MessageId = "5" }, 85new(new("human"), "i") { MessageId = "6" }, 86new(new("human"), "j") { MessageId = "7" }, 87new(new("human"), "k") { MessageId = "7" }, 88new(null, "l") { MessageId = "7" }, 89new(null, "m") { MessageId = "8" }, 134new(ChatRole.Assistant, "Hello ") { AuthorName = "Alice" }, 135new(null, "from ") { AuthorName = "Alice" }, 136new(null, "Alice!"), 139new(null, "Hi ") { AuthorName = "Bob" }, 140new(null, "from ") { AuthorName = "Bob" }, 141new(null, "Bob!"), 144new(ChatRole.Assistant, "Greetings ") { AuthorName = "Charlie" }, 145new(null, "from Charlie!") { AuthorName = "Charlie" }, 148new(null, "Alice again!") { AuthorName = "Alice" }, 151new(null, " Still Alice.") { AuthorName = "" }, 152new(null, " And more."), 187new(ChatRole.Assistant, "A") { MessageId = "1", AuthorName = "Alice" }, 188new(null, "B") { MessageId = "1", AuthorName = "Alice" }, 191new(null, "C") { MessageId = "1", AuthorName = "Bob" }, 194new(null, "D") { MessageId = "2", AuthorName = "Bob" }, 195new(null, "E") { MessageId = "2", AuthorName = "Bob" }, 198new(ChatRole.User, "F") { MessageId = "2", AuthorName = "Bob" }, 201new(ChatRole.Tool, "G") { MessageId = "3", AuthorName = "Charlie" }, 202new(null, "H") { MessageId = "3", AuthorName = "Charlie" }, 246new(ChatRole.Assistant, "Hello") { AuthorName = "Assistant" }, 249new(null, " world") { AuthorName = "" }, 252new(null, "!"), 255new(null, " How") { AuthorName = "" }, 256new(null, " are") { AuthorName = "" }, 259new(null, " you?") { AuthorName = null }, 281new(ChatRole.Assistant, "Hello") { MessageId = "1" }, 282new(null, " there") { MessageId = "1" }, 285new(null, " I'm Bob") { MessageId = "1", AuthorName = "Bob" }, 286new(null, " speaking") { MessageId = "1", AuthorName = "Bob" }, 289new(null, "Now Alice") { MessageId = "1", AuthorName = "Alice" }, 316new(ChatRole.Assistant, "Hello"), 317new(null, " there"), 320new(null, " from") { MessageId = "msg1" }, 321new(null, " AI") { MessageId = "msg1" }, 324new(null, "Next message") { MessageId = "msg2" }, 351new(ChatRole.Assistant, "Hello") { MessageId = "msg1" }, 352new(null, " world") { MessageId = "msg1" }, 355new(null, "!") { MessageId = "" }, 358new(null, " How"), 361new(null, " are") { MessageId = "" }, 362new(null, " you?"), 384new(null, "Hello") { MessageId = "1" }, 385new(null, " there") { MessageId = "1" }, 388new(ChatRole.Assistant, " from") { MessageId = "1" }, 389new(null, " AI") { MessageId = "1" }, 392new(ChatRole.User, "User message") { MessageId = "1" }, 419new(new ChatRole("agent1"), "Hello") { MessageId = "1" }, 420new(null, " from") { MessageId = "1" }, 421new(new ChatRole("agent1"), " agent1") { MessageId = "1" }, 424new(new ChatRole("agent2"), "Hi") { MessageId = "1" }, 425new(null, " from") { MessageId = "1" }, 426new(new ChatRole("agent2"), " agent2") { MessageId = "1" }, 429new(ChatRole.Assistant, "Assistant here") { MessageId = "1" }, 457new(null, "Hi! ") { CreatedAt = new DateTimeOffset(2023, 1, 1, 10, 0, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 458new(ChatRole.Assistant, "Hello") { MessageId = "msg1", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 0, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 459new(null, " from") { MessageId = "msg1", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 1, 0, TimeSpan.Zero) }, // Later CreatedAt should not overwrite first 460new(null, " AI") { MessageId = "msg1", AuthorName = "Assistant" }, // Keep same AuthorName to avoid creating new message 463new(null, "More text") { MessageId = "msg2", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 2, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 466new(ChatRole.User, "How") { MessageId = "msg3", CreatedAt = new DateTimeOffset(2024, 1, 1, 11, 0, 0, TimeSpan.Zero), AuthorName = "User" }, 467new(null, " are") { MessageId = "msg3", CreatedAt = new DateTimeOffset(2024, 1, 1, 11, 1, 0, TimeSpan.Zero) }, 468new(null, " you?") { MessageId = "msg3", AuthorName = "User" }, // Keep same AuthorName 471new(ChatRole.Assistant, "I'm doing well,") { MessageId = "msg4", CreatedAt = new DateTimeOffset(2024, 1, 1, 12, 0, 0, TimeSpan.Zero) }, 472new(null, " thank you!") { MessageId = "msg4", CreatedAt = new DateTimeOffset(2024, 1, 1, 12, 2, 0, TimeSpan.Zero) }, // Later CreatedAt should not overwrite first 475new(null, " How can I help?"), 557updates.Add(new(null, text)); 605new(null, "A"), 606new(null, "B"), 607new(null, "C"), 611new(null, "G"), 612new(null, "H"), 615new(null, "K"), 617new(null, "M"), 618new(null, "N"), 680new(null, "A"), 681new(null, "B"), 682new(null, "C"), 690new(null, "K"), 692new(null, "M"), 693new(null, "N"), 720new(null, "Hello, "), 721new(null, "world!"), 750new(ChatRole.Tool, "a") { MessageId = "4", CreatedAt = early }, 753new(null, "b") { CreatedAt = unixEpoch }, 756new(null, "c") { CreatedAt = beforeEpoch }, 759new(null, "d") { CreatedAt = middle }, 762new(null, "e") { CreatedAt = early }, 765new(null, "f") { CreatedAt = late }, 768new(null, "g") { CreatedAt = unixEpoch }, 771new(null, "h") { CreatedAt = null }, 819new(ChatRole.Assistant, "a") { CreatedAt = first }, 820new(null, "b") { CreatedAt = second }, 846new(null, "Let's generate"), 847new(null, " some images"), 862new(null, "Here are those generated images"),
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)
252ChatResponseUpdate textUpdate = new(mcu.Role == MessageRole.User ? ChatRole.User : ChatRole.Assistant, mcu.Text)
Microsoft.Extensions.AI.OpenAI.Tests (6)
OpenAIConversionTests.cs (6)
1118var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Hello") 1136var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Hello, world!") 1315var responseUpdate = new ChatResponseUpdate(inputRole, "Test message"); 1341var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Test") 1362new ChatResponseUpdate(ChatRole.Assistant, "Hello, ") 1369new ChatResponseUpdate(ChatRole.Assistant, "world!")
Microsoft.Extensions.AI.Tests (20)
ChatCompletion\DistributedCachingChatClientTest.cs (8)
314new(ChatRole.Assistant, "This"), 315new(ChatRole.Assistant, " becomes one chunk"), 317new(ChatRole.Assistant, "... and this"), 318new(ChatRole.Assistant, " becomes another"), 319new(ChatRole.Assistant, " one."), 437new(ChatRole.Assistant, "Chunk 1"), 485() => new(ChatRole.Assistant, "Chunk 1"), 524[() => new(ChatRole.Assistant, "A good result")]);
ChatCompletion\ImageGeneratingChatClientTests.cs (1)
229yield return new(ChatRole.Assistant, "test");
ChatCompletion\LoggingChatClientTests.cs (2)
108yield return new(ChatRole.Assistant, "blue "); 109yield return new(ChatRole.Assistant, "whale");
ChatCompletion\OpenTelemetryChatClientTests.cs (2)
69yield return new ChatResponseUpdate(ChatRole.Assistant, text) 371yield return new(ChatRole.Assistant, "Assistant response text");
ChatCompletion\ReducingChatClientTests.cs (2)
51var 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)