151 references to new
Microsoft.Extensions.AI.Abstractions.Tests (121)
ChatCompletion\ChatClientExtensionsTests.cs (2)
146return YieldAsync([new ChatResponseUpdate(ChatRole.Assistant, "world")]); 233return YieldAsync([new ChatResponseUpdate(ChatRole.Assistant, "world")]);
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (117)
31new(ChatRole.Assistant, "Hello") { ResponseId = "someResponse", MessageId = "12345", CreatedAt = new DateTimeOffset(2024, 2, 3, 4, 5, 6, TimeSpan.Zero), ModelId = "model123" }, 32new(ChatRole.Assistant, ", ") { AuthorName = "Someone", AdditionalProperties = new() { ["a"] = "b" } }, 33new(null, "world!") { CreatedAt = new DateTimeOffset(2025, 2, 3, 4, 5, 6, TimeSpan.Zero), ConversationId = "123", AdditionalProperties = new() { ["c"] = "d" } }, 75new(null, "!") { MessageId = "1" }, 76new(ChatRole.Assistant, "a") { MessageId = "1" }, 77new(ChatRole.Assistant, "b") { MessageId = "2" }, 78new(ChatRole.User, "c") { MessageId = "2" }, 79new(ChatRole.User, "d") { MessageId = "2" }, 80new(ChatRole.Assistant, "e") { MessageId = "3" }, 81new(ChatRole.Tool, "f") { MessageId = "4" }, 82new(ChatRole.Tool, "g") { MessageId = "4" }, 83new(ChatRole.Tool, "h") { MessageId = "5" }, 84new(new("human"), "i") { MessageId = "6" }, 85new(new("human"), "j") { MessageId = "7" }, 86new(new("human"), "k") { MessageId = "7" }, 87new(null, "l") { MessageId = "7" }, 88new(null, "m") { MessageId = "8" }, 133new(ChatRole.Assistant, "Hello ") { AuthorName = "Alice" }, 134new(null, "from ") { AuthorName = "Alice" }, 135new(null, "Alice!"), 138new(null, "Hi ") { AuthorName = "Bob" }, 139new(null, "from ") { AuthorName = "Bob" }, 140new(null, "Bob!"), 143new(ChatRole.Assistant, "Greetings ") { AuthorName = "Charlie" }, 144new(null, "from Charlie!") { AuthorName = "Charlie" }, 147new(null, "Alice again!") { AuthorName = "Alice" }, 150new(null, " Still Alice.") { AuthorName = "" }, 151new(null, " And more."), 186new(ChatRole.Assistant, "A") { MessageId = "1", AuthorName = "Alice" }, 187new(null, "B") { MessageId = "1", AuthorName = "Alice" }, 190new(null, "C") { MessageId = "1", AuthorName = "Bob" }, 193new(null, "D") { MessageId = "2", AuthorName = "Bob" }, 194new(null, "E") { MessageId = "2", AuthorName = "Bob" }, 197new(ChatRole.User, "F") { MessageId = "2", AuthorName = "Bob" }, 200new(ChatRole.Tool, "G") { MessageId = "3", AuthorName = "Charlie" }, 201new(null, "H") { MessageId = "3", AuthorName = "Charlie" }, 245new(ChatRole.Assistant, "Hello") { AuthorName = "Assistant" }, 248new(null, " world") { AuthorName = "" }, 251new(null, "!"), 254new(null, " How") { AuthorName = "" }, 255new(null, " are") { AuthorName = "" }, 258new(null, " you?") { AuthorName = null }, 280new(ChatRole.Assistant, "Hello") { MessageId = "1" }, 281new(null, " there") { MessageId = "1" }, 284new(null, " I'm Bob") { MessageId = "1", AuthorName = "Bob" }, 285new(null, " speaking") { MessageId = "1", AuthorName = "Bob" }, 288new(null, "Now Alice") { MessageId = "1", AuthorName = "Alice" }, 315new(ChatRole.Assistant, "Hello"), 316new(null, " there"), 319new(null, " from") { MessageId = "msg1" }, 320new(null, " AI") { MessageId = "msg1" }, 323new(null, "Next message") { MessageId = "msg2" }, 350new(ChatRole.Assistant, "Hello") { MessageId = "msg1" }, 351new(null, " world") { MessageId = "msg1" }, 354new(null, "!") { MessageId = "" }, 357new(null, " How"), 360new(null, " are") { MessageId = "" }, 361new(null, " you?"), 383new(null, "Hello") { MessageId = "1" }, 384new(null, " there") { MessageId = "1" }, 387new(ChatRole.Assistant, " from") { MessageId = "1" }, 388new(null, " AI") { MessageId = "1" }, 391new(ChatRole.User, "User message") { MessageId = "1" }, 418new(new ChatRole("agent1"), "Hello") { MessageId = "1" }, 419new(null, " from") { MessageId = "1" }, 420new(new ChatRole("agent1"), " agent1") { MessageId = "1" }, 423new(new ChatRole("agent2"), "Hi") { MessageId = "1" }, 424new(null, " from") { MessageId = "1" }, 425new(new ChatRole("agent2"), " agent2") { MessageId = "1" }, 428new(ChatRole.Assistant, "Assistant here") { MessageId = "1" }, 456new(ChatRole.Assistant, "First message") { MessageId = "msg1", AdditionalProperties = new() { ["key1"] = "value1" } }, 457new(null, " part 2") { MessageId = "msg1", AdditionalProperties = new() { ["key2"] = "value2" } }, 460new(ChatRole.User, "Second message") { MessageId = "msg2", AdditionalProperties = new() { ["key1"] = "different_value1" } }, 461new(null, " part 2") { MessageId = "msg2", AdditionalProperties = new() { ["key3"] = "value3" } }, 464new(ChatRole.Assistant, "Third message") { MessageId = "msg3" }, 508new(ChatRole.Assistant, "Hello") { MessageId = "msg1", AdditionalProperties = new() { ["messageKey"] = "messageValue" } }, 541new(null, "Hi! ") { CreatedAt = new DateTimeOffset(2023, 1, 1, 10, 0, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 542new(ChatRole.Assistant, "Hello") { MessageId = "msg1", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 0, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 543new(null, " from") { MessageId = "msg1", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 1, 0, TimeSpan.Zero) }, // Later CreatedAt should not overwrite first 544new(null, " AI") { MessageId = "msg1", AuthorName = "Assistant" }, // Keep same AuthorName to avoid creating new message 547new(null, "More text") { MessageId = "msg2", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 2, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 550new(ChatRole.User, "How") { MessageId = "msg3", CreatedAt = new DateTimeOffset(2024, 1, 1, 11, 0, 0, TimeSpan.Zero), AuthorName = "User" }, 551new(null, " are") { MessageId = "msg3", CreatedAt = new DateTimeOffset(2024, 1, 1, 11, 1, 0, TimeSpan.Zero) }, 552new(null, " you?") { MessageId = "msg3", AuthorName = "User" }, // Keep same AuthorName 555new(ChatRole.Assistant, "I'm doing well,") { MessageId = "msg4", CreatedAt = new DateTimeOffset(2024, 1, 1, 12, 0, 0, TimeSpan.Zero) }, 556new(null, " thank you!") { MessageId = "msg4", CreatedAt = new DateTimeOffset(2024, 1, 1, 12, 2, 0, TimeSpan.Zero) }, // Later CreatedAt should not overwrite first 559new(null, " How can I help?"), 641updates.Add(new(null, text)); 689new(null, "A"), 690new(null, "B"), 691new(null, "C"), 695new(null, "G"), 696new(null, "H"), 699new(null, "K"), 701new(null, "M"), 702new(null, "N"), 764new(null, "A"), 765new(null, "B"), 766new(null, "C"), 774new(null, "K"), 776new(null, "M"), 777new(null, "N"), 804new(null, "Hello, "), 805new(null, "world!"), 834new(ChatRole.Tool, "a") { MessageId = "4", CreatedAt = early }, 837new(null, "b") { CreatedAt = unixEpoch }, 840new(null, "c") { CreatedAt = beforeEpoch }, 843new(null, "d") { CreatedAt = middle }, 846new(null, "e") { CreatedAt = early }, 849new(null, "f") { CreatedAt = late }, 852new(null, "g") { CreatedAt = unixEpoch }, 855new(null, "h") { CreatedAt = null }, 903new(ChatRole.Assistant, "a") { CreatedAt = first }, 904new(null, "b") { CreatedAt = second }, 930new(null, "Let's generate"), 931new(null, " some images"), 946new(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)
255ChatResponseUpdate textUpdate = new(mcu.Role == MessageRole.User ? ChatRole.User : ChatRole.Assistant, mcu.Text)
Microsoft.Extensions.AI.OpenAI.Tests (6)
OpenAIConversionTests.cs (6)
1163var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Hello") 1181var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Hello, world!") 1360var responseUpdate = new ChatResponseUpdate(inputRole, "Test message"); 1386var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Test") 1407new ChatResponseUpdate(ChatRole.Assistant, "Hello, ") 1414new ChatResponseUpdate(ChatRole.Assistant, "world!")
Microsoft.Extensions.AI.Tests (21)
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 (3)
70yield return new ChatResponseUpdate(ChatRole.Assistant, text) 374yield return new(ChatRole.Assistant, "Assistant response text"); 628yield return new(ChatRole.Assistant, "Processing with tools...");
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)