7 writes to Role
Microsoft.Extensions.AI.Abstractions (3)
ChatCompletion\ChatMessage.cs (1)
38Role = role;
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (2)
111message.Role = role; 156entry.Value.Role = ChatRole.Assistant;
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
97Role = ToChatRole(response.Role),
Microsoft.Extensions.AI.Integration.Tests (2)
PromptBasedFunctionCallingChatClient.cs (2)
66message.Role = ChatRole.User; 73message.Role = ChatRole.Assistant;
Microsoft.Extensions.AI.OpenAI (1)
OpenAIChatClient.cs (1)
123Role = ToChatRole(response.Role),
54 references to Role
Microsoft.Extensions.AI (7)
ChatCompletion\OpenTelemetryChatClient.cs (7)
414if (message.Role == ChatRole.Assistant) 419else if (message.Role == ChatRole.Tool) 435Log(new(1, message.Role == ChatRole.System ? OpenTelemetryConsts.GenAI.System.Message : OpenTelemetryConsts.GenAI.User.Message), 438Role = 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) 154if (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)
415if (input.Role == ChatRole.System) 419else if (input.Role == ChatRole.Tool) 442else if (input.Role == ChatRole.User) 446else if (input.Role == ChatRole.Assistant)
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (2)
150Assert.Equal(ChatRole.Assistant, response.Message.Role); 412Assert.Equal(ChatRole.Assistant, response.Message.Role);
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
367Role = content.Role.Value, 389Role = content.Role.Value,
Microsoft.Extensions.AI.Ollama.Tests (1)
OllamaChatClientTests.cs (1)
122Assert.Equal(ChatRole.Assistant, response.Message.Role);
Microsoft.Extensions.AI.OpenAI (5)
OpenAIChatClient.cs (5)
584if (input.Role == ChatRole.System || input.Role == ChatRole.User) 587yield return input.Role == ChatRole.System ? 591else if (input.Role == ChatRole.Tool) 614else if (input.Role == ChatRole.Assistant)
Microsoft.Extensions.AI.OpenAI.Tests (4)
OpenAIChatClientTests.cs (4)
193Assert.Equal(ChatRole.Assistant, response.Message.Role); 466Assert.Equal(ChatRole.Assistant, response.Message.Role); 559Assert.Equal(ChatRole.Assistant, response.Message.Role); 910Assert.Equal(ChatRole.Assistant, response.Message.Role);
Microsoft.Extensions.AI.Tests (6)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (2)
43Assert.Equal(ChatRole.User, message.Role); 289Assert.Equal(ChatRole.User, message.Role);
ChatCompletion\FunctionInvokingChatClientTests.cs (4)
537Assert.Equal(expectedMessage.Role, chatMessage.Role); 604Assert.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}",