15 writes to Role
Microsoft.Extensions.AI.Abstractions (3)
ChatCompletion\ChatMessage.cs (1)
38Role = role;
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (2)
111message.Role = role; 172entry.Value.Role = ChatRole.Assistant;
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
99Role = ToChatRole(response.Role),
Microsoft.Extensions.AI.Integration.Tests (2)
PromptBasedFunctionCallingChatClient.cs (2)
66message.Role = ChatRole.User; 73message.Role = ChatRole.Assistant;
Microsoft.Extensions.AI.OpenAI (5)
OpenAIModelMapper.ChatCompletion.cs (1)
79Role = FromOpenAIChatRole(openAICompletion.Role),
OpenAIModelMapper.ChatMessage.cs (4)
44Role = ChatRole.System, 53Role = ChatRole.User, 79Role = ChatRole.Tool, 88Role = ChatRole.Assistant,
Microsoft.Extensions.AI.OpenAI.Tests (4)
OpenAISerializationTests.cs (4)
438Role = ChatRole.Assistant, 535Role = ChatRole.Assistant, 541Role = ChatRole.Assistant, 681Role = ChatRole.Assistant,
65 references to Role
Microsoft.Extensions.AI (7)
ChatCompletion\OpenTelemetryChatClient.cs (7)
444if (message.Role == ChatRole.Assistant) 449else if (message.Role == ChatRole.Tool) 465Log(new(1, message.Role == ChatRole.System ? OpenTelemetryConsts.GenAI.System.Message : OpenTelemetryConsts.GenAI.User.Message), 468Role = message.Role != ChatRole.System && message.Role != ChatRole.User && !string.IsNullOrWhiteSpace(message.Role.Value) ? message.Role.Value : null,
Microsoft.Extensions.AI.Abstractions (3)
ChatCompletion\ChatCompletion.cs (1)
142Role = choice.Role,
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (2)
109if (update.Role is ChatRole role && message.Role == default) 170if (entry.Value.Role == default)
Microsoft.Extensions.AI.Abstractions.Tests (10)
ChatCompletion\ChatClientExtensionsTests.cs (2)
60Assert.Equal(ChatRole.User, m.Role); 87Assert.Equal(ChatRole.User, m.Role);
ChatCompletion\ChatCompletionTests.cs (1)
154Assert.Equal(ChatRole.Assistant, result.Choices[i].Role);
ChatCompletion\ChatMessageTests.cs (4)
20Assert.Equal(ChatRole.User, message.Role); 37Assert.Equal(ChatRole.Assistant, message.Role); 77Assert.Equal(ChatRole.System, message.Role); 304Assert.Equal("user", deserializedMessage.Role.Value);
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (3)
72Assert.Equal(ChatRole.User, message.Role); 80Assert.Equal(ChatRole.System, message.Role); 89Assert.Equal(ChatRole.Assistant, message.Role);
Microsoft.Extensions.AI.AzureAIInference (4)
AzureAIInferenceChatClient.cs (4)
417if (input.Role == ChatRole.System) 421else if (input.Role == ChatRole.Tool) 444else if (input.Role == ChatRole.User) 450else if (input.Role == ChatRole.Assistant)
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (2)
163Assert.Equal(ChatRole.Assistant, response.Message.Role); 661Assert.Equal(ChatRole.Assistant, response.Message.Role);
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
388Role = content.Role.Value, 410Role = content.Role.Value,
Microsoft.Extensions.AI.Ollama.Tests (1)
OllamaChatClientTests.cs (1)
122Assert.Equal(ChatRole.Assistant, response.Message.Role);
Microsoft.Extensions.AI.OpenAI (6)
OpenAIModelMapper.ChatCompletion.cs (1)
60role: ToOpenAIChatRole(chatCompletion.Message.Role).Value,
OpenAIModelMapper.ChatMessage.cs (5)
125if (input.Role == ChatRole.System || input.Role == ChatRole.User) 128yield return input.Role == ChatRole.System ? 132else if (input.Role == ChatRole.Tool) 155else if (input.Role == ChatRole.Assistant)
Microsoft.Extensions.AI.OpenAI.Tests (14)
OpenAIChatClientTests.cs (4)
193Assert.Equal(ChatRole.Assistant, response.Message.Role); 540Assert.Equal(ChatRole.Assistant, response.Message.Role); 639Assert.Equal(ChatRole.Assistant, response.Message.Role); 1010Assert.Equal(ChatRole.Assistant, response.Message.Role);
OpenAISerializationTests.cs (10)
47Assert.Equal(ChatRole.User, message.Role); 80Assert.Equal(ChatRole.User, message.Role); 153Assert.Equal(ChatRole.System, msg.Role); 165Assert.Equal(ChatRole.User, msg.Role); 177Assert.Equal(ChatRole.Assistant, msg.Role); 189Assert.Equal(ChatRole.User, msg.Role); 247Assert.Equal(ChatRole.System, msg.Role); 271Assert.Equal(ChatRole.User, msg.Role); 407Assert.Equal(ChatRole.Assistant, msg.Role); 419Assert.Equal(ChatRole.Tool, msg.Role);
Microsoft.Extensions.AI.Tests (6)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (2)
43Assert.Equal(ChatRole.User, message.Role); 291Assert.Equal(ChatRole.User, message.Role);
ChatCompletion\FunctionInvokingChatClientTests.cs (4)
599Assert.Equal(expectedMessage.Role, chatMessage.Role); 689Assert.Equal(expectedMessage.Role, chatMessage.Role);
Microsoft.ML.GenAI.LLaMA (5)
Llama3_1ChatTemplateBuilder.cs (5)
99if (messages.Any(m => availableRoles.Any(availableRole => availableRole == m.Role) == false)) 108var role = message.Role.Value; 112_ when message.Role == ChatRole.System => $"<|start_header_id|>system<|end_header_id|>{Newline}{content.Trim()}<|eot_id|>{Newline}", 113_ when message.Role == ChatRole.User => $"<|start_header_id|>user<|end_header_id|>{Newline}{content.Trim()}<|eot_id|>{Newline}", 114_ when message.Role == ChatRole.Assistant => $"<|start_header_id|>assistant<|end_header_id|>{Newline}{content.Trim()}<|eot_id|>{Newline}",
Microsoft.ML.GenAI.Phi (5)
Phi3\Phi3ChatTemplateBuilder.cs (5)
100if (messages.Any(m => availableRoles.Any(availableRole => availableRole == m.Role) == false)) 111var role = message.Role.Value; 115_ when message.Role == ChatRole.System => $"<|system|>{Newline}{content}<|end|>{Newline}", 116_ when message.Role == ChatRole.User => $"<|user|>{Newline}{content}<|end|>{Newline}", 117_ when message.Role == ChatRole.Assistant => $"<|assistant|>{Newline}{content}<|end|>{Newline}",