143 references to new
Microsoft.Extensions.AI.Abstractions.Tests (114)
ChatCompletion\ChatClientExtensionsTests.cs (2)
146return YieldAsync([new ChatResponseUpdate(ChatRole.Assistant, "world")]); 233return YieldAsync([new ChatResponseUpdate(ChatRole.Assistant, "world")]);
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (110)
31new(ChatRole.Assistant, "Hello") { ResponseId = "someResponse", MessageId = "12345", CreatedAt = new DateTimeOffset(1, 2, 3, 4, 5, 6, TimeSpan.Zero), ModelId = "model123" }, 32new(ChatRole.Assistant, ", ") { AuthorName = "Someone", AdditionalProperties = new() { ["a"] = "b" } }, 33new(null, "world!") { CreatedAt = new DateTimeOffset(2, 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(null, "Hi! ") { CreatedAt = new DateTimeOffset(2023, 1, 1, 10, 0, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 457new(ChatRole.Assistant, "Hello") { MessageId = "msg1", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 0, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 458new(null, " from") { MessageId = "msg1", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 1, 0, TimeSpan.Zero) }, // Later CreatedAt should win 459new(null, " AI") { MessageId = "msg1", AuthorName = "Assistant" }, // Keep same AuthorName to avoid creating new message 462new(null, "More text") { MessageId = "msg2", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 2, 0, TimeSpan.Zero), AuthorName = "Assistant" }, 465new(ChatRole.User, "How") { MessageId = "msg3", CreatedAt = new DateTimeOffset(2024, 1, 1, 11, 0, 0, TimeSpan.Zero), AuthorName = "User" }, 466new(null, " are") { MessageId = "msg3", CreatedAt = new DateTimeOffset(2024, 1, 1, 11, 1, 0, TimeSpan.Zero) }, 467new(null, " you?") { MessageId = "msg3", AuthorName = "User" }, // Keep same AuthorName 470new(ChatRole.Assistant, "I'm doing well,") { MessageId = "msg4", CreatedAt = new DateTimeOffset(2024, 1, 1, 12, 0, 0, TimeSpan.Zero) }, 471new(null, " thank you!") { MessageId = "msg4", CreatedAt = new DateTimeOffset(2024, 1, 1, 12, 2, 0, TimeSpan.Zero) }, // Later CreatedAt should win 474new(null, " How can I help?"), 556updates.Add(new(null, text)); 604new(null, "A"), 605new(null, "B"), 606new(null, "C"), 610new(null, "G"), 611new(null, "H"), 614new(null, "K"), 616new(null, "M"), 617new(null, "N"), 679new(null, "A"), 680new(null, "B"), 681new(null, "C"), 689new(null, "K"), 691new(null, "M"), 692new(null, "N"), 719new(null, "Hello, "), 720new(null, "world!"), 748new(ChatRole.Tool, "a") { MessageId = "4", CreatedAt = early }, 751new(null, "b") { CreatedAt = unixEpoch }, 754new(null, "c") { CreatedAt = middle }, 757new(null, "d") { CreatedAt = early }, 760new(null, "e") { CreatedAt = late }, 763new(null, "f") { CreatedAt = unixEpoch }, 766new(null, "g") { CreatedAt = null }, 812new(ChatRole.Assistant, "a") { CreatedAt = first }, 813new(null, "b") { CreatedAt = second }, 839new(null, "Let's generate"), 840new(null, " some images"), 855new(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)
960var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Hello") 978var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Hello, world!") 1157var responseUpdate = new ChatResponseUpdate(inputRole, "Test message"); 1183var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Test") 1204new ChatResponseUpdate(ChatRole.Assistant, "Hello, ") 1211new ChatResponseUpdate(ChatRole.Assistant, "world!")
Microsoft.Extensions.AI.Tests (20)
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\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)
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)