89 references to ChatMessage
Aspire.Azure.AI.OpenAI.Tests (1)
AspireAzureOpenAIClientBuilderChatClientExtensionsTests.cs (1)
221=> Task.FromResult(new ChatCompletion(new ChatMessage(ChatRole.Assistant, "Hello from middleware")));
Aspire.OpenAI.Tests (1)
AspireOpenAIClientBuilderChatClientExtensionsTests.cs (1)
222=> Task.FromResult(new ChatCompletion(new ChatMessage(ChatRole.Assistant, "Hello from middleware")));
Microsoft.Extensions.AI (3)
ChatCompletion\ChatClientStructuredOutputExtensions.cs (3)
70CompleteAsync<T>(chatClient, [new ChatMessage(ChatRole.User, chatMessage)], options, useNativeJsonSchema, cancellationToken); 92CompleteAsync<T>(chatClient, [new ChatMessage(ChatRole.User, chatMessage)], serializerOptions, options, useNativeJsonSchema, cancellationToken); 174promptAugmentation = new ChatMessage(ChatRole.User, $$"""
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatClientExtensions.cs (2)
45return client.CompleteAsync([new ChatMessage(ChatRole.User, chatMessage)], options, cancellationToken); 63return client.CompleteStreamingAsync([new ChatMessage(ChatRole.User, chatMessage)], options, cancellationToken);
Microsoft.Extensions.AI.Abstractions.Tests (10)
ChatCompletion\ChatCompletionTests.cs (9)
130new ChatMessage(ChatRole.Assistant, "Choice1"), 131new ChatMessage(ChatRole.Assistant, "Choice2"), 132new ChatMessage(ChatRole.Assistant, "Choice3"), 133new ChatMessage(ChatRole.Assistant, "Choice4"), 176new ChatMessage(ChatRole.Assistant, "This is a test." + Environment.NewLine + "It's multiple lines.") 187new ChatMessage(ChatRole.Assistant, "This is a test." + Environment.NewLine + "It's multiple lines."), 188new ChatMessage(ChatRole.Assistant, "So is" + Environment.NewLine + " this."), 189new ChatMessage(ChatRole.Assistant, "And this."), 208ChatCompletion completion = new(new ChatMessage(new ChatRole("customRole"), "Text"))
ChatCompletion\ChatMessageTests.cs (1)
35ChatMessage message = new(ChatRole.Assistant, text);
Microsoft.Extensions.AI.Integration.Tests (9)
ChatClientIntegrationTests.cs (3)
308var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000"); 325var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000"); 351var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000");
PromptBasedFunctionCallingChatClient.cs (1)
157existingToolPrompt = new ChatMessage(ChatRole.System, (string?)null);
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 (51)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (13)
56var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 81var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult))]); 113var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, "This is not valid JSON")]); 119var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 132var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, "null")]); 138var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 157var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 193var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 227var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 248var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(payload))]); 255var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 301var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") }; 329var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
ChatCompletion\DistributedCachingChatClientTest.cs (6)
85var result1 = await outer.CompleteAsync([new ChatMessage(ChatRole.User, "some input")]); 90var result2 = await outer.CompleteAsync([new ChatMessage(ChatRole.User, "some input")]); 97await outer.CompleteAsync([new ChatMessage(ChatRole.User, "some modified input")]); 122var result1 = outer.CompleteAsync([new ChatMessage(ChatRole.User, "some input")]); 123var result2 = outer.CompleteAsync([new ChatMessage(ChatRole.User, "some input")]); 134var result3 = outer.CompleteAsync([new ChatMessage(ChatRole.User, "some input")]);
ChatCompletion\FunctionInvokingChatClientTests.cs (28)
57new ChatMessage(ChatRole.User, "hello"), 64new ChatMessage(ChatRole.Assistant, "world"), 88new ChatMessage(ChatRole.User, "hello"), 111new ChatMessage(ChatRole.Assistant, "world"), 140new ChatMessage(ChatRole.User, "hello"), 151new ChatMessage(ChatRole.Assistant, "done"), 183new ChatMessage(ChatRole.User, "hello"), 194new ChatMessage(ChatRole.Assistant, "done"), 219new ChatMessage(ChatRole.User, "hello"), 226new ChatMessage(ChatRole.Assistant, "world"), 231new ChatMessage(ChatRole.User, "hello"), 232new ChatMessage(ChatRole.Assistant, "world") 271new ChatMessage(ChatRole.User, "hello"), 278new ChatMessage(ChatRole.Assistant, "world"), 286new ChatMessage(ChatRole.User, "hello"), 288new ChatMessage(ChatRole.Assistant, "more"), 289new ChatMessage(ChatRole.Assistant, "world"), 294new ChatMessage(ChatRole.User, "hello"), 301new ChatMessage(ChatRole.Assistant, "extrastuffmoreworld"), 304new ChatMessage(ChatRole.User, "hello"), 305new ChatMessage(ChatRole.Assistant, "extrastuffmoreworld"), 337new ChatMessage(ChatRole.User, "hello"), 340new ChatMessage(ChatRole.Assistant, "world"), 375List<ChatMessage> chat = [new ChatMessage(ChatRole.User, "hello")]; 396new ChatMessage(ChatRole.User, "hello"), 399new ChatMessage(ChatRole.Assistant, "world"), 452new ChatMessage(ChatRole.User, "hello"), 455new ChatMessage(ChatRole.Assistant, "world"),
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
42return new ChatCompletion([new ChatMessage(ChatRole.Assistant, "The blue whale, I think.")])
ChatCompletion\UseDelegateChatClientTests.cs (3)
50return Task.FromResult(new ChatCompletion(new ChatMessage(ChatRole.Assistant, "hello"))); 99return Task.FromResult(new ChatCompletion(new ChatMessage(ChatRole.Assistant, "hello"))); 192return Task.FromResult(new ChatCompletion(new ChatMessage(ChatRole.Assistant, "non-streaming hello")));
Microsoft.ML.GenAI.Core (1)
CausalLMPipelineChatClient.cs (1)
48var 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);