38 references to new
Microsoft.Extensions.AI.Abstractions (5)
ChatCompletion\ChatRole.cs (5)
20public static ChatRole System { get; } = new("system"); 23public static ChatRole Assistant { get; } = new("assistant"); 26public static ChatRole User { get; } = new("user"); 29public static ChatRole Tool { get; } = new("tool"); 94new(reader.GetString()!);
Microsoft.Extensions.AI.Abstractions.Tests (28)
ChatCompletion\ChatRoleTests.cs (28)
15Assert.Equal("abc", new ChatRole("abc").Value); 21Assert.Throws<ArgumentNullException>(() => new ChatRole(null!)); 22Assert.Throws<ArgumentException>(() => 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 (1)
AzureAIInferenceChatClient.cs (1)
264new ChatRole(role.ToString());
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
130Role = chunk.Message?.Role is not null ? new ChatRole(chunk.Message.Role) : null, 226return new ChatMessage(new(message.Role), contents);
Microsoft.Extensions.AI.OpenAI (1)
OpenAIChatClient.cs (1)
371_ => new ChatRole(role.ToString()),
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\DistributedCachingChatClientTest.cs (1)
43new(new ChatRole("fakeRole"), "This is some content")