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 (29)
ChatCompletion\ChatCompletionTests.cs (1)
208ChatCompletion completion = new(new ChatMessage(new ChatRole("customRole"), "Text"))
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 (1)
AzureAIInferenceChatClient.cs (1)
276new ChatRole(role.ToString());
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
254return new ChatMessage(new(message.Role), contents);
Microsoft.Extensions.AI.OpenAI (1)
OpenAIChatClient.cs (1)
381_ => new ChatRole(role.ToString()),
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\DistributedCachingChatClientTest.cs (1)
43new(new ChatRole("fakeRole"), "This is some content")