38 references to new
Microsoft.Extensions.AI.Abstractions (5)
ChatCompletion\ChatRole.cs (5)
20
public static ChatRole System { get; } =
new
("system");
23
public static ChatRole Assistant { get; } =
new
("assistant");
26
public static ChatRole User { get; } =
new
("user");
29
public static ChatRole Tool { get; } =
new
("tool");
94
new
(reader.GetString()!);
Microsoft.Extensions.AI.Abstractions.Tests (29)
ChatCompletion\ChatCompletionTests.cs (1)
208
ChatCompletion completion = new(new ChatMessage(new
ChatRole
("customRole"), "Text"))
ChatCompletion\ChatRoleTests.cs (28)
15
Assert.Equal("abc", new
ChatRole
("abc").Value);
21
Assert.Throws<ArgumentNullException>("value", () => new
ChatRole
(null!));
22
Assert.Throws<ArgumentException>("value", () => new
ChatRole
(" "));
28
Assert.True(new
ChatRole
("abc").Equals(new
ChatRole
("ABC")));
29
Assert.True(new
ChatRole
("abc").Equals((object)new
ChatRole
("ABC")));
30
Assert.True(new
ChatRole
("abc") == new
ChatRole
("ABC"));
31
Assert.False(new
ChatRole
("abc") != new
ChatRole
("ABC"));
33
Assert.False(new
ChatRole
("abc").Equals(new
ChatRole
("def")));
34
Assert.False(new
ChatRole
("abc").Equals((object)new
ChatRole
("def")));
35
Assert.False(new
ChatRole
("abc").Equals(null));
36
Assert.False(new
ChatRole
("abc").Equals("abc"));
37
Assert.False(new
ChatRole
("abc") == new
ChatRole
("def"));
38
Assert.True(new
ChatRole
("abc") != new
ChatRole
("def"));
40
Assert.Equal(new
ChatRole
("abc").GetHashCode(), new
ChatRole
("abc").GetHashCode());
41
Assert.Equal(new
ChatRole
("abc").GetHashCode(), new
ChatRole
("ABC").GetHashCode());
42
Assert.NotEqual(new
ChatRole
("abc").GetHashCode(), new
ChatRole
("def").GetHashCode()); // not guaranteed
57
ChatRole role =
new
("abc");
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
276
new
ChatRole
(role.ToString());
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
254
return 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)
43
new(new
ChatRole
("fakeRole"), "This is some content")