129 references to ChatMessage
Aspire.Azure.AI.OpenAI.Tests (1)
AspireAzureOpenAIClientBuilderChatClientExtensionsTests.cs (1)
221=> Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "Hello from middleware")));
Aspire.OpenAI.Tests (1)
AspireOpenAIClientBuilderChatClientExtensionsTests.cs (1)
269=> Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "Hello from middleware")));
Microsoft.Extensions.AI (3)
ChatCompletion\ChatClientStructuredOutputExtensions.cs (3)
69GetResponseAsync<T>(chatClient, new ChatMessage(ChatRole.User, chatMessage), options, useJsonSchemaResponseFormat, cancellationToken); 109GetResponseAsync<T>(chatClient, new ChatMessage(ChatRole.User, chatMessage), serializerOptions, options, useJsonSchemaResponseFormat, cancellationToken); 208promptAugmentation = new ChatMessage(ChatRole.User, $$"""
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatClientExtensions.cs (2)
100return client.GetResponseAsync(new ChatMessage(ChatRole.User, chatMessage), options, cancellationToken); 140return client.GetStreamingResponseAsync(new ChatMessage(ChatRole.User, chatMessage), options, cancellationToken);
Microsoft.Extensions.AI.Abstractions.Tests (5)
ChatCompletion\ChatMessageTests.cs (2)
36ChatMessage message = new(ChatRole.Assistant, text); 67message = new(ChatRole.User, (string?)null);
ChatCompletion\ChatResponseTests.cs (3)
87ChatResponse original = new(new ChatMessage(ChatRole.Assistant, "the message")) 122ChatResponse response = new(new ChatMessage(ChatRole.Assistant, $"This is a test.{Environment.NewLine}It's multiple lines.")); 130ChatResponse response = new(new ChatMessage(new ChatRole("customRole"), "Text") { MessageId = "someMessage" })
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
95ChatMessage message = new(ToChatRole(response.Role), response.Content)
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (2)
146[new ChatMessage(ChatRole.User, "hello")]; 219[new ChatMessage(ChatRole.User, "hello")];
Microsoft.Extensions.AI.Evaluation (3)
EvaluatorExtensions.cs (3)
51modelResponse: new ChatMessage(ChatRole.Assistant, modelResponse), 95userRequest: new ChatMessage(ChatRole.User, userRequest), 96modelResponse: new ChatMessage(ChatRole.Assistant, modelResponse),
Microsoft.Extensions.AI.Evaluation.Integration.Tests (3)
test\Libraries\Microsoft.Extensions.AI.Evaluation.Tests\ChatMessageUtilities.cs (3)
9=> new ChatMessage(ChatRole.System, message); 12=> new ChatMessage(ChatRole.User, message); 15=> new ChatMessage(ChatRole.Assistant, message);
Microsoft.Extensions.AI.Evaluation.Quality (17)
CoherenceEvaluator.cs (2)
118List<ChatMessage> evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)]; 198evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
CompletenessEvaluator.cs (2)
126List<ChatMessage> evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)]; 190evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
EquivalenceEvaluator.cs (2)
123List<ChatMessage> evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)]; 175evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
FluencyEvaluator.cs (2)
110List<ChatMessage> evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)]; 178evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
GroundednessEvaluator.cs (2)
128List<ChatMessage> evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)]; 300evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
RelevanceEvaluator.cs (2)
124List<ChatMessage> evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)]; 205evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
RelevanceTruthAndCompletenessEvaluator.cs (1)
264return [new ChatMessage(ChatRole.User, evaluationPrompt)];
RetrievalEvaluator.cs (2)
134List<ChatMessage> evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)]; 221evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
Utilities\JsonOutputFixer.cs (2)
67new ChatMessage(ChatRole.System, SystemPrompt), 68new ChatMessage(ChatRole.User, fixPrompt)
Microsoft.Extensions.AI.Evaluation.Reporting (3)
ScenarioRunExtensions.cs (3)
36modelResponse: new ChatMessage(ChatRole.Assistant, modelResponse), 65userRequest: new ChatMessage(ChatRole.User, userRequest), 66modelResponse: new ChatMessage(ChatRole.Assistant, modelResponse),
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (6)
ResultStoreTester.cs (2)
34messages: [new ChatMessage(ChatRole.User, "User prompt")], 35modelResponse: new ChatResponse(new ChatMessage(ChatRole.Assistant, "LLM response")),
ScenarioRunResultTests.cs (4)
86messages: [new ChatMessage(ChatRole.User, "prompt")], 87modelResponse: new ChatResponse(new ChatMessage(ChatRole.Assistant, "response")), 177messages: [new ChatMessage(ChatRole.User, "prompt")], 178modelResponse: new ChatResponse(new ChatMessage(ChatRole.Assistant, "response")),
Microsoft.Extensions.AI.Evaluation.Safety (2)
ContentSafetyChatClient.cs (1)
77return new ChatResponse(new ChatMessage(ChatRole.Assistant, annotationResult))
ContentSafetyEvaluator.cs (1)
142var payloadMessage = new ChatMessage(ChatRole.User, payload);
Microsoft.Extensions.AI.Evaluation.Tests (3)
ChatMessageUtilities.cs (3)
9=> new ChatMessage(ChatRole.System, message); 12=> new ChatMessage(ChatRole.User, message); 15=> new ChatMessage(ChatRole.Assistant, message);
Microsoft.Extensions.AI.Integration.Tests (11)
ChatClientIntegrationTests.cs (3)
477var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000"); 493var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000"); 518var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000");
PromptBasedFunctionCallingChatClient.cs (3)
72chatMessagesList[messageIndex] = new ChatMessage(ChatRole.User, $"<tool_call_result>{toolCallResultJson}</tool_call_result>"); 77chatMessagesList[messageIndex] = new ChatMessage(ChatRole.Assistant, $"<tool_call_json>{toolCallJson}</tool_call_json>"); 186return new ChatMessage(ChatRole.System, prompt);
ReducingChatClientTests.cs (5)
47new ChatMessage(ChatRole.User, "Hi there! Can you tell me about golden retrievers?"), 48new ChatMessage(ChatRole.Assistant, "Of course! Golden retrievers are known for their friendly and tolerant attitudes. They're great family pets and are very intelligent and easy to train."), 49new ChatMessage(ChatRole.User, "What kind of exercise do they need?"), 50new ChatMessage(ChatRole.Assistant, "Golden retrievers are quite active and need regular exercise. Daily walks, playtime, and activities like fetching or swimming are great for them."), 51new ChatMessage(ChatRole.User, "Are they good with kids?"),
Microsoft.Extensions.AI.Tests (54)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (12)
80var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 141var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 200var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "This is not valid JSON")); 206var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 219var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "null")); 225var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 244var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 272var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 300var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 325var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult, jso))); 367var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 395var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
ChatCompletion\DistributedCachingChatClientTest.cs (9)
46new ChatMessage(new ChatRole("fakeRole"), "This is some content") 116return new ChatResponse(new ChatMessage(ChatRole.Assistant, "Hello")); 160var input = new ChatMessage(ChatRole.User, "abc"); 190return new ChatResponse(new ChatMessage(ChatRole.Assistant, "A good result")); 199var input = new ChatMessage(ChatRole.User, "abc"); 470var input = new ChatMessage(ChatRole.User, "abc"); 508var input = new ChatMessage(ChatRole.User, "abc"); 535return new(new ChatMessage(ChatRole.Assistant, options!.AdditionalProperties!["someKey"]!.ToString())); 586return new(new ChatMessage(ChatRole.Assistant, options!.AdditionalProperties!["someKey"]!.ToString()));
ChatCompletion\FunctionInvokingChatClientTests.cs (28)
57new ChatMessage(ChatRole.User, "hello"), 64new ChatMessage(ChatRole.Assistant, "world"), 88new ChatMessage(ChatRole.User, "hello"), 111new ChatMessage(ChatRole.Assistant, "world"), 148new ChatMessage(ChatRole.User, "hello"), 159new ChatMessage(ChatRole.Assistant, "done"), 192new ChatMessage(ChatRole.User, "hello"), 203new ChatMessage(ChatRole.Assistant, "done"), 232new ChatMessage(ChatRole.User, "hello"), 281new ChatMessage(ChatRole.User, "hello"), 359new ChatMessage(ChatRole.User, "hello"), 406new ChatMessage(ChatRole.User, "hello"), 413new ChatMessage(ChatRole.Assistant, "world"), 443new ChatMessage(ChatRole.User, "hello"), 446new ChatMessage(ChatRole.Assistant, "world"), 465new ChatMessage(ChatRole.User, "hello"), 468new ChatMessage(ChatRole.Assistant, "world"), 521new ChatMessage(ChatRole.User, "hello"), 524new ChatMessage(ChatRole.Assistant, "world"), 582new(ChatRole.User, "Hello"), 640new(ChatRole.User, "Hello"), 698new ChatMessage(ChatRole.User, "hello"), 711new ChatMessage(ChatRole.Assistant, "world"), 825return new ChatResponse(new ChatMessage(ChatRole.Assistant, "done!")); 854new ChatMessage(ChatRole.User, "hello"), 857new ChatMessage(ChatRole.Assistant, "world"), 883new ChatMessage(ChatRole.User, "hello"), 893new ChatMessage(ChatRole.Assistant, "world"),
ChatCompletion\LoggingChatClientTests.cs (1)
59return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "blue whale")));
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
41return new ChatResponse(new ChatMessage(ChatRole.Assistant, "The blue whale, I think."))
ChatCompletion\UseDelegateChatClientTests.cs (3)
42return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "hello"))); 91return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "hello"))); 184return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "non-streaming hello")));
Microsoft.ML.GenAI.Core (1)
CausalLMPipelineChatClient.cs (1)
47var chatMessage = new ChatMessage(ChatRole.Assistant, output);
Microsoft.ML.GenAI.Core.Tests (3)
CasualLMDatasetTest.cs (3)
86new ChatMessage(ChatRole.System, "You are a helpful contoso assistant"), 87new ChatMessage(ChatRole.User, "What is contoso"), 93new ChatMessage(ChatRole.Assistant, "Contoso is a company"),
Microsoft.ML.GenAI.LLaMA.Tests (3)
LLaMA3_1Tests.cs (3)
134new ChatMessage(ChatRole.System, "You are a helpful AI assistant."), 135new ChatMessage(ChatRole.User, "Hello?"), 136new ChatMessage(ChatRole.Assistant, "World!"),
Microsoft.ML.GenAI.Samples (5)
Llama\SFT_Llama_3_2_1B.cs (3)
107new ChatMessage(ChatRole.System, "You are a helpful contoso assistant"), 108new ChatMessage(ChatRole.User, data.input), 111var assistantMessage = new ChatMessage(ChatRole.Assistant, data.output);
MEAI\Llama3_1.cs (1)
47var chatMessage = new ChatMessage(ChatRole.User, task);
MEAI\Phi3.cs (1)
37var chatMessage = new ChatMessage(ChatRole.User, task);