diff --git a/dotnet/samples/Concepts/Agents/ComplexChat_NestedShopper.cs b/dotnet/samples/Concepts/Agents/ComplexChat_NestedShopper.cs index 0802980422cd..aae984906ba3 100644 --- a/dotnet/samples/Concepts/Agents/ComplexChat_NestedShopper.cs +++ b/dotnet/samples/Concepts/Agents/ComplexChat_NestedShopper.cs @@ -154,7 +154,7 @@ public async Task NestedChatWithAggregatorAgentAsync() Console.WriteLine(">>>> AGGREGATED CHAT"); Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - await foreach (var content in chat.GetChatMessagesAsync(personalShopperAgent).Reverse()) + await foreach (ChatMessageContent content in chat.GetChatMessagesAsync(personalShopperAgent).Reverse()) { Console.WriteLine($">>>> {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); } @@ -165,7 +165,7 @@ async Task InvokeChatAsync(string input) Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var content in chat.InvokeAsync(personalShopperAgent)) + await foreach (ChatMessageContent content in chat.InvokeAsync(personalShopperAgent)) { Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); } diff --git a/dotnet/samples/Concepts/Agents/MixedChat_Agents.cs b/dotnet/samples/Concepts/Agents/MixedChat_Agents.cs index 68052ef99cf2..d3a894dd6c8e 100644 --- a/dotnet/samples/Concepts/Agents/MixedChat_Agents.cs +++ b/dotnet/samples/Concepts/Agents/MixedChat_Agents.cs @@ -56,8 +56,8 @@ await OpenAIAssistantAgent.CreateAsync( }); // Create a chat for agent interaction. - var chat = - new AgentGroupChat(agentWriter, agentReviewer) + AgentGroupChat chat = + new(agentWriter, agentReviewer) { ExecutionSettings = new() @@ -80,7 +80,7 @@ await OpenAIAssistantAgent.CreateAsync( chat.AddChatMessage(new ChatMessageContent(AuthorRole.User, input)); Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var content in chat.InvokeAsync()) + await foreach (ChatMessageContent content in chat.InvokeAsync()) { Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); } diff --git a/dotnet/samples/Concepts/Agents/OpenAIAssistant_ChartMaker.cs b/dotnet/samples/Concepts/Agents/OpenAIAssistant_ChartMaker.cs index 5617784b780c..ef5ba80154fa 100644 --- a/dotnet/samples/Concepts/Agents/OpenAIAssistant_ChartMaker.cs +++ b/dotnet/samples/Concepts/Agents/OpenAIAssistant_ChartMaker.cs @@ -37,7 +37,7 @@ await OpenAIAssistantAgent.CreateAsync( }); // Create a chat for agent interaction. - var chat = new AgentGroupChat(); + AgentGroupChat chat = new(); // Respond to user input try @@ -68,14 +68,14 @@ async Task InvokeAgentAsync(string input) Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var message in chat.InvokeAsync(agent)) + await foreach (ChatMessageContent message in chat.InvokeAsync(agent)) { if (!string.IsNullOrWhiteSpace(message.Content)) { Console.WriteLine($"# {message.Role} - {message.AuthorName ?? "*"}: '{message.Content}'"); } - foreach (var fileReference in message.Items.OfType()) + foreach (FileReferenceContent fileReference in message.Items.OfType()) { Console.WriteLine($"# {message.Role} - {message.AuthorName ?? "*"}: @{fileReference.FileId}"); } diff --git a/dotnet/samples/Concepts/Agents/OpenAIAssistant_CodeInterpreter.cs b/dotnet/samples/Concepts/Agents/OpenAIAssistant_CodeInterpreter.cs index 636f70636126..75b237489025 100644 --- a/dotnet/samples/Concepts/Agents/OpenAIAssistant_CodeInterpreter.cs +++ b/dotnet/samples/Concepts/Agents/OpenAIAssistant_CodeInterpreter.cs @@ -28,7 +28,7 @@ await OpenAIAssistantAgent.CreateAsync( }); // Create a chat for agent interaction. - var chat = new AgentGroupChat(); + AgentGroupChat chat = new(); // Respond to user input try diff --git a/dotnet/samples/Concepts/Agents/OpenAIAssistant_FileManipulation.cs b/dotnet/samples/Concepts/Agents/OpenAIAssistant_FileManipulation.cs index dbe9d17ba90a..8e64006ee9d3 100644 --- a/dotnet/samples/Concepts/Agents/OpenAIAssistant_FileManipulation.cs +++ b/dotnet/samples/Concepts/Agents/OpenAIAssistant_FileManipulation.cs @@ -44,7 +44,7 @@ await OpenAIAssistantAgent.CreateAsync( }); // Create a chat for agent interaction. - var chat = new AgentGroupChat(); + AgentGroupChat chat = new(); // Respond to user input try @@ -66,11 +66,11 @@ async Task InvokeAgentAsync(string input) Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var content in chat.InvokeAsync(agent)) + await foreach (ChatMessageContent content in chat.InvokeAsync(agent)) { Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); - foreach (var annotation in content.Items.OfType()) + foreach (AnnotationContent annotation in content.Items.OfType()) { Console.WriteLine($"\n* '{annotation.Quote}' => {annotation.FileId}"); BinaryContent fileContent = await fileService.GetFileContentAsync(annotation.FileId!); diff --git a/dotnet/samples/Concepts/Agents/OpenAIAssistant_Retrieval.cs b/dotnet/samples/Concepts/Agents/OpenAIAssistant_Retrieval.cs index 9c7c9bb46f43..6f30b6974ff7 100644 --- a/dotnet/samples/Concepts/Agents/OpenAIAssistant_Retrieval.cs +++ b/dotnet/samples/Concepts/Agents/OpenAIAssistant_Retrieval.cs @@ -40,7 +40,7 @@ await OpenAIAssistantAgent.CreateAsync( }); // Create a chat for agent interaction. - var chat = new AgentGroupChat(); + AgentGroupChat chat = new(); // Respond to user input try @@ -61,7 +61,7 @@ async Task InvokeAgentAsync(string input) Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var content in chat.InvokeAsync(agent)) + await foreach (ChatMessageContent content in chat.InvokeAsync(agent)) { Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); } diff --git a/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs b/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs index ddab79f032b0..d7d4a0471b01 100644 --- a/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs +++ b/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs @@ -26,7 +26,7 @@ public async Task UseSingleChatCompletionAgentAsync() Kernel = this.CreateKernelWithChatCompletion(), }; - /// Create a chat for agent interaction. For more, . + /// Create the chat history to capture the agent interaction. ChatHistory chat = []; // Respond to user input @@ -43,6 +43,8 @@ async Task InvokeAgentAsync(string input) await foreach (ChatMessageContent content in agent.InvokeAsync(chat)) { + chat.Add(content); + Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); } } diff --git a/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs b/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs index 61737de498be..38741bbb2e7c 100644 --- a/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs +++ b/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs @@ -33,7 +33,7 @@ public async Task UseChatCompletionWithPluginAgentAsync() KernelPlugin plugin = KernelPluginFactory.CreateFromType(); agent.Kernel.Plugins.Add(plugin); - /// Create a chat for agent interaction. For more, . + /// Create the chat history to capture the agent interaction. ChatHistory chat = []; // Respond to user input, invoking functions where appropriate. @@ -48,8 +48,10 @@ async Task InvokeAgentAsync(string input) chat.Add(new ChatMessageContent(AuthorRole.User, input)); Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var content in agent.InvokeAsync(chat)) + await foreach (ChatMessageContent content in agent.InvokeAsync(chat)) { + chat.Add(content); + Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); } } diff --git a/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs b/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs index 0c9c60f870a7..5d0c185f95f5 100644 --- a/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs +++ b/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs @@ -78,7 +78,7 @@ public async Task UseAgentGroupChatWithTwoAgentsAsync() chat.AddChatMessage(new ChatMessageContent(AuthorRole.User, input)); Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var content in chat.InvokeAsync()) + await foreach (ChatMessageContent content in chat.InvokeAsync()) { Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); } diff --git a/dotnet/samples/GettingStartedWithAgents/Step4_KernelFunctionStrategies.cs b/dotnet/samples/GettingStartedWithAgents/Step4_KernelFunctionStrategies.cs index cd99531ec27b..9cabe0193d3e 100644 --- a/dotnet/samples/GettingStartedWithAgents/Step4_KernelFunctionStrategies.cs +++ b/dotnet/samples/GettingStartedWithAgents/Step4_KernelFunctionStrategies.cs @@ -120,7 +120,7 @@ State only the name of the participant to take the next turn. chat.AddChatMessage(new ChatMessageContent(AuthorRole.User, input)); Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var content in chat.InvokeAsync()) + await foreach (ChatMessageContent content in chat.InvokeAsync()) { Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); } diff --git a/dotnet/samples/GettingStartedWithAgents/Step5_JsonResult.cs b/dotnet/samples/GettingStartedWithAgents/Step5_JsonResult.cs index b1e83a202505..20ad4c2096d4 100644 --- a/dotnet/samples/GettingStartedWithAgents/Step5_JsonResult.cs +++ b/dotnet/samples/GettingStartedWithAgents/Step5_JsonResult.cs @@ -64,7 +64,7 @@ async Task InvokeAgentAsync(string input) Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var content in chat.InvokeAsync(agent)) + await foreach (ChatMessageContent content in chat.InvokeAsync(agent)) { Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); Console.WriteLine($"# IS COMPLETE: {chat.IsComplete}"); diff --git a/dotnet/samples/GettingStartedWithAgents/Step6_DependencyInjection.cs b/dotnet/samples/GettingStartedWithAgents/Step6_DependencyInjection.cs index a7e3b9b41450..21af5db70dce 100644 --- a/dotnet/samples/GettingStartedWithAgents/Step6_DependencyInjection.cs +++ b/dotnet/samples/GettingStartedWithAgents/Step6_DependencyInjection.cs @@ -82,7 +82,7 @@ async Task WriteAgentResponse(string input) { Console.WriteLine($"# {AuthorRole.User}: {input}"); - await foreach (var content in agentClient.RunDemoAsync(input)) + await foreach (ChatMessageContent content in agentClient.RunDemoAsync(input)) { Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); } diff --git a/dotnet/samples/GettingStartedWithAgents/Step7_Logging.cs b/dotnet/samples/GettingStartedWithAgents/Step7_Logging.cs index 4372d71e37f8..1ab559e668fb 100644 --- a/dotnet/samples/GettingStartedWithAgents/Step7_Logging.cs +++ b/dotnet/samples/GettingStartedWithAgents/Step7_Logging.cs @@ -85,7 +85,7 @@ public async Task UseLoggerFactoryWithAgentGroupChatAsync() chat.AddChatMessage(new ChatMessageContent(AuthorRole.User, input)); Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var content in chat.InvokeAsync()) + await foreach (ChatMessageContent content in chat.InvokeAsync()) { Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'"); } diff --git a/dotnet/samples/GettingStartedWithAgents/Step8_OpenAIAssistant.cs b/dotnet/samples/GettingStartedWithAgents/Step8_OpenAIAssistant.cs index 09afcfc44826..d9e9760e3fa6 100644 --- a/dotnet/samples/GettingStartedWithAgents/Step8_OpenAIAssistant.cs +++ b/dotnet/samples/GettingStartedWithAgents/Step8_OpenAIAssistant.cs @@ -36,7 +36,7 @@ await OpenAIAssistantAgent.CreateAsync( KernelPlugin plugin = KernelPluginFactory.CreateFromType(); agent.Kernel.Plugins.Add(plugin); - // Create a chat for agent interaction. + // Create a thread for the agent interaction. string threadId = await agent.CreateThreadAsync(); // Respond to user input @@ -60,7 +60,7 @@ async Task InvokeAgentAsync(string input) Console.WriteLine($"# {AuthorRole.User}: '{input}'"); - await foreach (var content in agent.InvokeAsync(threadId)) + await foreach (ChatMessageContent content in agent.InvokeAsync(threadId)) { if (content.Role != AuthorRole.Tool) {