44 references to new
Microsoft.Extensions.AI.Abstractions (5)
ChatCompletion\ChatRole.cs (5)
22public static ChatRole System { get; } = new("system"); 25public static ChatRole Assistant { get; } = new("assistant"); 28public static ChatRole User { get; } = new("user"); 31public static ChatRole Tool { get; } = new("tool"); 96new(reader.GetString()!);
Microsoft.Extensions.AI.Abstractions.Tests (30)
ChatCompletion\ChatResponseTests.cs (1)
130ChatResponse response = new(new ChatMessage(new ChatRole("customRole"), "Text"))
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (1)
55Assert.Equal(new ChatRole("human"), message.Role);
ChatCompletion\ChatRoleTests.cs (28)
15Assert.Equal("abc", new ChatRole("abc").Value); 21Assert.Throws<ArgumentNullException>("value", () => new ChatRole(null!)); 22Assert.Throws<ArgumentException>("value", () => new ChatRole(" ")); 28Assert.True(new ChatRole("abc").Equals(new ChatRole("ABC"))); 29Assert.True(new ChatRole("abc").Equals((object)new ChatRole("ABC"))); 30Assert.True(new ChatRole("abc") == new ChatRole("ABC")); 31Assert.False(new ChatRole("abc") != new ChatRole("ABC")); 33Assert.False(new ChatRole("abc").Equals(new ChatRole("def"))); 34Assert.False(new ChatRole("abc").Equals((object)new ChatRole("def"))); 35Assert.False(new ChatRole("abc").Equals(null)); 36Assert.False(new ChatRole("abc").Equals("abc")); 37Assert.False(new ChatRole("abc") == new ChatRole("def")); 38Assert.True(new ChatRole("abc") != new ChatRole("def")); 40Assert.Equal(new ChatRole("abc").GetHashCode(), new ChatRole("abc").GetHashCode()); 41Assert.Equal(new ChatRole("abc").GetHashCode(), new ChatRole("ABC").GetHashCode()); 42Assert.NotEqual(new ChatRole("abc").GetHashCode(), new ChatRole("def").GetHashCode()); // not guaranteed 57ChatRole role = new("abc");
Microsoft.Extensions.AI.AzureAIInference (2)
AzureAIInferenceChatClient.cs (2)
37private static ChatRole ChatRoleDeveloper { get; } = new("developer"); 272new ChatRole(role.ToString());
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
274return new ChatMessage(new(message.Role), contents);
Microsoft.Extensions.AI.OpenAI (2)
OpenAIModelMapper.ChatCompletion.cs (1)
542_ => new ChatRole(role.ToString()),
OpenAIModelMapper.ChatMessage.cs (1)
17public static ChatRole ChatRoleDeveloper { get; } = new ChatRole("developer");
Microsoft.Extensions.AI.Tests (4)
ChatCompletion\DistributedCachingChatClientTest.cs (4)
43new ChatMessage(new ChatRole("fakeRole"), "This is some content") 221Role = new ChatRole("fakeRole2"), 234Role = new ChatRole("fakeRole2"), 607new ChatMessage(new ChatRole("fakeRole"),