1148 instantiations of ChatMessage
Aspire.Azure.AI.Inference.Tests (1)
Aspire.Azure.AI.OpenAI.Tests (2)
Aspire.Dashboard (29)
Model\Assistant\Prompts\KnownChatMessages.cs (25)
43return new ChatMessage(ChatRole.System, systemChatMessage);
67return new(ChatRole.User, resolvedPromptText);
78return new(ChatRole.User, prompt);
89return new(ChatRole.User, prompt);
99return new(ChatRole.User, message);
112return new(ChatRole.User, prompt);
122return new(ChatRole.User, prompt);
133return new(ChatRole.User, prompt);
142return new(ChatRole.User, prompt);
155return new(ChatRole.User, prompt);
165return new(ChatRole.User, prompt);
174return new(ChatRole.User, prompt);
196return new(ChatRole.User, prompt);
214return new(ChatRole.User, prompt);
224return new(ChatRole.User, prompt);
234return new(ChatRole.User, prompt);
243return new(ChatRole.User, prompt);
255return new(ChatRole.User, message);
264return new(ChatRole.User, message);
274return new ChatMessage(ChatRole.User, message);
284return new ChatMessage(ChatRole.User, message);
311return new(ChatRole.User, prompt);
338return new(ChatRole.User, prompt);
356return new(ChatRole.User, prompt);
365return new(ChatRole.User, prompt);
Aspire.OpenAI.Tests (2)
Microsoft.AspNetCore.Components.AI (2)
Microsoft.Extensions.AI (12)
ChatCompletion\ChatClientStructuredOutputExtensions.cs (3)
61GetResponseAsync<T>(chatClient, new ChatMessage(ChatRole.User, chatMessage), options, useJsonSchemaResponseFormat, cancellationToken);
101GetResponseAsync<T>(chatClient, new ChatMessage(ChatRole.User, chatMessage), serializerOptions, options, useJsonSchemaResponseFormat, cancellationToken);
190promptAugmentation = new ChatMessage(ChatRole.User, $$"""
Microsoft.Extensions.AI.Abstractions (6)
ChatCompletion\ChatMessage.cs (1)
51new()
Microsoft.Extensions.AI.Abstractions.Tests (32)
Microsoft.Extensions.AI.Evaluation (3)
Microsoft.Extensions.AI.Evaluation.Integration.Tests (9)
Microsoft.Extensions.AI.Evaluation.NLP.Tests (17)
Microsoft.Extensions.AI.Evaluation.Quality (22)
Microsoft.Extensions.AI.Evaluation.Reporting (4)
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (1)
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (9)
Microsoft.Extensions.AI.Evaluation.Safety (2)
Microsoft.Extensions.AI.Evaluation.Tests (3)
Microsoft.Extensions.AI.Integration.Tests (79)
ChatClientIntegrationTests.cs (59)
68new(ChatRole.User, "Pick a city, any city"),
69new(ChatRole.Assistant, "Seattle"),
70new(ChatRole.User, "And another one"),
71new(ChatRole.Assistant, "Jakarta"),
72new(ChatRole.User, "What continent are they each in?"),
86new(ChatRole.System, []),
87new(ChatRole.User, []),
88new(ChatRole.Assistant, []),
89new(ChatRole.User, "What is 1 + 2? Reply with a single number."),
102new(ChatRole.User, "Quote, word for word, Neil Armstrong's famous words.")
160List<ChatMessage> history = [new(ChatRole.User, "Explain in 100 words how AI works")];
183new(ChatRole.User,
201new(ChatRole.User,
231new(ChatRole.User, "What is the current secret number?")
298new(ChatRole.User, "What is the secret number for id foo?")
330new(ChatRole.User, "What is the secret number for John aged 19?")
360new(ChatRole.User, "Can you add bacon, lettuce, and tomatoes to Peter's shopping cart?")
640var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000");
656var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000");
681var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000");
733var message = new ChatMessage(ChatRole.User, "What is the temperature?");
772var message = new ChatMessage(ChatRole.User, "What is the temperature?");
814var message = new ChatMessage(ChatRole.User, "What is the temperature?");
842await chatClient.GetResponseAsync([new(ChatRole.User, "What's the biggest animal?")]);
941var response = await chatClient.GetResponseAsync([new(ChatRole.User, "What's the biggest animal?")]);
1137new(ChatRole.User, "My name is Alice and I love hiking in the mountains."),
1138new(ChatRole.Assistant, "Nice to meet you, Alice! Hiking in the mountains sounds wonderful. Do you have a favorite trail?"),
1139new(ChatRole.User, "Yes, I love the Pacific Crest Trail. I hiked a section last summer."),
1140new(ChatRole.Assistant, "The Pacific Crest Trail is amazing! Which section did you hike?"),
1141new(ChatRole.User, "I hiked the section through the Sierra Nevada. It was challenging but beautiful."),
1142new(ChatRole.Assistant, "The Sierra Nevada section is known for its stunning views. How long did it take you?"),
1143new(ChatRole.User, "What's my name and what activity do I enjoy?")
1179new(ChatRole.System, "You are a pirate. Always respond in pirate speak."),
1180new(ChatRole.User, "Tell me about the weather"),
1181new(ChatRole.Assistant, "Ahoy matey! The weather be fine today, with clear skies on the horizon!"),
1182new(ChatRole.User, "What about tomorrow?"),
1183new(ChatRole.Assistant, "Arr, tomorrow be lookin' a bit cloudy, might be some rain blowin' in from the east!"),
1184new(ChatRole.User, "Should I bring an umbrella?"),
1185new(ChatRole.Assistant, "Aye, ye best be bringin' yer umbrella, unless ye want to be soaked like a barnacle!"),
1186new(ChatRole.User, "What's 2 + 2?")
1240new(ChatRole.User, "What's the weather in Seattle?"),
1241new(ChatRole.Assistant, "Let me check the weather in Seattle for you."),
1242new(ChatRole.User, "And what about Miami?"),
1243new(ChatRole.Assistant, "I'll check Miami's weather as well."),
1244new(ChatRole.User, "Which city had better weather?")
1274new(ChatRole.User, "I'm Bob and I work as a software engineer at a startup."),
1275new(ChatRole.Assistant, "Nice to meet you, Bob! Working at a startup must be exciting. What kind of software do you develop?"),
1276new(ChatRole.User, "We build AI-powered tools for education."),
1277new(ChatRole.Assistant, "That sounds impactful! AI in education has so much potential."),
1278new(ChatRole.User, "Yes, we focus on personalized learning experiences."),
1279new(ChatRole.Assistant, "Personalized learning is the future of education!"),
1280new(ChatRole.User, "Was anyone named in the conversation? Provide their name and job.")
1320new(ChatRole.User, "I have 3 cats and 2 dogs."),
1321new(ChatRole.Assistant, "That's 5 pets total! You must have a lively household."),
1322new(ChatRole.User, "Yes, and I spend about $200 per month on pet food."),
1323new(ChatRole.Assistant, "That's a significant expense, but I'm sure they're worth it!"),
1324new(ChatRole.User, "They eat 10 cans of food per week."),
1325new(ChatRole.Assistant, "That's quite a bit of food for your furry friends!"),
1326new(ChatRole.User, "How many pets do I have in total?")
ImageGeneratingChatClientIntegrationTests.cs (12)
128[new ChatMessage(ChatRole.User, "Please generate an image of a cat")],
166[new ChatMessage(ChatRole.User, [new TextContent("Please edit this image to add a red border"), originalImageData])],
195new(ChatRole.User, "Please generate an image of a dog")
203chatHistory.Add(new ChatMessage(ChatRole.User, "Please edit the image to make it more colorful"));
245new(ChatRole.User, "Please generate an image of a tree")
253chatHistory.Add(new ChatMessage(ChatRole.User, "Please edit the image to add flowers"));
258chatHistory.Add(new ChatMessage(ChatRole.User, "Please edit that last image to add birds"));
290new(ChatRole.User, "Please generate an image of a tree")
298chatHistory.Add(new ChatMessage(ChatRole.User, "Please edit the image to add fruit"));
303chatHistory.Add(new ChatMessage(ChatRole.User, "That didn't work out. Please edit the original image to add birds"));
341[new ChatMessage(ChatRole.User, "Generate an image of a castle")],
379new ChatMessage(ChatRole.User,
ReducingChatClientTests.cs (5)
45new ChatMessage(ChatRole.User, "Hi there! Can you tell me about golden retrievers?"),
46new 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."),
47new ChatMessage(ChatRole.User, "What kind of exercise do they need?"),
48new 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."),
49new ChatMessage(ChatRole.User, "Are they good with kids?"),
Microsoft.Extensions.AI.OpenAI (4)
Microsoft.Extensions.AI.OpenAI.Tests (95)
OpenAIChatClientTests.cs (17)
821new(ChatRole.System, "You are a really nice friend."),
822new(ChatRole.User, "hello!"),
823new(ChatRole.Assistant, "hi, how are you?"),
824new(ChatRole.User, "i'm good. how are you?"),
928new(ChatRole.System, [new TextContent("You are a really nice friend."), new TextContent("Really nice.")]),
929new(ChatRole.User, "hello!"),
1024new(ChatRole.System, "You are a really nice friend."),
1025new(ChatRole.User, "hello!"),
1026new(ChatRole.Assistant, (string?)null),
1027new(ChatRole.User, "i'm good. how are you?"),
1467new(ChatRole.System, "You are a really nice friend."),
1468new(ChatRole.User, "hello!"),
1469new(ChatRole.Assistant,
1475new (ChatRole.Tool,
1480new(ChatRole.Assistant, "You are great."),
1481new(ChatRole.User, "Thanks!"),
1587new(ChatRole.User,
OpenAIConversionTests.cs (36)
726new(ChatRole.System, "You are a helpful assistant."),
727new(ChatRole.User, "Hello") { AuthorName = "Jane" },
728new(ChatRole.Assistant,
737new(ChatRole.Tool, [new FunctionResultContent("callid123", "theresult")]),
738new(ChatRole.Assistant, "The answer is 42.") { AuthorName = "@#$#$@$" },
795new(ChatRole.System, "You are a helpful assistant."),
796new(ChatRole.User, "Hello"),
797new(ChatRole.Assistant,
806new(ChatRole.Tool, [new FunctionResultContent("callid123", "theresult")]),
807new(ChatRole.Assistant, "The answer is 42."),
848new(ChatRole.User,
856new(ChatRole.Assistant,
861new(ChatRole.User,
1191new(ChatRole.Assistant, "Hi there!")
1217new(ChatRole.Assistant,
1492var items = new ChatMessage[] { new(ChatRole.Assistant, [mcpToolCall, mcpToolResult]) }.AsOpenAIResponseItems().ToArray();
1519var chatResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant,
1558var chatResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "Hello"));
1588var chatResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant,
1633var chatResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "Test"))
1656var chatResponse = new ChatResponse(new ChatMessage(inputRole, "Test"));
1994var chatResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "Test"))
2007var chatResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "Hello, world!"))
2032var chatResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "Test message"))
2082new(ChatRole.Assistant, "First message"),
2083new(ChatRole.Assistant, "Second message"),
2084new(ChatRole.Assistant,
2119new(ChatRole.Assistant,
2124new(ChatRole.Tool, [new FunctionResultContent("call-456", "The weather is sunny")]),
2125new(ChatRole.Assistant, "The weather in Seattle is sunny!")
2154new(ChatRole.System, "You are a helpful assistant."),
2155new(ChatRole.User, "Hello, how are you?"),
2156new(ChatRole.Assistant, "I'm doing well, thank you for asking!")
2181var chatResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "Default test"));
2199var chatResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "Model test"));
2214var chatResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "Model priority test"))
OpenAIResponseClientIntegrationTests.cs (12)
267List<ChatMessage> input = [new ChatMessage(ChatRole.User, "Tell me the path to the README.md file for Microsoft.Extensions.AI.Abstractions in the dotnet/extensions repository")];
286var approvalResponse = new ChatMessage(ChatRole.Tool,
531List<ChatMessage> input = [new ChatMessage(ChatRole.User, "What is on my calendar for today?")];
543input.Add(new ChatMessage(ChatRole.Tool, [approvalRequest.CreateResponse(true)]));
706List<ChatMessage> chatHistory = [new ChatMessage(ChatRole.User, "What is 2+2? Think step by step but be very brief.")];
724chatHistory.Add(new ChatMessage(ChatRole.User, "What is 3+3?"));
743deserializedHistory.Add(new ChatMessage(ChatRole.User, "What is 4+4?"));
758deserializedHistory.Add(new ChatMessage(ChatRole.User, "What is 5+5?"));
787List<ChatMessage> chatHistory = [new ChatMessage(ChatRole.User, "What is 2+2? Think step by step but be very brief.")];
805chatHistory.Add(new ChatMessage(ChatRole.User, "What is 3+3?"));
824deserializedHistory.Add(new ChatMessage(ChatRole.User, "What is 4+4?"));
839deserializedHistory.Add(new ChatMessage(ChatRole.User, "What is 5+5?"));
OpenAIResponseClientTests.cs (30)
648chatHistory.Add(new ChatMessage(ChatRole.User, "Are you sure?"));
897var response = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "Search the web for the temperature today in Fremont")], chatOptions);
993await foreach (var update in client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "Search the web for the temperature today in Fremont")], chatOptions))
1617new ChatMessage(new ChatRole(role), [approvalRequest.CreateResponse(true)]), chatOptions);
1765new(new ChatRole(role), [anchorContent, codeInterpreterApproval, imageGenApproval]),
4822new ChatMessage(ChatRole.User, "test"),
4823new ChatMessage(ChatRole.Tool, [new FunctionResultContent("call_123", new TextContent("Result text"))])
4878new ChatMessage(ChatRole.User, "test"),
4879new ChatMessage(ChatRole.Tool, [
4940new ChatMessage(ChatRole.User, "test"),
4941new ChatMessage(ChatRole.Tool, [
4997new ChatMessage(ChatRole.User, "test"),
4998new ChatMessage(ChatRole.Tool, [
5054new ChatMessage(ChatRole.User, "test"),
5055new ChatMessage(ChatRole.Tool, [
5113new ChatMessage(ChatRole.User, "test"),
5114new ChatMessage(ChatRole.Tool, [
5176new ChatMessage(ChatRole.User, "test"),
5177new ChatMessage(ChatRole.Tool, [
5231new ChatMessage(ChatRole.User, "test"),
5232new ChatMessage(ChatRole.Tool, [
5286new ChatMessage(ChatRole.User, "test"),
5287new ChatMessage(ChatRole.Tool, [
5343new ChatMessage(ChatRole.User, "test"),
5344new ChatMessage(ChatRole.Tool, [
5400new ChatMessage(ChatRole.User, "test"),
5401new ChatMessage(ChatRole.Tool, [
5569new ChatMessage(ChatRole.User, [
5819[new ChatMessage(ChatRole.User, "test")],
6128var response = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "")]);
Microsoft.Extensions.AI.Tests (789)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (22)
23var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult, JsonContext2.Default.Animal)))
75var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
100var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult, JsonContext2.Default.Options)))
136var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
161var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult, JsonContext2.Default.Options)));
198new ChatMessage(ChatRole.Assistant,
203new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callid123", "result")]),
204new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult, JsonContext2.Default.Options))
239var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "This is not valid JSON"));
245var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
258var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "null"));
264var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
277var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, [new UriContent("https://example.com", "image/*")]));
283var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
297var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult, JsonContext2.Default.Options)));
311var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
332var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(payload, JsonContext2.Default.Options)));
339var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
364var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult, jso)));
401var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
425return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, resultDuplicatedJson)));
429var chatHistory = new List<ChatMessage> { new(ChatRole.User, "Hello") };
ChatCompletion\DistributedCachingChatClientTest.cs (12)
49new ChatMessage(new ChatRole("fakeRole"), "This is some content")
141return new ChatResponse(new ChatMessage(ChatRole.Assistant, "Hello"));
185var input = new ChatMessage(ChatRole.User, "abc");
215return new ChatResponse(new ChatMessage(ChatRole.Assistant, "A good result"));
224var input = new ChatMessage(ChatRole.User, "abc");
495var input = new ChatMessage(ChatRole.User, "abc");
533var input = new ChatMessage(ChatRole.User, "abc");
560return new(new ChatMessage(ChatRole.Assistant, options!.AdditionalProperties!["someKey"]!.ToString()));
611return new(new ChatMessage(ChatRole.Assistant, innerCallCount.ToString()));
657return new(new ChatMessage(ChatRole.Assistant, options!.AdditionalProperties!["someKey"]!.ToString()));
686new ChatMessage(new ChatRole("fakeRole"),
745new ChatMessage(ChatRole.Assistant, [new TextContent("Hey")])));
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (257)
36new ChatMessage(ChatRole.User, "hello"),
41new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
46new ChatMessage(ChatRole.Assistant,
72new ChatMessage(ChatRole.User, "hello"),
77new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
82new ChatMessage(ChatRole.Assistant,
119new ChatMessage(ChatRole.User, "hello"),
124new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
131new ChatMessage(ChatRole.Assistant,
169new ChatMessage(ChatRole.User, "hello"),
174new ChatMessage(ChatRole.Assistant, [
182new ChatMessage(ChatRole.Assistant,
214new ChatMessage(ChatRole.User, "hello"),
219new ChatMessage(ChatRole.Assistant, [
227new ChatMessage(ChatRole.Assistant,
256new ChatMessage(ChatRole.User, "hello"),
257new ChatMessage(ChatRole.Assistant,
262new ChatMessage(ChatRole.User,
271new ChatMessage(ChatRole.User, "hello"),
272new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
273new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
278new ChatMessage(ChatRole.Assistant, "world"),
283new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
284new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
285new ChatMessage(ChatRole.Assistant, "world"),
308new ChatMessage(ChatRole.User, "hello"),
309new ChatMessage(ChatRole.Assistant,
314new ChatMessage(ChatRole.User,
324new ChatMessage(ChatRole.User, "hello"),
325new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
326new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
331new ChatMessage(ChatRole.Assistant, "world"),
336new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
337new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
338new ChatMessage(ChatRole.Assistant, "world"),
360new ChatMessage(ChatRole.User, "hello"),
361new ChatMessage(ChatRole.Assistant,
365new ChatMessage(ChatRole.Assistant,
369new ChatMessage(ChatRole.User,
373new ChatMessage(ChatRole.User,
381new ChatMessage(ChatRole.User, "hello"),
382new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]) { MessageId = "resp1" },
383new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]) { MessageId = "resp2" },
384new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
389new ChatMessage(ChatRole.Assistant, "world"),
394new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]) { MessageId = "resp1" },
395new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]) { MessageId = "resp2" },
396new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
397new ChatMessage(ChatRole.Assistant, "world"),
419new ChatMessage(ChatRole.User, "hello"),
420new ChatMessage(ChatRole.Assistant,
425new ChatMessage(ChatRole.User,
434new ChatMessage(ChatRole.User, "hello"),
435new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
436new ChatMessage(ChatRole.Tool,
445new ChatMessage(ChatRole.Assistant, "world"),
450new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
451new ChatMessage(ChatRole.Tool,
456new ChatMessage(ChatRole.Assistant, "world"),
478new ChatMessage(ChatRole.User, "hello"),
479new ChatMessage(ChatRole.Assistant,
484new ChatMessage(ChatRole.User,
493new ChatMessage(ChatRole.User, "hello"),
494new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
495new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Tool call invocation rejected.")]),
496new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 2: 42")]),
501new ChatMessage(ChatRole.Assistant, "world"),
506new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
507new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Tool call invocation rejected.")]),
508new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 2: 42")]),
509new ChatMessage(ChatRole.Assistant, "world"),
514new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
515new ChatMessage(ChatRole.Tool,
520new ChatMessage(ChatRole.Assistant, "world"),
542new ChatMessage(ChatRole.User, "hello"),
543new ChatMessage(ChatRole.Assistant,
548new ChatMessage(ChatRole.User,
563new ChatMessage(ChatRole.User, "hello"),
564new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
565new ChatMessage(ChatRole.Tool,
574new ChatMessage(ChatRole.Assistant, "world"),
579new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
580new ChatMessage(ChatRole.Tool,
585new ChatMessage(ChatRole.Assistant, "world"),
608new ChatMessage(ChatRole.User, "hello"),
609new ChatMessage(ChatRole.Assistant,
615new ChatMessage(ChatRole.User,
625new ChatMessage(ChatRole.User, "hello"),
626new ChatMessage(ChatRole.Assistant,
632new ChatMessage(ChatRole.Tool,
637new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId3", result: "Result 3: test")]),
642new ChatMessage(ChatRole.Assistant, "world"),
647new ChatMessage(ChatRole.Assistant,
653new ChatMessage(ChatRole.Tool,
658new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId3", result: "Result 3: test")]),
659new ChatMessage(ChatRole.Assistant, "world"),
664new ChatMessage(ChatRole.Assistant,
670new ChatMessage(ChatRole.Tool,
676new ChatMessage(ChatRole.Assistant, "world"),
700new ChatMessage(ChatRole.User, "hello"),
701new ChatMessage(ChatRole.Assistant,
705new ChatMessage(ChatRole.User,
716new ChatMessage(ChatRole.User, "hello"),
717new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
718new ChatMessage(ChatRole.Tool,
726new ChatMessage(ChatRole.Assistant, "world"),
731new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
732new ChatMessage(ChatRole.Tool,
736new ChatMessage(ChatRole.Assistant, "world"),
758new ChatMessage(ChatRole.User, "hello"),
759new ChatMessage(ChatRole.Assistant,
764new ChatMessage(ChatRole.User,
773new ChatMessage(ChatRole.User, "hello"),
774new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
775new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
780new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 3 } })]),
785new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
786new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
787new ChatMessage(ChatRole.Assistant,
812new ChatMessage(ChatRole.User, "hello"),
813new ChatMessage(ChatRole.Assistant,
818new ChatMessage(ChatRole.User,
823new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
824new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
825new ChatMessage(ChatRole.Assistant,
829new ChatMessage(ChatRole.User,
837new ChatMessage(ChatRole.User, "hello"),
838new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
839new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
840new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "Func1")]),
841new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId3", result: "Result 1")]),
846new ChatMessage(ChatRole.Assistant, "World"),
851new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "Func1")]),
852new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId3", result: "Result 1")]),
853new ChatMessage(ChatRole.Assistant, "World"),
891new ChatMessage(ChatRole.User, "hello"),
892new ChatMessage(ChatRole.Assistant,
896new ChatMessage(ChatRole.User,
905Task.FromResult(new ChatResponse([new ChatMessage(ChatRole.Assistant, "world")])),
907YieldAsync(new ChatResponse([new ChatMessage(ChatRole.Assistant, "world")]).ToChatResponseUpdates()),
963new ChatMessage(ChatRole.User, "hello"),
964new ChatMessage(ChatRole.Assistant,
968new ChatMessage(ChatRole.User,
972new ChatMessage(ChatRole.Assistant,
976new ChatMessage(ChatRole.User,
985Task.FromResult(new ChatResponse([new ChatMessage(ChatRole.Assistant, "world")])),
987YieldAsync(new ChatResponse([new ChatMessage(ChatRole.Assistant, "world")]).ToChatResponseUpdates()),
1028new ChatMessage(ChatRole.User, "hello"),
1035new ChatMessage(ChatRole.User, "hello"),
1039new ChatMessage(ChatRole.User, "hello"),
1040new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1041new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 2: 42")])
1049new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1053new ChatMessage(ChatRole.Assistant, "World again"),
1059new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1060new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 2: 42")]),
1061new ChatMessage(ChatRole.Assistant, "World again"),
1083new ChatMessage(ChatRole.User, "hello"),
1084new ChatMessage(ChatRole.Assistant,
1113new ChatMessage(ChatRole.User, "hello"),
1114new ChatMessage(ChatRole.User,
1123new ChatMessage(ChatRole.User, "hello"),
1124new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1125new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
1130new ChatMessage(ChatRole.Assistant, "world"),
1135new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1136new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
1137new ChatMessage(ChatRole.Assistant, "world"),
1160new ChatMessage(ChatRole.User,
1169new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
1174new ChatMessage(ChatRole.Assistant, "world"),
1179new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1180new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1"), new FunctionResultContent("callId2", result: "Result 2: 42")]),
1181new ChatMessage(ChatRole.Assistant, "world"),
1204new ChatMessage(ChatRole.User,
1210new ChatMessage(ChatRole.User, "By the way, please keep the answer concise."),
1217new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1218new ChatMessage(ChatRole.User, "By the way, please keep the answer concise."),
1223new ChatMessage(ChatRole.Assistant, "world"),
1228new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1229new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1230new ChatMessage(ChatRole.Assistant, "world"),
1254new ChatMessage(ChatRole.User,
1265new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1266new ChatMessage(ChatRole.User, "please proceed"),
1271new ChatMessage(ChatRole.Assistant, "world"),
1276new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1277new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1278new ChatMessage(ChatRole.Assistant, "world"),
1299new ChatMessage(ChatRole.User, "hello"),
1300new ChatMessage(ChatRole.Assistant,
1304new ChatMessage(ChatRole.User,
1310new ChatMessage(ChatRole.User, "By the way, please keep the answer concise."),
1317new ChatMessage(ChatRole.User, "hello"),
1318new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1319new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1320new ChatMessage(ChatRole.User, "By the way, please keep the answer concise."),
1325new ChatMessage(ChatRole.Assistant, "world"),
1330new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1331new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1332new ChatMessage(ChatRole.Assistant, "world"),
1354new ChatMessage(ChatRole.User, "hello"),
1355new ChatMessage(ChatRole.Assistant,
1359new ChatMessage(ChatRole.User,
1368new ChatMessage(ChatRole.User, "hello"),
1369new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1370new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1371new ChatMessage(ChatRole.User, "please proceed"),
1376new ChatMessage(ChatRole.Assistant, "world"),
1381new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1382new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1383new ChatMessage(ChatRole.Assistant, "world"),
1412new ChatMessage(ChatRole.User, "hello"),
1413new ChatMessage(ChatRole.Assistant,
1417new ChatMessage(ChatRole.User,
1425new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1426new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1467List<ChatMessage> input = [new ChatMessage(ChatRole.User, "hello")];
1543List<ChatMessage> input = [new ChatMessage(ChatRole.User, "hello")];
1641List<ChatMessage> input = [new ChatMessage(ChatRole.User, "hello")];
1647new ChatMessage(ChatRole.Assistant, [alreadyProcessedFunctionCall]),
1653new ChatMessage(ChatRole.Assistant, [alreadyProcessedFunctionCall]),
1685new ChatMessage(ChatRole.User, "hello"),
1686new ChatMessage(ChatRole.Assistant,
1690new ChatMessage(ChatRole.User,
1698new ChatMessage(ChatRole.Assistant, "world"),
1704new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("function-call-id", "Func1")]) { MessageId = OriginalMessageId },
1705new ChatMessage(ChatRole.Tool, [new FunctionResultContent("function-call-id", result: "Result 1")]),
1706new ChatMessage(ChatRole.Assistant, "world"),
1736new ChatMessage(ChatRole.User, "hello"),
1741new ChatMessage(ChatRole.Assistant,
1750new ChatMessage(ChatRole.Assistant,
1779new ChatMessage(ChatRole.User, "hello"),
1780new ChatMessage(ChatRole.Assistant,
1785new ChatMessage(ChatRole.User,
1794new ChatMessage(ChatRole.User, "hello"),
1795new ChatMessage(ChatRole.Assistant,
1799new ChatMessage(ChatRole.Assistant,
1803new ChatMessage(ChatRole.Tool,
1807new ChatMessage(ChatRole.User,
1815new ChatMessage(ChatRole.Assistant, [
1823new ChatMessage(ChatRole.Assistant,
1827new ChatMessage(ChatRole.Tool,
1831new ChatMessage(ChatRole.Assistant, [
1863new ChatMessage(ChatRole.User, "hello"),
1864new ChatMessage(ChatRole.Assistant,
1869new ChatMessage(ChatRole.User,
1877new ChatMessage(ChatRole.User, "hello"),
1878new ChatMessage(ChatRole.Assistant,
1882new ChatMessage(ChatRole.Assistant,
1886new ChatMessage(ChatRole.Tool,
1892new ChatMessage(ChatRole.User,
1900new ChatMessage(ChatRole.Assistant, [
1909new ChatMessage(ChatRole.Assistant,
1913new ChatMessage(ChatRole.Tool,
1919new ChatMessage(ChatRole.Assistant, [
2090input.Select(m => new ChatMessage(m.Role, m.Contents.Select(CloneFcc).ToList()) { MessageId = m.MessageId }).ToList();
ChatCompletion\FunctionInvokingChatClientTests.cs (290)
93new ChatMessage(ChatRole.User, "hello"),
94new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
95new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
96new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
97new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 2: 42")]),
98new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]),
99new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId3", result: "Success: Function completed.")]),
100new ChatMessage(ChatRole.Assistant, "world"),
127new ChatMessage(ChatRole.User, "hello"),
128new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
129new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
130new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
131new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 2: 42")]),
132new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]),
133new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId3", result: "Success: Function completed.")]),
134new ChatMessage(ChatRole.Assistant, "world"),
160new ChatMessage(ChatRole.User, "hello"),
161new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
162new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
163new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
164new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 2: 42")]),
165new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]),
166new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId3", result: "Success: Function completed.")]),
167new ChatMessage(ChatRole.Assistant, "world"),
191new ChatMessage(ChatRole.User, "hello"),
192new ChatMessage(ChatRole.Assistant,
198new ChatMessage(ChatRole.Tool,
204new ChatMessage(ChatRole.Assistant,
209new ChatMessage(ChatRole.Tool,
214new ChatMessage(ChatRole.Assistant, "world"),
251new ChatMessage(ChatRole.User, "hello"),
252new ChatMessage(ChatRole.Assistant,
257new ChatMessage(ChatRole.Tool,
262new ChatMessage(ChatRole.Assistant, "done"),
295new ChatMessage(ChatRole.User, "hello"),
296new ChatMessage(ChatRole.Assistant,
301new ChatMessage(ChatRole.Tool,
306new ChatMessage(ChatRole.Assistant, "done"),
329new ChatMessage(ChatRole.User, "hello"),
330new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
331new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1 from delegate")]),
332new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
333new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 2: 42 from delegate")]),
334new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]),
335new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId3", result: "Success: Function completed.")]),
336new ChatMessage(ChatRole.Assistant, "world"),
380new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])));
384return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "done")));
393new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])).ToChatResponseUpdates());
397return YieldAsync(new ChatResponse(new ChatMessage(ChatRole.Assistant, "done")).ToChatResponseUpdates());
416new ChatMessage(ChatRole.User, "hello"),
461new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])));
465return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "done")));
474new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])).ToChatResponseUpdates());
478return YieldAsync(new ChatResponse(new ChatMessage(ChatRole.Assistant, "done")).ToChatResponseUpdates());
495new ChatMessage(ChatRole.User, "hello"),
542new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])));
546return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "done")));
555new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])).ToChatResponseUpdates());
559return YieldAsync(new ChatResponse(new ChatMessage(ChatRole.Assistant, "done")).ToChatResponseUpdates());
579new ChatMessage(ChatRole.User, "hello"),
636new ChatMessage(ChatRole.User, "hello"),
637new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId0", "VoidReturn")]),
644plan.Add(new ChatMessage(ChatRole.Tool, [new FunctionResultContent($"callId{i}", result: "Success: Function completed.")]));
645plan.Add(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId{(i + 1)}", "VoidReturn")]));
668var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId{capturedOptions.Count}", "Func1")]);
712var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId{capturedOptions.Count}", "Func1")]);
759var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]);
764var message = new ChatMessage(ChatRole.Assistant, "Done");
804var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]);
858new ChatMessage(ChatRole.User, "hello"),
936new ChatMessage(ChatRole.User, "hello"),
953var assistantMessage = new ChatMessage(ChatRole.Assistant, []);
954var toolMessage = new ChatMessage(ChatRole.Tool, []);
983new ChatMessage(ChatRole.User, "hello"),
984new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]),
985new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 1")]),
986new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
987new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 2: 42")]),
988new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]),
989new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId3", result: "Success: Function completed.")]),
990new ChatMessage(ChatRole.Assistant, "world"),
1020new ChatMessage(ChatRole.User, "hello"),
1021new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1022new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: detailedErrors ? "Error: Function failed. Exception: Oh no!" : "Error: Function failed.")]),
1023new ChatMessage(ChatRole.Assistant, "world"),
1042new ChatMessage(ChatRole.User, "hello"),
1043new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]),
1044new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1045new ChatMessage(ChatRole.Assistant, "world"),
1099new ChatMessage(ChatRole.User, "hello"),
1100new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]),
1101new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1102new ChatMessage(ChatRole.Assistant, "world"),
1177new(ChatRole.User, "Hello"),
1235new(ChatRole.User, "Hello"),
1245new(ChatRole.Assistant, [new FunctionCallContent($"callId{chatContents.Count()}", "Func1")]) :
1246new(ChatRole.Assistant, "The answer is 42.");
1293new ChatMessage(ChatRole.User, "hello"),
1294new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["i"] = 41 })]),
1295new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 41")]),
1296new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["i"] = 42 })]),
1297new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId2", result: "Result 42")]),
1304new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "Func1", new Dictionary<string, object?> { ["i"] = 43 })]),
1305new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId3", result: "Result 43")]),
1306new ChatMessage(ChatRole.Assistant, "world"),
1369var message = new ChatMessage(ChatRole.Assistant, resultContents);
1377List<ChatMessage> messages = [new(ChatRole.User, "hello")];
1412return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId-abc", "Func1")]))
1420return new ChatResponse(new ChatMessage(ChatRole.Assistant, "done!"));
1449new ChatMessage(ChatRole.User, "hello"),
1450new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]),
1451new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1452new ChatMessage(ChatRole.Assistant, "world"),
1478new ChatMessage(ChatRole.User, "hello"),
1479new ChatMessage(ChatRole.Assistant, [
1483new ChatMessage(ChatRole.Tool,
1488new ChatMessage(ChatRole.Assistant, "world"),
1531new(ChatRole.User, "hello"),
1532new(ChatRole.Assistant, [
1536new(ChatRole.Tool, [
1540new(ChatRole.Assistant, "done"),
1550new(ChatRole.User, "hello"),
1551new(ChatRole.Assistant, [
1555new(ChatRole.Tool, [
1559new(ChatRole.Assistant, "done"),
1579new(ChatRole.User, "hello"),
1580new(ChatRole.Assistant, [new FunctionCallContent("callId1", "DefOnly")]),
1581new(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Should not be produced")]),
1582new(ChatRole.Assistant, "world"),
1608new(ChatRole.User, "hi"),
1609new(ChatRole.Assistant, [
1613new(ChatRole.Tool, [new FunctionResultContent("callId1", result: "OK"), new FunctionResultContent("callId2", result: "nope")]),
1614new(ChatRole.Assistant, "done"),
1645messages.Add(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]));
1681new ChatMessage(ChatRole.User, "hello"),
1682new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1683new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1684new ChatMessage(ChatRole.Assistant, "world"),
1741? new(ChatRole.Assistant, [new FunctionCallContent("call1", "Func1")])
1742: new(ChatRole.Assistant, "Done");
1762[new ChatMessage(ChatRole.User, "hello")], options))
1792new ChatMessage(ChatRole.User, "hello"),
1793new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1794new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1795new ChatMessage(ChatRole.Assistant, "world"),
1834new ChatMessage(ChatRole.User, "hello"),
1835new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1836new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1837new ChatMessage(ChatRole.Assistant, "world"),
1884new ChatMessage(ChatRole.User, "hello"),
1885new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "secret" })]),
1886new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1887new ChatMessage(ChatRole.Assistant, "world"),
1956new ChatMessage(ChatRole.User, "hello"),
1957new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
1958new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
1959new ChatMessage(ChatRole.Assistant, "world"),
2005new ChatMessage(ChatRole.User, "hello"),
2006new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
2007new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Result 1")]),
2008new ChatMessage(ChatRole.Assistant, "world"),
2042var message = new ChatMessage(ChatRole.Assistant, [alreadyProcessedFunctionCall]);
2048var message = new ChatMessage(ChatRole.Assistant, [alreadyProcessedFunctionCall]);
2056? await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "hello")], options).ToChatResponseAsync()
2057: await client.GetResponseAsync([new ChatMessage(ChatRole.User, "hello")], options);
2097var message = new ChatMessage(ChatRole.Assistant, [needsProcessing, alreadyProcessed]);
2103var message = new ChatMessage(ChatRole.Assistant, "done");
2112var message = new ChatMessage(ChatRole.Assistant, [needsProcessing, alreadyProcessed]);
2118var message = new ChatMessage(ChatRole.Assistant, "done");
2127? await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "hello")], options).ToChatResponseAsync()
2128: await client.GetResponseAsync([new ChatMessage(ChatRole.User, "hello")], options);
2161return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]));
2165return new ChatResponse(new ChatMessage(ChatRole.Assistant, "Done"));
2174var response = await client2.GetResponseAsync([new ChatMessage(ChatRole.User, "hello")], options);
2224var message = new ChatMessage(ChatRole.Assistant, CloneContents(plan[contents.Count()].Contents))
2288ChatMessage message = new(ChatRole.Assistant, CloneContents(plan[contents.Count()].Contents))
2388return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2395return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2401return new ChatResponse([new ChatMessage(ChatRole.Assistant, "Done")]);
2411message = new ChatMessage(ChatRole.Assistant,
2417message = new ChatMessage(ChatRole.Assistant,
2422message = new ChatMessage(ChatRole.Assistant, "Done");
2433var result = await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "test")], options).ToChatResponseAsync();
2438var result = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "test")], options);
2482return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2489return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2495return new ChatResponse([new ChatMessage(ChatRole.Assistant, "Done")]);
2505message = new ChatMessage(ChatRole.Assistant,
2511message = new ChatMessage(ChatRole.Assistant,
2516message = new ChatMessage(ChatRole.Assistant, "Done");
2527var result = await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "test")], options).ToChatResponseAsync();
2536var result = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "test")], options);
2589return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2595return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2600return new ChatResponse([new ChatMessage(ChatRole.Assistant, "Done")]);
2610message = new ChatMessage(ChatRole.Assistant,
2616message = new ChatMessage(ChatRole.Assistant,
2621message = new ChatMessage(ChatRole.Assistant, "Done");
2632var result = await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "test")], options).ToChatResponseAsync();
2642var result = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "test")], options);
2687return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2695return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2701return new ChatResponse([new ChatMessage(ChatRole.Assistant, "Done")]);
2711message = new ChatMessage(ChatRole.Assistant,
2717message = new ChatMessage(ChatRole.Assistant,
2723message = new ChatMessage(ChatRole.Assistant, "Done");
2737var result = await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "test")], options).ToChatResponseAsync();
2745var result = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "test")], options);
2791return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2797return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2802return new ChatResponse([new ChatMessage(ChatRole.Assistant, "Done")]);
2812message = new ChatMessage(ChatRole.Assistant,
2818message = new ChatMessage(ChatRole.Assistant,
2823message = new ChatMessage(ChatRole.Assistant, "Done");
2837var result = await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "test")], options).ToChatResponseAsync();
2847var result = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "test")], options);
2889return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2894return new ChatResponse([new ChatMessage(ChatRole.Assistant, "Done")]);
2904message = new ChatMessage(ChatRole.Assistant,
2909message = new ChatMessage(ChatRole.Assistant, "Done");
2920var result = await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "test")], options).ToChatResponseAsync();
2925var result = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "test")], options);
2967return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2975return new ChatResponse([new ChatMessage(ChatRole.Assistant,
2980return new ChatResponse([new ChatMessage(ChatRole.Assistant, "Done")]);
2990message = new ChatMessage(ChatRole.Assistant,
2996message = new ChatMessage(ChatRole.Assistant,
3001message = new ChatMessage(ChatRole.Assistant, "Done");
3012var result = await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "test")], options).ToChatResponseAsync();
3021var result = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "test")], options);
3068return new ChatResponse([new ChatMessage(ChatRole.Assistant,
3076return new ChatResponse([new ChatMessage(ChatRole.Assistant,
3081return new ChatResponse([new ChatMessage(ChatRole.Assistant, "Done")]);
3091message = new ChatMessage(ChatRole.Assistant,
3097message = new ChatMessage(ChatRole.Assistant,
3102message = new ChatMessage(ChatRole.Assistant, "Done");
3113var result = await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "test")], options).ToChatResponseAsync();
3123var result = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "test")], options);
3174return new ChatResponse([new ChatMessage(ChatRole.Assistant,
3182return new ChatResponse([new ChatMessage(ChatRole.Assistant,
3187return new ChatResponse([new ChatMessage(ChatRole.Assistant, "Done")]);
3197message = new ChatMessage(ChatRole.Assistant,
3203message = new ChatMessage(ChatRole.Assistant,
3208message = new ChatMessage(ChatRole.Assistant, "Done");
3219var result = await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "test")], options).ToChatResponseAsync();
3230var result = await client.GetResponseAsync([new ChatMessage(ChatRole.User, "test")], options);
3257new ChatMessage(ChatRole.User, "hello"),
3258new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "UnknownFunc")]),
3259new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Error: Requested function \"UnknownFunc\" not found.")]),
3260new ChatMessage(ChatRole.Assistant, "world"),
3287new ChatMessage(ChatRole.User, "hello"),
3288new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
3289new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Should not be produced")]),
3290new ChatMessage(ChatRole.Assistant, "world"),
3323new ChatMessage(ChatRole.User, "hello"),
3324new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "TerminatingFunc")]),
3325new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", result: "Terminated")]),
3352new ChatMessage(ChatRole.User, "hello"),
3353new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
3359new ChatMessage(ChatRole.User, "hello"),
3360new ChatMessage(ChatRole.Assistant,
3386Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "world")))
3395new ChatMessage(ChatRole.User, "hello"),
3396new ChatMessage(ChatRole.Assistant,
3400new ChatMessage(ChatRole.User,
3423Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "world")))
3432new ChatMessage(ChatRole.User, "hello"),
3433new ChatMessage(ChatRole.Assistant,
3437new ChatMessage(ChatRole.User,
3474new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
3475new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", "Server Result")]),
3482new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
3483new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", "Server Result")]),
3492? await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "hello")], options).ToChatResponseAsync()
3493: await client.GetResponseAsync([new ChatMessage(ChatRole.User, "hello")], options);
3538new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2")]),
3539new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", "Server Result 1")]),
3544return new ChatResponse(new ChatMessage(ChatRole.Assistant, "done"));
3553new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2")]),
3554new ChatMessage(ChatRole.Tool, [new FunctionResultContent("callId1", "Server Result 1")]),
3560var response = new ChatResponse(new ChatMessage(ChatRole.Assistant, "done"));
3569? await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "hello")], options).ToChatResponseAsync()
3570: await client.GetResponseAsync([new ChatMessage(ChatRole.User, "hello")], options);
3607return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]));
3611return new ChatResponse(new ChatMessage(ChatRole.Assistant, "done"));
3618var response = new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]));
3623var response = new ChatResponse(new ChatMessage(ChatRole.Assistant, "done"));
3632? await client.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "hello")], options).ToChatResponseAsync()
3633: await client.GetResponseAsync([new ChatMessage(ChatRole.User, "hello")], options);
ChatCompletion\ImageGeneratingChatClientTests.cs (17)
39return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "test response")));
52var response = await client.GetResponseAsync([new(ChatRole.User, "test")], chatOptions);
76return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "test response")));
89var response = await client.GetResponseAsync([new(ChatRole.User, "test")], chatOptions);
123return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "test response")));
137var response = await client.GetResponseAsync([new(ChatRole.User, "test")], chatOptions);
241await foreach (var update in client.GetStreamingResponseAsync([new(ChatRole.User, "test")], chatOptions))
261return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "test response")));
269var response = await client.GetResponseAsync([new(ChatRole.User, "test")], null);
284return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "test response")));
297await client.GetResponseAsync([new(ChatRole.User, "test")], chatOptions);
316var responseMessage = new ChatMessage(ChatRole.Assistant,
331var response = await client.GetResponseAsync([new(ChatRole.User, "test")], chatOptions);
373await foreach (var responseUpdate in client.GetStreamingResponseAsync([new(ChatRole.User, "test")], chatOptions))
413return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, contents)));
426var response = await client.GetResponseAsync([new(ChatRole.User, "test")], chatOptions);
501await foreach (var update in client.GetStreamingResponseAsync([new(ChatRole.User, "test")], chatOptions))
ChatCompletion\OpenTelemetryChatClientTests.cs (24)
41return new ChatResponse(new ChatMessage(ChatRole.Assistant, "The blue whale, I think."))
114new(ChatRole.System, "You are a close friend."),
115new(ChatRole.User, "Hey!") { AuthorName = "Alice" },
116new(ChatRole.Assistant, [new FunctionCallContent("12345", "GetPersonName")]),
117new(ChatRole.Tool, [new FunctionResultContent("12345", "John")]),
118new(ChatRole.Assistant, "Hey John, what's up?") { AuthorName = "BotAssistant" },
119new(ChatRole.User, "What's the biggest animal?")
404return new ChatResponse(new ChatMessage(ChatRole.Assistant,
442new(ChatRole.User,
450new(ChatRole.Assistant, [new FunctionCallContent("call-456", "SearchFiles")]),
451new(ChatRole.Tool, [new FunctionResultContent("call-456", "Found 3 files")]),
588return new ChatResponse(new ChatMessage(ChatRole.Assistant, "The blue whale, I think."));
603new(ChatRole.User,
658return new ChatResponse(new ChatMessage(ChatRole.Assistant,
705new(ChatRole.User, "Execute code and generate an image"),
823return new ChatResponse(new ChatMessage(ChatRole.Assistant, "Done"));
843new(ChatRole.Assistant,
847new(ChatRole.User,
932await foreach (var update in chatClient.GetStreamingResponseAsync([new(ChatRole.User, "Hello")], new ChatOptions { ModelId = "mymodel" }))
980return new ChatResponse(new ChatMessage(ChatRole.Assistant, "Response"));
992await chatClient.GetResponseAsync([new(ChatRole.User, "Hello")]);
1037await foreach (var update in chatClient.GetStreamingResponseAsync([new(ChatRole.User, "Hello")]))
1046chatClient.GetResponseAsync([new(ChatRole.User, "Hello")]));
1091await foreach (var update in chatClient.GetStreamingResponseAsync([new(ChatRole.User, "Hello")]))
ChatCompletion\ReducingChatClientTests.cs (9)
37new(ChatRole.System, "You are a helpful assistant"),
38new(ChatRole.User, "Hello"),
39new(ChatRole.Assistant, "Hi there!"),
40new(ChatRole.User, "What's the weather?")
45new(ChatRole.System, "You are a helpful assistant"),
46new(ChatRole.User, "What's the weather?")
50var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, "It's sunny!"));
98var reducedMessages = new List<ChatMessage> { new(ChatRole.User, "Reduced message") };
119await client.GetResponseAsync(new List<ChatMessage> { new(ChatRole.User, "Original message") });
ChatReduction\MessageCountingChatReducerTests.cs (28)
53new ChatMessage(ChatRole.System, "You are a helpful assistant."),
54new ChatMessage(ChatRole.User, "Hello"),
55new ChatMessage(ChatRole.Assistant, "Hi there!"),
56new ChatMessage(ChatRole.User, "How are you?"),
57new ChatMessage(ChatRole.Assistant, "I'm doing well, thanks!"),
88new ChatMessage(ChatRole.System, "First system message"),
89new ChatMessage(ChatRole.User, "Hello"),
90new ChatMessage(ChatRole.System, "Second system message"),
91new ChatMessage(ChatRole.Assistant, "Hi"),
92new ChatMessage(ChatRole.User, "How are you?"),
93new ChatMessage(ChatRole.Assistant, "I'm fine!"),
127new ChatMessage(ChatRole.User, "What's the weather?"),
128new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call1", "get_weather", new Dictionary<string, object?> { ["location"] = "Seattle" })]),
129new ChatMessage(ChatRole.Tool, [new FunctionResultContent("call1", "Sunny, 72°F")]),
130new ChatMessage(ChatRole.Assistant, "The weather in Seattle is sunny and 72°F."),
131new ChatMessage(ChatRole.User, "Thanks!"),
132new ChatMessage(ChatRole.Assistant, "You're welcome!"),
167messages.Add(new ChatMessage(i % 2 == 0 ? ChatRole.User : ChatRole.Assistant, $"Message {i}"));
202new ChatMessage(ChatRole.System, "System prompt"),
223new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call1", "func", null)]),
224new ChatMessage(ChatRole.Tool, [new FunctionResultContent("call1", "result")]),
225new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call2", "func", null)]),
226new ChatMessage(ChatRole.Tool, [new FunctionResultContent("call2", "result")]),
241new ChatMessage(ChatRole.System, "System"),
242new ChatMessage(ChatRole.User, "First"),
243new ChatMessage(ChatRole.Assistant, "Second"),
244new ChatMessage(ChatRole.User, "Third"),
245new ChatMessage(ChatRole.Assistant, "Fourth"),
ChatReduction\SummarizingChatReducerTests.cs (51)
69new ChatMessage(ChatRole.System, "You are a helpful assistant."),
70new ChatMessage(ChatRole.User, "Hello"),
71new ChatMessage(ChatRole.Assistant, "Hi there!"),
72new ChatMessage(ChatRole.User, "How are you?"),
76Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "Summary of conversation")));
96new ChatMessage(ChatRole.User, "What's the time?"),
97new ChatMessage(ChatRole.Assistant, "Let me check"),
98new ChatMessage(ChatRole.User, "What's the weather?"),
99new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call1", "get_weather"), new TestInputRequestContent("uir1")]),
100new ChatMessage(ChatRole.Tool, [new FunctionResultContent("call1", "Sunny")]),
101new ChatMessage(ChatRole.User, [new TestInputResponseContent("uir1")]),
102new ChatMessage(ChatRole.Assistant, "It's sunny"),
108return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "Asked about time")));
141new ChatMessage(ChatRole.User, "First question"),
142new ChatMessage(ChatRole.Assistant, "First answer"),
143new ChatMessage(ChatRole.User, "Second question"),
144new ChatMessage(ChatRole.Assistant, "Second answer"),
145new ChatMessage(ChatRole.User, "Third question"),
146new ChatMessage(ChatRole.Assistant, "Third answer"),
156return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "Summary of first exchange")));
187new ChatMessage(ChatRole.User, "What's the weather in Seattle?"),
188new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call1", "get_weather", new Dictionary<string, object?> { ["location"] = "Seattle" }), new TestInputRequestContent("uir2")]),
189new ChatMessage(ChatRole.Tool, [new FunctionResultContent("call1", "Sunny, 72°F")]),
190new ChatMessage(ChatRole.User, [new TestInputResponseContent("uir2")]),
191new ChatMessage(ChatRole.Assistant, "It's sunny and 72°F in Seattle."),
192new ChatMessage(ChatRole.User, "What about New York?"),
193new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call2", "get_weather", new Dictionary<string, object?> { ["location"] = "New York" })]),
194new ChatMessage(ChatRole.Tool, [new FunctionResultContent("call2", "Rainy, 65°F")]),
195new ChatMessage(ChatRole.Assistant, "It's rainy and 65°F in New York."),
209return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "User asked about weather in Seattle and New York.")));
242messages.Add(new ChatMessage(ChatRole.Assistant, $"Message {i}"));
249return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "Summary")));
276new ChatMessage(ChatRole.User, "Message 1"),
277new ChatMessage(ChatRole.Assistant, "Response 1"),
278new ChatMessage(ChatRole.User, "Message 2"),
287return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "Summary")));
302new ChatMessage(ChatRole.System, "First system message"),
303new ChatMessage(ChatRole.User, "Hello"),
304new ChatMessage(ChatRole.System, "Second system message"),
305new ChatMessage(ChatRole.Assistant, "Hi"),
306new ChatMessage(ChatRole.User, "How are you?"),
310Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "Summary")));
330new ChatMessage(ChatRole.User, "Hi there! Can you tell me about golden retrievers?"),
331new 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."),
332new ChatMessage(ChatRole.User, "What kind of exercise do they need?"),
333new 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."),
334new ChatMessage(ChatRole.User, "Are they good with kids?"),
350return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, Summary)));
361messages.Add(new ChatMessage(ChatRole.Assistant, "Golden retrievers get along well with kids! They're able to be playful and energetic while remaining gentle."));
362messages.Add(new ChatMessage(ChatRole.User, "Do they make good lap dogs?"));
377return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, Summary)));
ChatRouting\FailoverChatClientTests.cs (45)
58? router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).ToChatResponseAsync()
59: router.GetResponseAsync([new(ChatRole.User, "hi")]);
83[new(ChatRole.User, "hi")],
86[new(ChatRole.User, "hi")],
106? router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).ToChatResponseAsync()
107: router.GetResponseAsync([new(ChatRole.User, "hi")]);
134() => router.GetResponseAsync([new(ChatRole.User, "hi")]));
165() => router.GetResponseAsync([new(ChatRole.User, "hi")]));
196() => router.GetResponseAsync([new(ChatRole.User, "hi")]));
225_ = await router.GetResponseAsync([new(ChatRole.User, "hi")], requestOptions);
257ChatResponse expected = new(new ChatMessage(ChatRole.Assistant, "ok"));
276? await router.GetStreamingResponseAsync([new(ChatRole.User, "hi")], requestOptions).ToChatResponseAsync()
277: await router.GetResponseAsync([new(ChatRole.User, "hi")], requestOptions);
303return Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "ok")));
323? await router.GetStreamingResponseAsync([new(ChatRole.User, "hi")], requestOptions).ToChatResponseAsync()
324: await router.GetResponseAsync([new(ChatRole.User, "hi")], requestOptions);
352() => router.GetResponseAsync([new(ChatRole.User, "hi")]));
367ChatResponse expected = new(new ChatMessage(ChatRole.Assistant, "ok"));
395ChatResponse response = await router.GetResponseAsync([new(ChatRole.User, "hi")]);
423_ = await router.GetResponseAsync([new(ChatRole.User, "hi")]);
432ChatResponse expected = new(new ChatMessage(ChatRole.Assistant, "ok"));
446ChatResponse response = await router.GetResponseAsync([new(ChatRole.User, "hi")]);
474() => router.GetResponseAsync([new(ChatRole.User, "hi")]));
502ChatResponse? response = await router.GetResponseAsync([new(ChatRole.User, "hi")]);
529[new(ChatRole.User, "hi")],
557[new(ChatRole.User, "hi")],
590[new(ChatRole.User, "hi")],
628() => CollectAsync(router.GetStreamingResponseAsync([new(ChatRole.User, "hi")])));
652await router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).ToChatResponseAsync();
686[new(ChatRole.User, "hi")],
730[new(ChatRole.User, "hi")],
743ChatResponse expected = new(new ChatMessage(ChatRole.Assistant, "ok"));
758ChatResponse response = await client.GetResponseAsync([new(ChatRole.User, "hi")]);
783await client.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).ToChatResponseAsync();
811await client.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).ToChatResponseAsync();
839() => CollectAsync(router.GetStreamingResponseAsync([new(ChatRole.User, "hi")])));
862await router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).ToChatResponseAsync();
885await router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).ToChatResponseAsync();
916await router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).ToChatResponseAsync();
955[new(ChatRole.User, "hi")],
1004await router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).ToChatResponseAsync();
1042await foreach (ChatResponseUpdate update in router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]))
1080await CollectAsync(router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]));
1111await CollectAsync(router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]));
1135await ConsumeOneAsync(router.GetStreamingResponseAsync([new(ChatRole.User, "hi")]));
ChatRouting\OrderedFailoverChatClientTests.cs (17)
38ChatResponse expected = new(new ChatMessage(ChatRole.Assistant, "ok"));
49ChatResponse response = await client.GetResponseAsync([new(ChatRole.User, "hi")]);
59ChatResponse expected = new(new ChatMessage(ChatRole.Assistant, "ok"));
80ChatResponse response = await client.GetResponseAsync([new(ChatRole.User, "hi")]);
101() => client.GetResponseAsync([new(ChatRole.User, "hi")]));
121() => client.GetResponseAsync([new(ChatRole.User, "hi")]));
144_ = await client.GetResponseAsync([new(ChatRole.User, "one")]);
145_ = await client.GetResponseAsync([new(ChatRole.User, "two")]);
183client.GetResponseAsync([new(ChatRole.User, index.ToString())])),
205client.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).GetAsyncEnumerator())
217ChatResponse expected = new(new ChatMessage(ChatRole.Assistant, "ok"));
226ChatResponse response = await failover.GetResponseAsync([new(ChatRole.User, "hi")]);
262[new(ChatRole.User, "hi")],
288await client.GetStreamingResponseAsync([new(ChatRole.User, "hi")]).ToChatResponseAsync();
315[new(ChatRole.User, "hi")],
354ChatResponse expected = new(new ChatMessage(ChatRole.Assistant, "ok"));
362ChatResponse response = await outer.GetResponseAsync([new(ChatRole.User, "hi")]);
ChatRouting\SemanticRoutingChatClientTests.cs (10)
97ChatResponse expected = new(new ChatMessage(ChatRole.Assistant, "code"));
105Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "writing"))),
118ChatResponse first = await router.GetResponseAsync([new(ChatRole.User, "debug this code")]);
119ChatResponse second = await router.GetResponseAsync([new(ChatRole.User, "debug this code")]);
149Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "code"))),
154Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "writing"))),
170ChatResponse response = await router.GetResponseAsync([new(ChatRole.User, "query")]);
192Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, "profiled"))),
194ChatResponse expected = new(new ChatMessage(ChatRole.Assistant, "default"));
211await router.GetResponseAsync([new(ChatRole.User, "unrelated query")]);
Microsoft.Extensions.DataIngestion (7)
Microsoft.Extensions.DataIngestion.Tests (6)
Microsoft.ML.GenAI.Core (1)
Microsoft.ML.GenAI.Core.Tests (3)
Microsoft.ML.GenAI.LLaMA.Tests (3)
Microsoft.ML.GenAI.Samples (5)
1333 references to ChatMessage
Aspire.Azure.AI.OpenAI.Tests (1)
Aspire.Dashboard (48)
Model\Assistant\Prompts\KnownChatMessages.cs (25)
17public static ChatMessage CreateSystemMessage()
46public static ChatMessage CreateInitialMessage(string promptText, string applicationName, List<ResourceViewModel> resources, DashboardOptions dashboardOptions)
70public static ChatMessage CreateFollowUpMessage(int questionCount)
81public static ChatMessage CreateRecentActivityMessage()
92public static ChatMessage CreateResourceRecentActivityMessage(ResourceViewModel resource)
105public static ChatMessage CreateAnalyzeResourceMessage(ResourceViewModel resource)
115public static ChatMessage CreateSummarizeResourcesMessage()
125public static ChatMessage CreateUnhealthyResourcesMessage()
136public static ChatMessage CreateHelpMessage()
148public static ChatMessage CreateAllConsoleLogsMessage()
158public static ChatMessage CreateResourceConsoleLogsMessage(ResourceViewModel resource)
168public static ChatMessage CreateHelpMessage()
180public static ChatMessage CreateErrorStructuredLogsMessage(List<OtlpLogEntry> errorLogs, DashboardOptions options, Func<IOtlpResource, string> getResourceName)
199public static ChatMessage CreateAnalyzeLogEntryMessage(OtlpLogEntry logEntry, DashboardOptions options, Func<IOtlpResource, string> getResourceName)
217public static ChatMessage CreateResourceStructuredLogsMessage(OtlpResource resource)
227public static ChatMessage CreateAllStructuredLogsMessage()
237public static ChatMessage CreateHelpMessage()
249public static ChatMessage CreateAllTracesPerformanceMessage()
258public static ChatMessage CreateResourceTracesPerformanceMessage(string resourceName)
267public static ChatMessage CreateAllTracesMessage()
277public static ChatMessage CreateResourceTracesMessage(OtlpResource resource)
287public static ChatMessage CreateAnalyzeTraceMessage(OtlpTrace trace, List<OtlpLogEntry> traceLogEntries, IEnumerable<IOutgoingPeerResolver> outgoingPeerResolvers, DashboardOptions options, Func<IOtlpResource, string> getResourceName)
314public static ChatMessage CreateAnalyzeSpanMessage(OtlpSpan span, List<OtlpLogEntry> traceLogEntries, IEnumerable<IOutgoingPeerResolver> outgoingPeerResolvers, DashboardOptions options, Func<IOtlpResource, string> getResourceName)
341public static ChatMessage CreateErrorTracesMessage(List<OtlpTrace> errorTraces, IEnumerable<IOutgoingPeerResolver> outgoingPeerResolvers, DashboardOptions options, Func<IOtlpResource, string> getResourceName)
359public static ChatMessage CreateHelpMessage()
Aspire.OpenAI.Tests (1)
Microsoft.AspNetCore.Components.AI (6)
Microsoft.Extensions.AI (129)
ChatCompletion\AnonymousDelegatingChatClient.cs (11)
21private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? _getResponseFunc;
29private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? _getStreamingResponseFunc;
32private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task>, CancellationToken, Task>? _sharedFunc;
51Func<IEnumerable<ChatMessage>, ChatOptions?, Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task>, CancellationToken, Task> sharedFunc)
77Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? getResponseFunc,
78Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
89IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
98IEnumerable<ChatMessage> messages, ChatOptions? options, CancellationToken cancellationToken)
128IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
ChatCompletion\CachingChatClient.cs (6)
47IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
57IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
75IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
85IEnumerable<ChatMessage> messages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
150protected abstract string GetCacheKey(IEnumerable<ChatMessage> messages, ChatOptions? options, params ReadOnlySpan<object?> additionalValues);
209protected virtual bool EnableCaching(IEnumerable<ChatMessage> messages, ChatOptions? options)
ChatCompletion\ChatClientBuilder.cs (4)
108public ChatClientBuilder Use(Func<IEnumerable<ChatMessage>, ChatOptions?, Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task>, CancellationToken, Task> sharedFunc)
143Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? getResponseFunc,
144Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
ChatCompletion\FunctionInvokingChatClient.cs (53)
278IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
289List<ChatMessage> originalMessages = [.. messages];
292List<ChatMessage>? augmentedHistory = null; // the actual history of messages sent on turns other than the first
294List<ChatMessage>? responseMessages = null; // tracked list of messages, across multiple turns, to be used for the final response
311(IList<ChatMessage>? invokedApprovedFunctionApprovalResponses, bool shouldTerminate, consecutiveErrorCount) =
438IEnumerable<ChatMessage> messages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
450List<ChatMessage> originalMessages = [.. messages];
453List<ChatMessage>? augmentedHistory = null; // the actual history of messages sent on turns other than the first
455List<ChatMessage>? responseMessages = null; // tracked list of messages, across multiple turns, to be used in fallback cases to reconstitute history
484foreach (var message in preDownstreamCallHistory)
495(IList<ChatMessage>? invokedApprovedFunctionApprovalResponses, bool shouldTerminate, consecutiveErrorCount) =
500foreach (var message in invokedApprovedFunctionApprovalResponses)
687foreach (var message in modeAndMessages.MessagesAdded)
707private static ChatResponseUpdate ConvertToolResultMessageToUpdate(ChatMessage message, string? conversationId, string? messageId) =>
746IEnumerable<ChatMessage> originalMessages,
747ref IEnumerable<ChatMessage> messages,
748[NotNull] ref List<ChatMessage>? augmentedHistory,
750List<ChatMessage> allTurnsResponseMessages,
865private static bool HasAnyFunctionApproval(List<ChatMessage> messages) =>
868private static bool MessageHasFunctionApproval(ChatMessage message) =>
882private static bool MessageContainsOnlyFunctionApprovals(ChatMessage message) =>
889IList<ChatMessage> messages, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls)
924private static void MarkServerHandledFunctionCalls(IList<ChatMessage> messages)
1162private async Task<(bool ShouldTerminate, int NewConsecutiveErrorCount, IList<ChatMessage> MessagesAdded)> ProcessFunctionCallsAsync(
1163List<ChatMessage> messages, ChatOptions? options,
1203IList<ChatMessage> addedMessages = CreateResponseMessages(results.ToArray());
1224private void UpdateConsecutiveErrorCountOrThrow(IList<ChatMessage> added, ref int consecutiveErrorCount)
1256private void ThrowIfNoFunctionResultsAdded(IList<ChatMessage>? messages)
1267protected virtual IList<ChatMessage> CreateResponseMessages(
1334private (List<ChatMessage>? preDownstreamCallHistory, List<ApprovalResultWithRequestMessage>? approvals, int approvedResultInsertIndex) ProcessFunctionApprovalResponses(
1335List<ChatMessage> originalMessages, bool hasConversationId, string? toolMessageId, string? functionCallContentFallbackMessageId)
1378ICollection<ChatMessage>? allPreDownstreamCallMessages = ConvertToFunctionCallContentMessages(
1384ChatMessage? rejectedPreDownstreamCallResultsMessage = rejectedFunctionCallResults is not null ?
1391List<ChatMessage>? preDownstreamCallHistory = null;
1426List<ChatMessage> messages)
1428Dictionary<string, (ChatMessage Message, ToolApprovalRequestContent RequestContent)>? allApprovalRequestsMessages = null;
1442var message = messages[i];
1482var newMessage = message.Clone();
1529ChatMessage? requestMessage = null;
1576private static ICollection<ChatMessage>? ConvertToFunctionCallContentMessages(
1581ChatMessage? currentMessage = null;
1582Dictionary<string, ChatMessage>? messagesById = null;
1630if (messagesById?.Values is ICollection<ChatMessage> cm)
1645/// Takes the <see cref="FunctionCallContent"/> from the <paramref name="resultWithRequestMessage"/> and wraps it in a <see cref="ChatMessage"/>
1648private static ChatMessage ConvertToFunctionCallContentMessage(ApprovalResultWithRequestMessage resultWithRequestMessage, string? fallbackMessageId)
1650ChatMessage functionCallMessage = resultWithRequestMessage.RequestMessage?.Clone() ?? new() { Role = ChatRole.Assistant };
1737private IList<ChatMessage> ReplaceFunctionCallsWithApprovalRequests(
1738IList<ChatMessage> messages,
1785var message = lastMessageIndex != messageIndex ? outputMessages[messageIndex].Clone() : outputMessages[messageIndex];
1808/// wrapped in <see cref="ChatMessage"/> objects.
1810private async Task<(IList<ChatMessage>? FunctionResultContentMessages, bool ShouldTerminate, int ConsecutiveErrorCount)> InvokeApprovedFunctionApprovalResponsesAsync(
1812List<ChatMessage> originalMessages,
1918public ChatMessage? RequestMessage { get; init; }
Microsoft.Extensions.AI.Abstractions (133)
ChatCompletion\ChatResponseExtensions.cs (17)
30public static void AddMessages(this IList<ChatMessage> list, ChatResponse response)
35if (list is List<ChatMessage> listConcrete)
41foreach (var message in response.Messages)
48/// <summary>Converts the <paramref name="updates"/> into <see cref="ChatMessage"/> instances and adds them to <paramref name="list"/>.</summary>
54/// As part of combining <paramref name="updates"/> into a series of <see cref="ChatMessage"/> instances, the
59public static void AddMessages(this IList<ChatMessage> list, IEnumerable<ChatResponseUpdate> updates)
72/// <summary>Converts the <paramref name="update"/> into a <see cref="ChatMessage"/> instance and adds it to <paramref name="list"/>.</summary>
80/// no <see cref="ChatMessage"/> will be added to the <paramref name="list"/>.
82public static void AddMessages(this IList<ChatMessage> list, ChatResponseUpdate update, Func<AIContent, bool>? filter = null)
100/// <summary>Converts the <paramref name="updates"/> into <see cref="ChatMessage"/> instances and adds them to <paramref name="list"/>.</summary>
108/// As part of combining <paramref name="updates"/> into a series of <see cref="ChatMessage"/> instances, tne
114this IList<ChatMessage> list, IAsyncEnumerable<ChatResponseUpdate> updates, CancellationToken cancellationToken = default)
122IList<ChatMessage> list, IAsyncEnumerable<ChatResponseUpdate> updates, CancellationToken cancellationToken) =>
132/// <see cref="ChatMessage"/> instances. This includes using <see cref="ChatResponseUpdate.MessageId"/> to determine
160/// <see cref="ChatMessage"/> instances. This includes using <see cref="ChatResponseUpdate.MessageId"/> to determine
545var lastMessage = response.Messages[response.Messages.Count - 1];
553ChatMessage message;
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.ChatMessage.g.cs (38)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage>? _ChatMessage;
21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> ChatMessage
24get => _ChatMessage ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.ChatMessage));
27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> Create_ChatMessage(global::System.Text.Json.JsonSerializerOptions options)
29if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.ChatMessage>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> jsonTypeInfo))
31var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.ChatMessage>
37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty<global::System.Type>(), modifiers: null),
41jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.ChatMessage>(options, objectInfo);
58DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
60Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AuthorName,
61Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AuthorName = value!,
68AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("AuthorName", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
78DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
80Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).CreatedAt,
81Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).CreatedAt = value!,
88AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("CreatedAt", InstanceMemberBindingFlags, null, typeof(global::System.DateTimeOffset?), global::System.Array.Empty<global::System.Type>(), null),
98DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
100Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Role,
101Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Role = value!,
108AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Role", InstanceMemberBindingFlags, null, typeof(global::Microsoft.Extensions.AI.ChatRole), global::System.Array.Empty<global::System.Type>(), null),
118DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
128AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Text", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
139DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
141Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Contents,
142Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Contents = value!,
149AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Contents", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.AIContent>), global::System.Array.Empty<global::System.Type>(), null),
160DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
162Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).MessageId,
163Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).MessageId = value!,
170AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("MessageId", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
180DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
190AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("RawRepresentation", InstanceMemberBindingFlags, null, typeof(object), global::System.Array.Empty<global::System.Type>(), null),
200DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
202Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AdditionalProperties,
203Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AdditionalProperties = value!,
210AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("AdditionalProperties", InstanceMemberBindingFlags, null, typeof(global::Microsoft.Extensions.AI.AdditionalPropertiesDictionary), global::System.Array.Empty<global::System.Type>(), null),
Microsoft.Extensions.AI.Abstractions.Tests (120)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestJsonSerializerContext.ChatMessage.g.cs (38)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage>? _ChatMessage;
19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> ChatMessage
22get => _ChatMessage ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.ChatMessage));
25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> Create_ChatMessage(global::System.Text.Json.JsonSerializerOptions options)
27if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.ChatMessage>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> jsonTypeInfo))
29var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.ChatMessage>
35ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty<global::System.Type>(), modifiers: null),
39jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.ChatMessage>(options, objectInfo);
56DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
58Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AuthorName,
59Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AuthorName = value!,
66AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("AuthorName", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
76DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
78Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).CreatedAt,
79Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).CreatedAt = value!,
86AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("CreatedAt", InstanceMemberBindingFlags, null, typeof(global::System.DateTimeOffset?), global::System.Array.Empty<global::System.Type>(), null),
96DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
98Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Role,
99Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Role = value!,
106AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Role", InstanceMemberBindingFlags, null, typeof(global::Microsoft.Extensions.AI.ChatRole), global::System.Array.Empty<global::System.Type>(), null),
116DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
126AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Text", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
137DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
139Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Contents,
140Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Contents = value!,
147AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Contents", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.AIContent>), global::System.Array.Empty<global::System.Type>(), null),
159DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
161Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).MessageId,
162Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).MessageId = value!,
169AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("MessageId", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
179DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
189AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("RawRepresentation", InstanceMemberBindingFlags, null, typeof(object), global::System.Array.Empty<global::System.Type>(), null),
199DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
201Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AdditionalProperties,
202Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AdditionalProperties = value!,
209AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("AdditionalProperties", InstanceMemberBindingFlags, null, typeof(global::Microsoft.Extensions.AI.AdditionalPropertiesDictionary), global::System.Array.Empty<global::System.Type>(), null),
TestChatClient.cs (4)
20public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task<ChatResponse>>? GetResponseAsyncCallback { get; set; }
22public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; }
29public Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
32public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.Extensions.AI.Evaluation (49)
Microsoft.Extensions.AI.Evaluation.Integration.Tests (41)
Microsoft.Extensions.AI.Evaluation.NLP (3)
Microsoft.Extensions.AI.Evaluation.Quality (64)
Microsoft.Extensions.AI.Evaluation.Reporting (73)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.ChatMessage.g.cs (38)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage>? _ChatMessage;
21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> ChatMessage
24get => _ChatMessage ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.ChatMessage));
27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> Create_ChatMessage(global::System.Text.Json.JsonSerializerOptions options)
29if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.ChatMessage>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> jsonTypeInfo))
31var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.ChatMessage>
37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty<global::System.Type>(), modifiers: null),
41jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.ChatMessage>(options, objectInfo);
58DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
60Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AuthorName,
61Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AuthorName = value!,
68AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("AuthorName", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
78DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
80Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).CreatedAt,
81Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).CreatedAt = value!,
88AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("CreatedAt", InstanceMemberBindingFlags, null, typeof(global::System.DateTimeOffset?), global::System.Array.Empty<global::System.Type>(), null),
98DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
100Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Role,
101Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Role = value!,
108AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Role", InstanceMemberBindingFlags, null, typeof(global::Microsoft.Extensions.AI.ChatRole), global::System.Array.Empty<global::System.Type>(), null),
118DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
128AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Text", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
139DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
141Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Contents,
142Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Contents = value!,
149AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Contents", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.AIContent>), global::System.Array.Empty<global::System.Type>(), null),
161DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
163Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).MessageId,
164Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).MessageId = value!,
171AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("MessageId", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
181DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
191AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("RawRepresentation", InstanceMemberBindingFlags, null, typeof(object), global::System.Array.Empty<global::System.Type>(), null),
201DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
203Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AdditionalProperties,
204Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AdditionalProperties = value!,
211AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("AdditionalProperties", InstanceMemberBindingFlags, null, typeof(global::Microsoft.Extensions.AI.AdditionalPropertiesDictionary), global::System.Array.Empty<global::System.Type>(), null),
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.ScenarioRunResult.g.cs (7)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Evaluation.Reporting.ScenarioRunResult((string)args[0], (string)args[1], (string)args[2], (global::System.DateTime)args[3], (global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>)args[4], (global::Microsoft.Extensions.AI.ChatResponse)args[5], (global::Microsoft.Extensions.AI.Evaluation.EvaluationResult)args[6], (global::Microsoft.Extensions.AI.Evaluation.Reporting.ChatDetails)args[7], (global::System.Collections.Generic.IList<string>)args[8], (int?)args[9]),
37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Evaluation.Reporting.ScenarioRunResult).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(string), typeof(string), typeof(string), typeof(global::System.DateTime), typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>), typeof(global::Microsoft.Extensions.AI.ChatResponse), typeof(global::Microsoft.Extensions.AI.Evaluation.EvaluationResult), typeof(global::Microsoft.Extensions.AI.Evaluation.Reporting.ChatDetails), typeof(global::System.Collections.Generic.IList<string>), typeof(int?)}, modifiers: null),
139var info4 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>>
154AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Evaluation.Reporting.ScenarioRunResult).GetProperty("Messages", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>), global::System.Array.Empty<global::System.Type>(), null),
157properties[4] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>>(options, info4);
296global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage> __value_Messages = ((global::Microsoft.Extensions.AI.Evaluation.Reporting.ScenarioRunResult)value).Messages;
381ParameterType = typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>),
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (61)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.ChatMessage.g.cs (38)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage>? _ChatMessage;
21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> ChatMessage
24get => _ChatMessage ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.ChatMessage));
27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> Create_ChatMessage(global::System.Text.Json.JsonSerializerOptions options)
29if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.ChatMessage>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> jsonTypeInfo))
31var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.ChatMessage>
37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty<global::System.Type>(), modifiers: null),
41jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.ChatMessage>(options, objectInfo);
58DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
60Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AuthorName,
61Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AuthorName = value!,
68AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("AuthorName", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
78DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
80Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).CreatedAt,
81Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).CreatedAt = value!,
88AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("CreatedAt", InstanceMemberBindingFlags, null, typeof(global::System.DateTimeOffset?), global::System.Array.Empty<global::System.Type>(), null),
98DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
100Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Role,
101Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Role = value!,
108AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Role", InstanceMemberBindingFlags, null, typeof(global::Microsoft.Extensions.AI.ChatRole), global::System.Array.Empty<global::System.Type>(), null),
118DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
128AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Text", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
139DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
141Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Contents,
142Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Contents = value!,
149AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Contents", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.AIContent>), global::System.Array.Empty<global::System.Type>(), null),
161DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
163Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).MessageId,
164Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).MessageId = value!,
171AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("MessageId", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
181DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
191AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("RawRepresentation", InstanceMemberBindingFlags, null, typeof(object), global::System.Array.Empty<global::System.Type>(), null),
201DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
203Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AdditionalProperties,
204Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AdditionalProperties = value!,
211AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("AdditionalProperties", InstanceMemberBindingFlags, null, typeof(global::Microsoft.Extensions.AI.AdditionalPropertiesDictionary), global::System.Array.Empty<global::System.Type>(), null),
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.ScenarioRunResult.g.cs (7)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Evaluation.Reporting.ScenarioRunResult((string)args[0], (string)args[1], (string)args[2], (global::System.DateTime)args[3], (global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>)args[4], (global::Microsoft.Extensions.AI.ChatResponse)args[5], (global::Microsoft.Extensions.AI.Evaluation.EvaluationResult)args[6], (global::Microsoft.Extensions.AI.Evaluation.Reporting.ChatDetails)args[7], (global::System.Collections.Generic.IList<string>)args[8], (int?)args[9]),
37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Evaluation.Reporting.ScenarioRunResult).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(string), typeof(string), typeof(string), typeof(global::System.DateTime), typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>), typeof(global::Microsoft.Extensions.AI.ChatResponse), typeof(global::Microsoft.Extensions.AI.Evaluation.EvaluationResult), typeof(global::Microsoft.Extensions.AI.Evaluation.Reporting.ChatDetails), typeof(global::System.Collections.Generic.IList<string>), typeof(int?)}, modifiers: null),
139var info4 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>>
154AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Evaluation.Reporting.ScenarioRunResult).GetProperty("Messages", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>), global::System.Array.Empty<global::System.Type>(), null),
157properties[4] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>>(options, info4);
296global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage> __value_Messages = ((global::Microsoft.Extensions.AI.Evaluation.Reporting.ScenarioRunResult)value).Messages;
381ParameterType = typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.ChatMessage>),
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (4)
Microsoft.Extensions.AI.Evaluation.Safety (36)
ContentSafetyServicePayloadUtilities.cs (22)
17IEnumerable<ChatMessage> conversation,
79IEnumerable<ChatMessage> conversation,
90List<Dictionary<string, ChatMessage>> turns;
110if (turn.TryGetValue("question", out ChatMessage? question))
115if (turn.TryGetValue("answer", out ChatMessage? answer))
165IEnumerable<ChatMessage> conversation,
182List<Dictionary<string, ChatMessage>> turns;
202if (turn.TryGetValue("question", out ChatMessage? question))
207if (turn.TryGetValue("answer", out ChatMessage? answer))
246IEnumerable<ChatMessage> conversation,
260List<Dictionary<string, ChatMessage>> turns;
274IEnumerable<JsonObject> GetMessages(Dictionary<string, ChatMessage> turn, int turnIndex)
278if (turn.TryGetValue("question", out ChatMessage? question))
289if (turn.TryGetValue("answer", out ChatMessage? answer))
314IEnumerable<JsonObject> GetContents(ChatMessage message)
384(List<Dictionary<string, ChatMessage>> turns,
388IEnumerable<ChatMessage> conversation,
395List<Dictionary<string, ChatMessage>> turns = [];
396Dictionary<string, ChatMessage> currentTurn = [];
416foreach (ChatMessage message in conversation)
450void ValidateContents(ChatMessage message)
478foreach (var message in turn.Values)
Microsoft.Extensions.AI.Evaluation.Tests (3)
Microsoft.Extensions.AI.Integration.Tests (44)
ChatClientIntegrationTests.cs (21)
100IList<ChatMessage> chatHistory =
160List<ChatMessage> history = [new(ChatRole.User, "Explain in 100 words how AI works")];
229List<ChatMessage> messages =
296List<ChatMessage> messages =
328List<ChatMessage> messages =
358List<ChatMessage> messages =
640var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000");
656var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000");
681var message = new ChatMessage(ChatRole.User, "Pick a random number, uniformly distributed between 1 and 1000000");
733var message = new ChatMessage(ChatRole.User, "What is the temperature?");
772var message = new ChatMessage(ChatRole.User, "What is the temperature?");
814var message = new ChatMessage(ChatRole.User, "What is the temperature?");
1135List<ChatMessage> messages =
1177List<ChatMessage> messages =
1238List<ChatMessage> messages =
1272List<ChatMessage> messages =
1318List<ChatMessage> messages =
1337var summaryMessage = chatClient.LastSummarizedConversation[0];
1359public IReadOnlyList<ChatMessage>? LastSummarizedConversation { get; private set; }
1383public Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
1386public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
parent\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (4)
20public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task<ChatResponse>>? GetResponseAsyncCallback { get; set; }
22public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; }
29public Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
32public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (1)
Microsoft.Extensions.AI.OpenAI (27)
Microsoft.Extensions.AI.OpenAI.Tests (75)
Microsoft.Extensions.AI.Tests (380)
ChatCompletion\DistributedCachingChatClientTest.cs (9)
123private sealed class CustomCachingChatClient(IChatClient innerClient, IDistributedCache storage, Func<IEnumerable<ChatMessage>, ChatOptions?, bool> enableCaching) :
126protected override bool EnableCaching(IEnumerable<ChatMessage> messages, ChatOptions? options) => enableCaching(messages, options);
185var input = new ChatMessage(ChatRole.User, "abc");
224var input = new ChatMessage(ChatRole.User, "abc");
495var input = new ChatMessage(ChatRole.User, "abc");
533var input = new ChatMessage(ChatRole.User, "abc");
803ChatMessage expectedMessage = expected.Messages.Last();
804ChatMessage actualMessage = actual.Messages.Last();
878protected override string GetCacheKey(IEnumerable<ChatMessage> messages, ChatOptions? options, params ReadOnlySpan<object?> additionalValues)
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (152)
34List<ChatMessage> input =
39List<ChatMessage> downstreamClientOutput =
44List<ChatMessage> expectedOutput =
70List<ChatMessage> input =
75List<ChatMessage> downstreamClientOutput =
80List<ChatMessage> expectedOutput =
117List<ChatMessage> input =
122List<ChatMessage> downstreamClientOutput =
129List<ChatMessage> expectedOutput =
167List<ChatMessage> input =
172List<ChatMessage> downstreamClientOutput =
180List<ChatMessage> expectedOutput =
212List<ChatMessage> input =
217List<ChatMessage> downstreamClientOutput =
225List<ChatMessage> expectedOutput =
254List<ChatMessage> input =
269List<ChatMessage> expectedDownstreamClientInput =
276List<ChatMessage> downstreamClientOutput =
281List<ChatMessage> output =
306List<ChatMessage> input =
322List<ChatMessage> expectedDownstreamClientInput =
329List<ChatMessage> downstreamClientOutput =
334List<ChatMessage> output =
358List<ChatMessage> input =
379List<ChatMessage> expectedDownstreamClientInput =
387List<ChatMessage> downstreamClientOutput =
392List<ChatMessage> output =
417List<ChatMessage> input =
432List<ChatMessage> expectedDownstreamClientInput =
443List<ChatMessage> downstreamClientOutput =
448List<ChatMessage> output =
476List<ChatMessage> input =
491List<ChatMessage> expectedDownstreamClientInput =
499List<ChatMessage> downstreamClientOutput =
504List<ChatMessage> nonStreamingOutput =
512List<ChatMessage> streamingOutput =
540List<ChatMessage> input =
561List<ChatMessage> expectedDownstreamClientInput =
572List<ChatMessage> downstreamClientOutput =
577List<ChatMessage> output =
606List<ChatMessage> input =
623List<ChatMessage> expectedDownstreamClientInput =
640List<ChatMessage> downstreamClientOutput =
645List<ChatMessage> nonStreamingOutput =
662List<ChatMessage> streamingOutput =
698List<ChatMessage> input =
714List<ChatMessage> expectedDownstreamClientInput =
724List<ChatMessage> downstreamClientOutput =
729List<ChatMessage> output =
756List<ChatMessage> input =
771List<ChatMessage> expectedDownstreamClientInput =
778List<ChatMessage> downstreamClientOutput =
783List<ChatMessage> output =
810List<ChatMessage> input =
835List<ChatMessage> expectedDownstreamClientInput =
844List<ChatMessage> downstreamClientOutput =
849List<ChatMessage> output =
889List<ChatMessage> input =
961List<ChatMessage> input =
1026List<ChatMessage> input =
1031Func<Queue<List<ChatMessage>>> expectedDownstreamClientInput = () => new Queue<List<ChatMessage>>(
1033new List<ChatMessage>
1037new List<ChatMessage>
1045Func<Queue<List<ChatMessage>>> downstreamClientOutput = () => new Queue<List<ChatMessage>>(
1047new List<ChatMessage>
1051new List<ChatMessage>
1057List<ChatMessage> output =
1081List<ChatMessage> input =
1111List<ChatMessage> input =
1121List<ChatMessage> expectedDownstreamClientInput =
1128List<ChatMessage> downstreamClientOutput =
1133List<ChatMessage> output =
1158List<ChatMessage> input =
1167List<ChatMessage> expectedDownstreamClientInput =
1172List<ChatMessage> downstreamClientOutput =
1177List<ChatMessage> output =
1202List<ChatMessage> input =
1215List<ChatMessage> expectedDownstreamClientInput =
1221List<ChatMessage> downstreamClientOutput =
1226List<ChatMessage> output =
1252List<ChatMessage> input =
1263List<ChatMessage> expectedDownstreamClientInput =
1269List<ChatMessage> downstreamClientOutput =
1274List<ChatMessage> output =
1297List<ChatMessage> input =
1315List<ChatMessage> expectedDownstreamClientInput =
1323List<ChatMessage> downstreamClientOutput =
1328List<ChatMessage> output =
1352List<ChatMessage> input =
1366List<ChatMessage> expectedDownstreamClientInput =
1374List<ChatMessage> downstreamClientOutput =
1379List<ChatMessage> output =
1410List<ChatMessage> input =
1423List<ChatMessage> expectedOutput =
1467List<ChatMessage> input = [new ChatMessage(ChatRole.User, "hello")];
1475IEnumerable<ChatMessage> contents, ChatOptions? actualOptions, [EnumeratorCancellation] CancellationToken actualCancellationToken)
1496var updates = service.GetStreamingResponseAsync(new EnumeratedOnceEnumerable<ChatMessage>(input), options, cts.Token);
1543List<ChatMessage> input = [new ChatMessage(ChatRole.User, "hello")];
1551IEnumerable<ChatMessage> contents, ChatOptions? actualOptions, [EnumeratorCancellation] CancellationToken actualCancellationToken)
1577var updates = service.GetStreamingResponseAsync(new EnumeratedOnceEnumerable<ChatMessage>(input), options, cts.Token);
1641List<ChatMessage> input = [new ChatMessage(ChatRole.User, "hello")];
1645List<ChatMessage> downstreamClientOutput =
1651List<ChatMessage> expectedOutput =
1683List<ChatMessage> input =
1696List<ChatMessage> downstreamClientOutput =
1702List<ChatMessage> expectedOutput =
1734List<ChatMessage> input =
1739List<ChatMessage> downstreamClientOutput =
1748List<ChatMessage> expectedOutput =
1777List<ChatMessage> input =
1792List<ChatMessage> expectedDownstreamClientInput =
1813List<ChatMessage> downstreamClientOutput =
1821List<ChatMessage> output =
1861List<ChatMessage> input =
1876List<ChatMessage> expectedDownstreamClientInput = [
1898List<ChatMessage> downstreamClientOutput =
1908List<ChatMessage> output = [
1931private static Task<List<ChatMessage>> InvokeAndAssertAsync(
1933List<ChatMessage> input,
1934List<ChatMessage> downstreamClientOutput,
1935List<ChatMessage> expectedOutput,
1936List<ChatMessage>? expectedDownstreamClientInput = null,
1942new Queue<List<ChatMessage>>(new[] { downstreamClientOutput }),
1944expectedDownstreamClientInput is null ? null : new Queue<List<ChatMessage>>(new[] { expectedDownstreamClientInput }),
1948private static async Task<List<ChatMessage>> InvokeAndAssertMultiRoundAsync(
1950List<ChatMessage> input,
1951Queue<List<ChatMessage>> downstreamClientOutput,
1952List<ChatMessage> expectedOutput,
1953Queue<List<ChatMessage>>? expectedDownstreamClientInput = null,
1987var result = await service.GetResponseAsync(new EnumeratedOnceEnumerable<ChatMessage>(CloneInput(input)), options, cts.Token);
1990var actualOutput = result.Messages as List<ChatMessage> ?? result.Messages.ToList();
2019private static Task<List<ChatMessage>> InvokeAndAssertStreamingAsync(
2021List<ChatMessage> input,
2022List<ChatMessage> downstreamClientOutput,
2023List<ChatMessage> expectedOutput,
2024List<ChatMessage>? expectedDownstreamClientInput = null,
2030new Queue<List<ChatMessage>>(new[] { downstreamClientOutput }),
2032expectedDownstreamClientInput is null ? null : new Queue<List<ChatMessage>>(new[] { expectedDownstreamClientInput }),
2036private static async Task<List<ChatMessage>> InvokeAndAssertStreamingMultiRoundAsync(
2038List<ChatMessage> input,
2039Queue<List<ChatMessage>> downstreamClientOutput,
2040List<ChatMessage> expectedOutput,
2041Queue<List<ChatMessage>>? expectedDownstreamClientInput = null,
2069var result = await service.GetStreamingResponseAsync(new EnumeratedOnceEnumerable<ChatMessage>(CloneInput(input)), options, cts.Token).ToChatResponseAsync();
2072var actualOutput = result.Messages as List<ChatMessage> ?? result.Messages.ToList();
2089private static List<ChatMessage> CloneInput(List<ChatMessage> input) =>
2125IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
2132IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
2138private static void NormalizeApprovalFlags(IEnumerable<ChatMessage> messages)
ChatCompletion\FunctionInvokingChatClientTests.cs (98)
91List<ChatMessage> plan =
125List<ChatMessage> plan =
158List<ChatMessage> plan =
189List<ChatMessage> plan =
249List<ChatMessage> plan =
293List<ChatMessage> plan =
327List<ChatMessage> plan =
376var toolMessage = msgs.FirstOrDefault(m => m.Role == ChatRole.Tool);
389var toolMessage = msgs.FirstOrDefault(m => m.Role == ChatRole.Tool);
414var messages = new List<ChatMessage>
430var toolMessage = response.Messages.First(m => m.Role == ChatRole.Tool);
457var toolMessage = msgs.FirstOrDefault(m => m.Role == ChatRole.Tool);
470var toolMessage = msgs.FirstOrDefault(m => m.Role == ChatRole.Tool);
493var messages = new List<ChatMessage>
510var toolMessage = response.Messages.First(m => m.Role == ChatRole.Tool);
538var toolMessage = msgs.FirstOrDefault(m => m.Role == ChatRole.Tool);
551var toolMessage = msgs.FirstOrDefault(m => m.Role == ChatRole.Tool);
577var messages = new List<ChatMessage>
594var toolMessage = response.Messages.First(m => m.Role == ChatRole.Tool);
634List<ChatMessage> plan =
668var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId{capturedOptions.Count}", "Func1")]);
712var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId{capturedOptions.Count}", "Func1")]);
759var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]);
764var message = new ChatMessage(ChatRole.Assistant, "Done");
804var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]);
856List<ChatMessage> plan =
934List<ChatMessage> plan =
951private static IEnumerable<ChatMessage> CreateFunctionCallIterationPlan(ref int callIndex, params bool[] shouldThrow)
953var assistantMessage = new ChatMessage(ChatRole.Assistant, []);
954var toolMessage = new ChatMessage(ChatRole.Tool, []);
981List<ChatMessage> plan =
998static void Validate(List<ChatMessage> finalChat)
1018List<ChatMessage> plan =
1040List<ChatMessage> plan =
1097List<ChatMessage> plan =
1175var messages = new List<ChatMessage>
1233var messages = new List<ChatMessage>
1244ChatMessage message = chatContents.Count() is 1 or 3 ?
1291List<ChatMessage> planBeforeTermination =
1301List<ChatMessage> plan =
1316async Task InvokeAsync(Func<Task<List<ChatMessage>>> work)
1360var existingSearchResult = chatContents.SingleOrDefault(m => m.Role == ChatRole.Tool);
1369var message = new ChatMessage(ChatRole.Assistant, resultContents);
1377List<ChatMessage> messages = [new(ChatRole.User, "hello")];
1383var lastMessage = messages.Last();
1404Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, ChatResponse> callback =
1447List<ChatMessage> plan =
1476List<ChatMessage> plan =
1529List<ChatMessage> planForContinue =
1548List<ChatMessage> fullPlanWithUnknown =
1577List<ChatMessage> fullPlan =
1585List<ChatMessage> expected = fullPlan.Take(2).ToList();
1606List<ChatMessage> fullPlan =
1617List<ChatMessage> expected = fullPlan.Take(2).ToList();
1640List<ChatMessage> messages = [];
1679List<ChatMessage> plan =
1740ChatMessage message = callCount == 1
1790List<ChatMessage> plan =
1832List<ChatMessage> plan =
1882List<ChatMessage> plan =
1954List<ChatMessage> plan =
2003List<ChatMessage> plan =
2014var functionCallMessage = chat.First(m => m.Contents.Any(c => c is FunctionCallContent));
2042var message = new ChatMessage(ChatRole.Assistant, [alreadyProcessedFunctionCall]);
2048var message = new ChatMessage(ChatRole.Assistant, [alreadyProcessedFunctionCall]);
2097var message = new ChatMessage(ChatRole.Assistant, [needsProcessing, alreadyProcessed]);
2103var message = new ChatMessage(ChatRole.Assistant, "done");
2112var message = new ChatMessage(ChatRole.Assistant, [needsProcessing, alreadyProcessed]);
2118var message = new ChatMessage(ChatRole.Assistant, "done");
2198private static async Task<List<ChatMessage>> InvokeAndAssertAsync(
2200List<ChatMessage> plan,
2201List<ChatMessage>? expected = null,
2210List<ChatMessage> chat = [plan[0]];
2224var message = new ChatMessage(ChatRole.Assistant, CloneContents(plan[contents.Count()].Contents))
2234var result = await service.GetResponseAsync(new EnumeratedOnceEnumerable<ChatMessage>(chat), options, cts.Token);
2268private static async Task<List<ChatMessage>> InvokeAndAssertStreamingAsync(
2270List<ChatMessage> plan,
2271List<ChatMessage>? expected = null,
2280List<ChatMessage> chat = [plan[0]];
2288ChatMessage message = new(ChatRole.Assistant, CloneContents(plan[contents.Count()].Contents))
2298var result = await service.GetStreamingResponseAsync(new EnumeratedOnceEnumerable<ChatMessage>(chat), options, cts.Token).ToChatResponseAsync();
2408ChatMessage message;
2502ChatMessage message;
2607ChatMessage message;
2708ChatMessage message;
2809ChatMessage message;
2901ChatMessage message;
2987ChatMessage message;
3088ChatMessage message;
3194ChatMessage message;
3255List<ChatMessage> plan =
3285List<ChatMessage> plan =
3293List<ChatMessage> expected = plan.Take(2).ToList();
3321List<ChatMessage> plan =
3350List<ChatMessage> plan =
3357List<ChatMessage> expected =
3393var messages = new List<ChatMessage>
3430var messages = new List<ChatMessage>
ChatCompletion\OpenTelemetryChatClientTests.cs (10)
67IEnumerable<ChatMessage> messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken)
112List<ChatMessage> messages =
419IEnumerable<ChatMessage> messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken)
440List<ChatMessage> messages =
601List<ChatMessage> messages =
673IEnumerable<ChatMessage> messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken)
703List<ChatMessage> messages =
841List<ChatMessage> messages =
914IEnumerable<ChatMessage> messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken)
1101IEnumerable<ChatMessage> messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestJsonSerializerContext.ChatMessage.g.cs (38)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage>? _ChatMessage;
19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> ChatMessage
22get => _ChatMessage ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.ChatMessage));
25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> Create_ChatMessage(global::System.Text.Json.JsonSerializerOptions options)
27if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.ChatMessage>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.ChatMessage> jsonTypeInfo))
29var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.ChatMessage>
35ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty<global::System.Type>(), modifiers: null),
39jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.ChatMessage>(options, objectInfo);
56DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
58Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AuthorName,
59Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AuthorName = value!,
66AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("AuthorName", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
76DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
78Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).CreatedAt,
79Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).CreatedAt = value!,
86AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("CreatedAt", InstanceMemberBindingFlags, null, typeof(global::System.DateTimeOffset?), global::System.Array.Empty<global::System.Type>(), null),
96DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
98Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Role,
99Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Role = value!,
106AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Role", InstanceMemberBindingFlags, null, typeof(global::Microsoft.Extensions.AI.ChatRole), global::System.Array.Empty<global::System.Type>(), null),
116DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
126AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Text", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
137DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
139Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Contents,
140Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).Contents = value!,
147AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("Contents", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.IList<global::Microsoft.Extensions.AI.AIContent>), global::System.Array.Empty<global::System.Type>(), null),
159DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
161Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).MessageId,
162Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).MessageId = value!,
169AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("MessageId", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
179DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
189AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("RawRepresentation", InstanceMemberBindingFlags, null, typeof(object), global::System.Array.Empty<global::System.Type>(), null),
199DeclaringType = typeof(global::Microsoft.Extensions.AI.ChatMessage),
201Getter = static obj => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AdditionalProperties,
202Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.ChatMessage)obj).AdditionalProperties = value!,
209AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatMessage).GetProperty("AdditionalProperties", InstanceMemberBindingFlags, null, typeof(global::Microsoft.Extensions.AI.AdditionalPropertiesDictionary), global::System.Array.Empty<global::System.Type>(), null),
parent\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (4)
20public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task<ChatResponse>>? GetResponseAsyncCallback { get; set; }
22public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; }
29public Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
32public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.Extensions.DataIngestion (8)
Microsoft.Extensions.DataIngestion.Tests (4)
parent\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (4)
20public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task<ChatResponse>>? GetResponseAsyncCallback { get; set; }
22public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; }
29public Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
32public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.ML.GenAI.Core (7)
Microsoft.ML.GenAI.Core.Tests (3)
Microsoft.ML.GenAI.LLaMA (4)
Microsoft.ML.GenAI.Phi (4)
Microsoft.ML.GenAI.Samples (4)