From 27c266822343c85f4cf70aa49e3e40e20f7733dd Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Fri, 7 Nov 2025 00:58:30 -0800 Subject: [PATCH 1/9] Integrate DevUI into the aiagent-webapi project template --- src/ProjectTemplates/.gitignore | 4 +- src/ProjectTemplates/GeneratedContent.targets | 13 +- .../.template.config/dotnetcli.host.json | 7 + .../.template.config/ide.host.json | 8 ++ .../.template.config/template.json | 18 +++ .../WebApiAgent/WebApiAgent-CSharp/Program.cs | 31 ++++- .../Properties/launchSettings.json.in | 33 +++++ .../WebApiAgent/WebApiAgent-CSharp/README.md | 5 +- .../WebApiAgent-CSharp.csproj.in | 3 + .../aiagent-webapi/Program.cs | 21 ++- .../Properties/launchSettings.json | 6 +- .../aiagent-webapi/README.md | 2 + .../aiagent-webapi/aiagent-webapi.csproj | 1 + .../aiagent-webapi/Program.cs | 21 ++- .../Properties/launchSettings.json | 6 +- .../aiagent-webapi/README.md | 2 + .../aiagent-webapi/aiagent-webapi.csproj | 1 + .../aiagent-webapi/Program.cs | 21 ++- .../Properties/launchSettings.json | 6 +- .../aiagent-webapi/README.md | 2 + .../aiagent-webapi/aiagent-webapi.csproj | 1 + .../aiagent-webapi/Program.cs | 55 ++++++++ .../Properties/launchSettings.json | 6 +- .../aiagent-webapi/README.md | 127 ++++++++++++++++++ .../aiagent-webapi/aiagent-webapi.csproj | 18 +++ .../aiagent-webapi/appsettings.json | 9 ++ .../aiagent-webapi/Program.cs | 21 ++- .../Properties/launchSettings.json | 6 +- .../aiagent-webapi/README.md | 2 + .../aiagent-webapi/aiagent-webapi.csproj | 1 + .../aiagent-webapi/Program.cs | 21 ++- .../Properties/launchSettings.json | 6 +- .../aiagent-webapi/README.md | 3 +- .../aiagent-webapi/aiagent-webapi.csproj | 1 + .../aiagent-webapi/Program.cs | 21 ++- .../Properties/launchSettings.json | 6 +- .../aiagent-webapi/README.md | 2 + .../aiagent-webapi/aiagent-webapi.csproj | 1 + .../WebApiAgentTemplateExecutionTests.cs | 1 + .../WebApiAgentTemplateSnapshotTests.cs | 6 + 40 files changed, 494 insertions(+), 31 deletions(-) create mode 100644 src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json.in create mode 100644 test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs rename {src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp => test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi}/Properties/launchSettings.json (79%) create mode 100644 test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/README.md create mode 100644 test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/aiagent-webapi.csproj create mode 100644 test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/appsettings.json diff --git a/src/ProjectTemplates/.gitignore b/src/ProjectTemplates/.gitignore index ceffca4abbc..10ca9b380a7 100644 --- a/src/ProjectTemplates/.gitignore +++ b/src/ProjectTemplates/.gitignore @@ -12,8 +12,8 @@ package-lock.json */src/**/Directory.Build.props */src/**/ingestioncache.* -# launchSettings.json files are required for the templates. -!launchSettings.json +# The aichatweb template includes hard-coded launchSettings.json files in the template +!Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/*/Properties/launchSettings.json # Templates include JS dependencies in dist folders. !**/dist/* diff --git a/src/ProjectTemplates/GeneratedContent.targets b/src/ProjectTemplates/GeneratedContent.targets index a9c3d4ea760..eaab5017681 100644 --- a/src/ProjectTemplates/GeneratedContent.targets +++ b/src/ProjectTemplates/GeneratedContent.targets @@ -37,8 +37,8 @@ Specifies external packages that get referenced in generated template content. --> - 1.0.0-preview.251104.1 - 1.0.0-alpha.251104.1 + 1.0.0-preview.251105.1 + 1.0.0-alpha.251105.1 9.5.1 9.5.1-preview.1.25502.11 1.0.0 @@ -91,6 +91,12 @@ + + @@ -100,9 +106,6 @@ - diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json index 94096fec7c7..a61ccf07665 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json @@ -16,6 +16,13 @@ "longName": "managed-identity", "shortName": "" }, + "UseDevUI": { + "isHidden": "true" + }, + "DoNotUseDevUI": { + "longName": "no-devui", + "shortName": "" + }, "httpPort": { "isHidden": "true", "longName": "httpPort", diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json index f91c03c283d..28d717c8506 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json @@ -15,6 +15,14 @@ { "id": "UseManagedIdentity", "isVisible": true + }, + { + "id": "UseDevUI", + "isVisible": true + }, + { + "id": "DoNotUseDevUI", + "isVisible": false } ] } diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json index 6aff00cbd63..4d4ef9883a8 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json @@ -93,6 +93,20 @@ "isEnabled": "(AiServiceProvider == \"azureopenai\")", "description": "Use managed identity to access Azure services" }, + "UseDevUI": { + "type": "parameter", + "displayName": "Enable the Agent Framework developer UI", + "datatype": "bool", + "defaultValue": "true", + "description": "Add the Agent Framework developer UI for use in the development environment" + }, + "DoNotUseDevUI": { + "type": "parameter", + "displayName": "Disable the Agent Framework developer UI", + "datatype": "bool", + "defaultValue": "false", + "description": "Do not add the Agent Framework developer UI" + }, "ChatModel": { "type": "parameter", "displayName": "Model/deployment for chat completions. Example: gpt-4o-mini", @@ -102,6 +116,10 @@ "type": "computed", "value": "(UseManagedIdentity)" }, + "IsDevUIEnabled": { + "type": "computed", + "value": "(UseDevUI && !DoNotUseDevUI)" + }, "IsAzureOpenAI": { "type": "computed", "value": "(AiServiceProvider == \"azureopenai\")" diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs index aadc8b70181..1f454791a2b 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs @@ -8,6 +8,9 @@ using Azure.Identity; #endif using Microsoft.Agents.AI; +#if (IsDevUIEnabled) +using Microsoft.Agents.AI.DevUI; +#endif using Microsoft.Agents.AI.Hosting; using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; @@ -86,11 +89,37 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +#if (IsDevUIEnabled) +if (builder.Environment.IsDevelopment()) +{ + // Add the Agent Framework developer UI (DevUI) services in development environments + builder.AddDevUI(); +} +#endif +var app = builder.Build(); app.UseHttpsRedirection(); + +// Expose the agents using the OpenAI Responses API +#if (IsDevUIEnabled) +// This is also needed for DevUI to function +#endif app.MapOpenAIResponses(); +// Expose the conversations using the OpenAI Conversations API +#if (IsDevUIEnabled) +// This is also needed for DevUI to manage stateful conversations +#endif +app.MapOpenAIConversations(); + +#if (IsDevUIEnabled) +if (app.Environment.IsDevelopment()) +{ + // Map the Agent Framework developer UI to /devui/ in development environments + app.MapDevUI(); +} + +#endif app.Run(); [Description("Formats the story for display.")] diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json.in b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json.in new file mode 100644 index 00000000000..c6738271d14 --- /dev/null +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json.in @@ -0,0 +1,33 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, +//#if (IsDevUIEnabled) + "launchBrowser": true, + "launchUrl": "devui/", +//#else + "launchBrowser": false, +//#endif + "applicationUrl": "http://localhost:5056", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, +//#if (IsDevUIEnabled) + "launchBrowser": true, + "launchUrl": "devui/", +//#else + "launchBrowser": false, +//#endif + "applicationUrl": "https://localhost:7041;http://localhost:5056", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md index 9355df92141..0d8ed99e232 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md @@ -165,6 +165,10 @@ The application will start and listen on: The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. + +In development environments, a `/devui/` route is mapped to the Agent Framework development UI (DevUI), and when the app is launched through an IDE a browser will open to this URL. DevUI provides a web-based UI for interacting with agents and workflows. DevUI operates as an OpenAI-compatible client using the Responses and Conversations endpoints. + + ## How It Works This application demonstrates Agent Framework with: @@ -280,5 +284,4 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 **Problem**: Model responses are slow or time out **Solution**: Ollama runs locally and performance depends on your hardware. Consider using a smaller model or ensuring your system has adequate resources (RAM, GPU if available). - diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in index 7ab75edde39..ac18e7ced67 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in @@ -9,6 +9,9 @@ + + + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs index da628ffb782..b624cc93c5b 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs @@ -1,6 +1,7 @@ using System.ClientModel; using System.ComponentModel; using Microsoft.Agents.AI; +using Microsoft.Agents.AI.DevUI; using Microsoft.Agents.AI.Hosting; using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; @@ -38,11 +39,29 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +if (builder.Environment.IsDevelopment()) +{ + // Add the Agent Framework developer UI (DevUI) services in development environments + builder.AddDevUI(); +} +var app = builder.Build(); app.UseHttpsRedirection(); + +// Expose the agents using the OpenAI Responses API +// This is also needed for DevUI to function app.MapOpenAIResponses(); +// Expose the conversations using the OpenAI Conversations API +// This is also needed for DevUI to manage stateful conversations +app.MapOpenAIConversations(); + +if (app.Environment.IsDevelopment()) +{ + // Map the Agent Framework developer UI to /devui/ in development environments + app.MapDevUI(); +} + app.Run(); [Description("Formats the story for display.")] diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Properties/launchSettings.json index 61e7634bcbb..c242aacc025 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Properties/launchSettings.json +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Properties/launchSettings.json @@ -4,7 +4,8 @@ "http": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -13,7 +14,8 @@ "https": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "https://localhost:9999;http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md index f524a1b6191..76b5b021b7c 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md @@ -55,6 +55,8 @@ The application will start and listen on: The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. +In development environments, a `/devui/` route is mapped to the Agent Framework development UI (DevUI), and when the app is launched through an IDE a browser will open to this URL. DevUI provides a web-based UI for interacting with agents and workflows. DevUI operates as an OpenAI-compatible client using the Responses and Conversations endpoints. + ## How It Works This application demonstrates Agent Framework with: diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/aiagent-webapi.csproj index 352213bdc90..337bfdd220c 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/aiagent-webapi.csproj +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/aiagent-webapi.csproj @@ -9,6 +9,7 @@ + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs index ced383f0234..d28cdae1fbc 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs @@ -2,6 +2,7 @@ using System.ComponentModel; using Azure.Identity; using Microsoft.Agents.AI; +using Microsoft.Agents.AI.DevUI; using Microsoft.Agents.AI.Hosting; using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; @@ -39,11 +40,29 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +if (builder.Environment.IsDevelopment()) +{ + // Add the Agent Framework developer UI (DevUI) services in development environments + builder.AddDevUI(); +} +var app = builder.Build(); app.UseHttpsRedirection(); + +// Expose the agents using the OpenAI Responses API +// This is also needed for DevUI to function app.MapOpenAIResponses(); +// Expose the conversations using the OpenAI Conversations API +// This is also needed for DevUI to manage stateful conversations +app.MapOpenAIConversations(); + +if (app.Environment.IsDevelopment()) +{ + // Map the Agent Framework developer UI to /devui/ in development environments + app.MapDevUI(); +} + app.Run(); [Description("Formats the story for display.")] diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Properties/launchSettings.json index 61e7634bcbb..c242aacc025 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Properties/launchSettings.json +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Properties/launchSettings.json @@ -4,7 +4,8 @@ "http": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -13,7 +14,8 @@ "https": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "https://localhost:9999;http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md index f912ccb7bc0..3c15487dec6 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md @@ -27,6 +27,8 @@ The application will start and listen on: The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. +In development environments, a `/devui/` route is mapped to the Agent Framework development UI (DevUI), and when the app is launched through an IDE a browser will open to this URL. DevUI provides a web-based UI for interacting with agents and workflows. DevUI operates as an OpenAI-compatible client using the Responses and Conversations endpoints. + ## How It Works This application demonstrates Agent Framework with: diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj index d1029ebe6a1..df14d27b60b 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj @@ -9,6 +9,7 @@ + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs index 9ed14c2c652..99fb24ee9e0 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs @@ -1,6 +1,7 @@ using System.ClientModel; using System.ComponentModel; using Microsoft.Agents.AI; +using Microsoft.Agents.AI.DevUI; using Microsoft.Agents.AI.Hosting; using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; @@ -35,11 +36,29 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +if (builder.Environment.IsDevelopment()) +{ + // Add the Agent Framework developer UI (DevUI) services in development environments + builder.AddDevUI(); +} +var app = builder.Build(); app.UseHttpsRedirection(); + +// Expose the agents using the OpenAI Responses API +// This is also needed for DevUI to function app.MapOpenAIResponses(); +// Expose the conversations using the OpenAI Conversations API +// This is also needed for DevUI to manage stateful conversations +app.MapOpenAIConversations(); + +if (app.Environment.IsDevelopment()) +{ + // Map the Agent Framework developer UI to /devui/ in development environments + app.MapDevUI(); +} + app.Run(); [Description("Formats the story for display.")] diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Properties/launchSettings.json index 61e7634bcbb..c242aacc025 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Properties/launchSettings.json +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Properties/launchSettings.json @@ -4,7 +4,8 @@ "http": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -13,7 +14,8 @@ "https": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "https://localhost:9999;http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md index b400819b591..eb5e909ee9b 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md @@ -57,6 +57,8 @@ The application will start and listen on: The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. +In development environments, a `/devui/` route is mapped to the Agent Framework development UI (DevUI), and when the app is launched through an IDE a browser will open to this URL. DevUI provides a web-based UI for interacting with agents and workflows. DevUI operates as an OpenAI-compatible client using the Responses and Conversations endpoints. + ## How It Works This application demonstrates Agent Framework with: diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/aiagent-webapi.csproj index 352213bdc90..337bfdd220c 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/aiagent-webapi.csproj +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/aiagent-webapi.csproj @@ -9,6 +9,7 @@ + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs new file mode 100644 index 00000000000..0a3d90ee4f1 --- /dev/null +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs @@ -0,0 +1,55 @@ +using System.ClientModel; +using System.ComponentModel; +using Microsoft.Agents.AI; +using Microsoft.Agents.AI.Hosting; +using Microsoft.Agents.AI.Workflows; +using Microsoft.Extensions.AI; +using OpenAI; + +var builder = WebApplication.CreateBuilder(args); + +// You will need to set the token to your own value +// You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: +// cd this-project-directory +// dotnet user-secrets set GitHubModels:Token YOUR-GITHUB-TOKEN +var credential = new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token. See README for details.")); +var openAIOptions = new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }; + +var chatClient = new OpenAIClient(credential, openAIOptions) + .GetChatClient("gpt-4o-mini").AsIChatClient(); + +builder.Services.AddChatClient(chatClient); + +builder.AddAIAgent("writer", "You write short stories (300 words or less) about the specified topic."); + +builder.AddAIAgent("editor", (sp, key) => new ChatClientAgent( + chatClient, + name: key, + instructions: "You edit short stories to improve grammar and style. You ensure the stories are less than 300 words.", + tools: [ AIFunctionFactory.Create(FormatStory) ] +)); + +builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( + workflowName: key, + sp.GetRequiredKeyedService("writer"), + sp.GetRequiredKeyedService("editor") +)).AddAsAIAgent(); + +var app = builder.Build(); +app.UseHttpsRedirection(); + +// Expose the agents using the OpenAI Responses API +app.MapOpenAIResponses(); + +// Expose the conversations using the OpenAI Conversations API +app.MapOpenAIConversations(); + +app.Run(); + +[Description("Formats the story for display.")] +string FormatStory(string title, string story) => $""" + **Title**: {title} + **Date**: {DateTime.Today.ToShortDateString()} + + {story} + """; diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Properties/launchSettings.json similarity index 79% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Properties/launchSettings.json index 9bc26dbafff..61e7634bcbb 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Properties/launchSettings.json @@ -1,11 +1,11 @@ -{ +{ "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "http": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": false, - "applicationUrl": "http://localhost:5056", + "applicationUrl": "http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -14,7 +14,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": false, - "applicationUrl": "https://localhost:7041;http://localhost:5056", + "applicationUrl": "https://localhost:9999;http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/README.md new file mode 100644 index 00000000000..b400819b591 --- /dev/null +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/README.md @@ -0,0 +1,127 @@ +# AI Agent Web API + +This is an AI Agent Web API application created from the `aiagent-webapi` template. This template is currently in a preview stage. If you have feedback, please take a [brief survey](https://aka.ms/dotnet/aiagent-webapi/preview1/survey). + +## Prerequisites + +- A GitHub Models API token (free to get started) + +## Getting Started + +### 1. Configure Your AI Service + +#### GitHub Models Configuration + +This application uses GitHub Models (model: gpt-4o-mini) for AI functionality. You'll need to configure your GitHub Models API token: + +**Option A: Using User Secrets (Recommended for Development)** + +```bash +dotnet user-secrets set "GitHubModels:Token" "your-github-models-token-here" +``` + +**Option B: Using Environment Variables** + +Set the `GitHubModels__Token` environment variable: + +- **Windows (PowerShell)**: + ```powershell + $env:GitHubModels__Token = "your-github-models-token-here" + ``` + +- **Linux/macOS**: + ```bash + export GitHubModels__Token="your-github-models-token-here" + ``` + +#### Get a GitHub Models Token + +1. Visit [GitHub Models](https://github.com/marketplace/models) +2. Sign in with your GitHub account +3. Select a model (e.g., gpt-4o-mini) +4. Click "Get API Key" or follow the authentication instructions +5. Copy your personal access token + + +### 2. Run the Application + +```bash +dotnet run -lp https +``` + +The application will start and listen on: +- HTTP: `http://localhost:9999` +- HTTPS: `https://localhost:9999` + +### 3. Test the Application + +The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. + +## How It Works + +This application demonstrates Agent Framework with: + +1. **Writer Agent**: Writes short stories (300 words or less) about specified topics +2. **Editor Agent**: Edits stories to improve grammar and style, ensuring they stay under 300 words +3. **Publisher Workflow Agent**: A sequential workflow agent that combines the writer and editor agents + +The agents are exposed through OpenAI-compatible API endpoints, making them easy to integrate with existing tools and applications. + +## Template Parameters + +When creating a new project, you can customize it using template parameters: + +```bash +# Specify AI service provider +dotnet new aiagent-webapi --provider azureopenai + +# Specify a custom chat model +dotnet new aiagent-webapi --chat-model gpt-4o + +# Use API key authentication for Azure OpenAI +dotnet new aiagent-webapi --provider azureopenai --managed-identity false + +# Use Ollama with a different model +dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 +``` + +### Available Parameters + +- **`--provider`**: Choose the AI service provider + - `githubmodels` (default) - GitHub Models + - `azureopenai` - Azure OpenAI + - `openai` - OpenAI Platform + - `ollama` - Ollama (local development) + +- **`--chat-model`**: Specify the chat model/deployment name + - Default for OpenAI/Azure OpenAI/GitHub Models: `gpt-4o-mini` + - Default for Ollama: `llama3.2` + +- **`--managed-identity`**: Use managed identity for Azure services (default: `true`) + - Only applicable when `--provider azureopenai` + +- **`--framework`**: Target framework (default: `net10.0`) + - Options: `net10.0`, `net9.0`, `net8.0` + +## Project Structure + +- `Program.cs` - Application entry point and configuration +- `appsettings.json` - Application configuration +- `Properties/launchSettings.json` - Launch profiles for development + +## Learn More + +- [AI apps for .NET developers](https://learn.microsoft.com/dotnet/ai) +- [Microsoft Agent Framework Documentation](https://aka.ms/dotnet/agent-framework/docs) +- [GitHub Models](https://github.com/marketplace/models) + +## Troubleshooting + +**Problem**: Application fails with "Missing configuration: GitHubModels:Token" + +**Solution**: Make sure you've configured your GitHub Models API token using one of the methods described above. + +**Problem**: API requests fail with authentication errors + +**Solution**: Verify your GitHub Models token is valid and hasn't expired. You may need to regenerate it from the GitHub Models website. + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/aiagent-webapi.csproj new file mode 100644 index 00000000000..352213bdc90 --- /dev/null +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/aiagent-webapi.csproj @@ -0,0 +1,18 @@ + + + + net10.0 + enable + enable + secret + + + + + + + + + + + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/appsettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/appsettings.json new file mode 100644 index 00000000000..223027717b4 --- /dev/null +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs index 9ed14c2c652..99fb24ee9e0 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs @@ -1,6 +1,7 @@ using System.ClientModel; using System.ComponentModel; using Microsoft.Agents.AI; +using Microsoft.Agents.AI.DevUI; using Microsoft.Agents.AI.Hosting; using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; @@ -35,11 +36,29 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +if (builder.Environment.IsDevelopment()) +{ + // Add the Agent Framework developer UI (DevUI) services in development environments + builder.AddDevUI(); +} +var app = builder.Build(); app.UseHttpsRedirection(); + +// Expose the agents using the OpenAI Responses API +// This is also needed for DevUI to function app.MapOpenAIResponses(); +// Expose the conversations using the OpenAI Conversations API +// This is also needed for DevUI to manage stateful conversations +app.MapOpenAIConversations(); + +if (app.Environment.IsDevelopment()) +{ + // Map the Agent Framework developer UI to /devui/ in development environments + app.MapDevUI(); +} + app.Run(); [Description("Formats the story for display.")] diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Properties/launchSettings.json index 61e7634bcbb..c242aacc025 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Properties/launchSettings.json +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Properties/launchSettings.json @@ -4,7 +4,8 @@ "http": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -13,7 +14,8 @@ "https": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "https://localhost:9999;http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md index b400819b591..eb5e909ee9b 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md @@ -57,6 +57,8 @@ The application will start and listen on: The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. +In development environments, a `/devui/` route is mapped to the Agent Framework development UI (DevUI), and when the app is launched through an IDE a browser will open to this URL. DevUI provides a web-based UI for interacting with agents and workflows. DevUI operates as an OpenAI-compatible client using the Responses and Conversations endpoints. + ## How It Works This application demonstrates Agent Framework with: diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/aiagent-webapi.csproj index 352213bdc90..337bfdd220c 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/aiagent-webapi.csproj +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/aiagent-webapi.csproj @@ -9,6 +9,7 @@ + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs index 4015d7fdc98..a53b31a48e1 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs @@ -1,5 +1,6 @@ using System.ComponentModel; using Microsoft.Agents.AI; +using Microsoft.Agents.AI.DevUI; using Microsoft.Agents.AI.Hosting; using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; @@ -28,11 +29,29 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +if (builder.Environment.IsDevelopment()) +{ + // Add the Agent Framework developer UI (DevUI) services in development environments + builder.AddDevUI(); +} +var app = builder.Build(); app.UseHttpsRedirection(); + +// Expose the agents using the OpenAI Responses API +// This is also needed for DevUI to function app.MapOpenAIResponses(); +// Expose the conversations using the OpenAI Conversations API +// This is also needed for DevUI to manage stateful conversations +app.MapOpenAIConversations(); + +if (app.Environment.IsDevelopment()) +{ + // Map the Agent Framework developer UI to /devui/ in development environments + app.MapDevUI(); +} + app.Run(); [Description("Formats the story for display.")] diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Properties/launchSettings.json index 61e7634bcbb..c242aacc025 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Properties/launchSettings.json +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Properties/launchSettings.json @@ -4,7 +4,8 @@ "http": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -13,7 +14,8 @@ "https": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "https://localhost:9999;http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md index 3cb101869fe..d12ccbd2aa2 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md @@ -38,6 +38,8 @@ The application will start and listen on: The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. +In development environments, a `/devui/` route is mapped to the Agent Framework development UI (DevUI), and when the app is launched through an IDE a browser will open to this URL. DevUI provides a web-based UI for interacting with agents and workflows. DevUI operates as an OpenAI-compatible client using the Responses and Conversations endpoints. + ## How It Works This application demonstrates Agent Framework with: @@ -108,4 +110,3 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 **Problem**: Model responses are slow or time out **Solution**: Ollama runs locally and performance depends on your hardware. Consider using a smaller model or ensuring your system has adequate resources (RAM, GPU if available). - diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj index 09e26e73acc..ed108d406e6 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj @@ -9,6 +9,7 @@ + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs index 4bf9e2b74b8..2bb9d029d64 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs @@ -1,6 +1,7 @@ using System.ClientModel; using System.ComponentModel; using Microsoft.Agents.AI; +using Microsoft.Agents.AI.DevUI; using Microsoft.Agents.AI.Hosting; using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; @@ -36,11 +37,29 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +if (builder.Environment.IsDevelopment()) +{ + // Add the Agent Framework developer UI (DevUI) services in development environments + builder.AddDevUI(); +} +var app = builder.Build(); app.UseHttpsRedirection(); + +// Expose the agents using the OpenAI Responses API +// This is also needed for DevUI to function app.MapOpenAIResponses(); +// Expose the conversations using the OpenAI Conversations API +// This is also needed for DevUI to manage stateful conversations +app.MapOpenAIConversations(); + +if (app.Environment.IsDevelopment()) +{ + // Map the Agent Framework developer UI to /devui/ in development environments + app.MapDevUI(); +} + app.Run(); [Description("Formats the story for display.")] diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Properties/launchSettings.json index 61e7634bcbb..c242aacc025 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Properties/launchSettings.json +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Properties/launchSettings.json @@ -4,7 +4,8 @@ "http": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -13,7 +14,8 @@ "https": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "https://localhost:9999;http://localhost:9999", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md index 898c82c2098..50e9252c0ff 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md @@ -57,6 +57,8 @@ The application will start and listen on: The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. +In development environments, a `/devui/` route is mapped to the Agent Framework development UI (DevUI), and when the app is launched through an IDE a browser will open to this URL. DevUI provides a web-based UI for interacting with agents and workflows. DevUI operates as an OpenAI-compatible client using the Responses and Conversations endpoints. + ## How It Works This application demonstrates Agent Framework with: diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/aiagent-webapi.csproj index 352213bdc90..337bfdd220c 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/aiagent-webapi.csproj +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/aiagent-webapi.csproj @@ -9,6 +9,7 @@ + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs index f9dc4861c65..e18f19430f4 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs @@ -55,6 +55,7 @@ public async Task CreateRestoreAndBuild(params string[] args) private static readonly (string name, string[] values)[] _templateOptions = [ ("--provider", ["azureopenai", "githubmodels", "ollama", "openai"]), ("--managed-identity", ["true", "false"]), + ("--no-devui", ["true", "false"]), ]; private static IEnumerable GetFilteredTemplateOptions(params string[] filter) diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs index fb907ca36fd..b5b118248d2 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs @@ -73,6 +73,12 @@ public async Task Ollama() await TestTemplateCoreAsync(scenarioName: nameof(Ollama), templateArgs: ["--provider", "ollama"]); } + [Fact] + public async Task DisableDevUI() + { + await TestTemplateCoreAsync(scenarioName: nameof(DisableDevUI), templateArgs: ["--no-devui"]); + } + private async Task TestTemplateCoreAsync(string scenarioName, IEnumerable? templateArgs = null) { string workingDir = TestUtils.CreateTemporaryFolder(); From 6a59614630aa9c79bd025e9bd3f33f86321ce700 Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Fri, 7 Nov 2025 20:55:39 -0800 Subject: [PATCH 2/9] Improve aiagent-webapi Program.cs per feedback. --- src/ProjectTemplates/GeneratedContent.targets | 4 +- .../WebApiAgent/WebApiAgent-CSharp/Program.cs | 50 +++++++++---------- .../aiagent-webapi/Program.cs | 31 +++++------- .../aiagent-webapi/Program.cs | 29 +++++------ .../aiagent-webapi/Program.cs | 38 +++++++------- .../aiagent-webapi/Program.cs | 26 +++++----- .../aiagent-webapi/Program.cs | 38 +++++++------- .../aiagent-webapi/Program.cs | 27 ++++------ .../aiagent-webapi/Program.cs | 29 +++++------ 9 files changed, 121 insertions(+), 151 deletions(-) diff --git a/src/ProjectTemplates/GeneratedContent.targets b/src/ProjectTemplates/GeneratedContent.targets index eaab5017681..8743c058127 100644 --- a/src/ProjectTemplates/GeneratedContent.targets +++ b/src/ProjectTemplates/GeneratedContent.targets @@ -37,8 +37,8 @@ Specifies external packages that get referenced in generated template content. --> - 1.0.0-preview.251105.1 - 1.0.0-alpha.251105.1 + 1.0.0-preview.251107.2 + 1.0.0-alpha.251107.2 9.5.1 9.5.1-preview.1.25502.11 1.0.0 diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs index 1f454791a2b..058b9b1842b 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs @@ -19,6 +19,9 @@ #elif (IsGHModels || IsOpenAI || IsAzureOpenAI) using OpenAI; #endif +#if (IsGHModels) +using OpenAI.Chat; +#endif var builder = WebApplication.CreateBuilder(args); @@ -27,11 +30,11 @@ // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory // dotnet user-secrets set GitHubModels:Token YOUR-GITHUB-TOKEN -var credential = new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token. See README for details.")); -var openAIOptions = new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }; - -var chatClient = new OpenAIClient(credential, openAIOptions) - .GetChatClient("gpt-4o-mini").AsIChatClient(); +var chatClient = new ChatClient( + "gpt-4o-mini", + new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token.")), + new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }) + .AsIChatClient(); #elif (IsOllama) // You will need to have Ollama running locally with the llama3.2 model installed // Visit https://ollama.com for installation instructions @@ -42,7 +45,7 @@ // cd this-project-directory // dotnet user-secrets set OpenAI:Key YOUR-API-KEY var openAIClient = new OpenAIClient( - new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key. See README for details."))); + new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key."))); #pragma warning disable OPENAI001 // GetOpenAIResponseClient(string) is experimental and subject to change or removal in future updates. var chatClient = openAIClient.GetOpenAIResponseClient("gpt-4o-mini").AsIChatClient(); @@ -55,7 +58,7 @@ #if (!IsManagedIdentity) // dotnet user-secrets set AzureOpenAI:Key YOUR-API-KEY #endif -var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint. See README for details.")), "/openai/v1"); +var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint.")), "/openai/v1"); #if (IsManagedIdentity) #pragma warning disable OPENAI001 // OpenAIClient(AuthenticationPolicy, OpenAIClientOptions) and GetOpenAIResponseClient(string) are experimental and subject to change or removal in future updates. var azureOpenAI = new OpenAIClient( @@ -64,7 +67,7 @@ #elif (!IsManagedIdentity) var openAIOptions = new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }; -var azureOpenAI = new OpenAIClient(new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key. See README for details.")), openAIOptions); +var azureOpenAI = new OpenAIClient(new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key.")), openAIOptions); #pragma warning disable OPENAI001 // GetOpenAIResponseClient(string) is experimental and subject to change or removal in future updates. #endif @@ -79,8 +82,8 @@ builder.AddAIAgent("editor", (sp, key) => new ChatClientAgent( chatClient, name: key, - instructions: "You edit short stories to improve grammar and style. You ensure the stories are less than 300 words.", - tools: [ AIFunctionFactory.Create(FormatStory) ] + instructions: "You edit short stories to improve grammar and style, ensuring the stories are less than 300 words. Once finished editing, you select a title and format the story for publishing.", + tools: [AIFunctionFactory.Create(FormatStory)] )); builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( @@ -89,43 +92,36 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); +// Register services for OpenAI responses and conversations #if (IsDevUIEnabled) -if (builder.Environment.IsDevelopment()) -{ - // Add the Agent Framework developer UI (DevUI) services in development environments - builder.AddDevUI(); -} - +// This is also required for DevUI #endif +builder.Services.AddOpenAIResponses(); +builder.Services.AddOpenAIConversations(); + var app = builder.Build(); app.UseHttpsRedirection(); -// Expose the agents using the OpenAI Responses API +// Map endpoints for OpenAI responses and conversations #if (IsDevUIEnabled) -// This is also needed for DevUI to function +// This is also required for DevUI #endif app.MapOpenAIResponses(); - -// Expose the conversations using the OpenAI Conversations API -#if (IsDevUIEnabled) -// This is also needed for DevUI to manage stateful conversations -#endif app.MapOpenAIConversations(); #if (IsDevUIEnabled) -if (app.Environment.IsDevelopment()) +if (builder.Environment.IsDevelopment()) { - // Map the Agent Framework developer UI to /devui/ in development environments + // Map DevUI endpoint to /devui app.MapDevUI(); } #endif app.Run(); -[Description("Formats the story for display.")] +[Description("Formats the story for publication, revealing its title.")] string FormatStory(string title, string story) => $""" **Title**: {title} - **Date**: {DateTime.Today.ToShortDateString()} {story} """; diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs index b624cc93c5b..7db2e3c2795 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs @@ -14,9 +14,9 @@ // cd this-project-directory // dotnet user-secrets set AzureOpenAI:Endpoint https://YOUR-DEPLOYMENT-NAME.openai.azure.com // dotnet user-secrets set AzureOpenAI:Key YOUR-API-KEY -var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint. See README for details.")), "/openai/v1"); +var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint.")), "/openai/v1"); var openAIOptions = new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }; -var azureOpenAI = new OpenAIClient(new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key. See README for details.")), openAIOptions); +var azureOpenAI = new OpenAIClient(new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key.")), openAIOptions); #pragma warning disable OPENAI001 // GetOpenAIResponseClient(string) is experimental and subject to change or removal in future updates. var chatClient = azureOpenAI.GetOpenAIResponseClient("gpt-4o-mini").AsIChatClient(); @@ -29,8 +29,8 @@ builder.AddAIAgent("editor", (sp, key) => new ChatClientAgent( chatClient, name: key, - instructions: "You edit short stories to improve grammar and style. You ensure the stories are less than 300 words.", - tools: [ AIFunctionFactory.Create(FormatStory) ] + instructions: "You edit short stories to improve grammar and style, ensuring the stories are less than 300 words. Once finished editing, you select a title and format the story for publishing.", + tools: [AIFunctionFactory.Create(FormatStory)] )); builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( @@ -39,35 +39,30 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -if (builder.Environment.IsDevelopment()) -{ - // Add the Agent Framework developer UI (DevUI) services in development environments - builder.AddDevUI(); -} +// Register services for OpenAI responses and conversations +// This is also required for DevUI +builder.Services.AddOpenAIResponses(); +builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Expose the agents using the OpenAI Responses API -// This is also needed for DevUI to function +// Map endpoints for OpenAI responses and conversations +// This is also required for DevUI app.MapOpenAIResponses(); - -// Expose the conversations using the OpenAI Conversations API -// This is also needed for DevUI to manage stateful conversations app.MapOpenAIConversations(); -if (app.Environment.IsDevelopment()) +if (builder.Environment.IsDevelopment()) { - // Map the Agent Framework developer UI to /devui/ in development environments + // Map DevUI endpoint to /devui app.MapDevUI(); } app.Run(); -[Description("Formats the story for display.")] +[Description("Formats the story for publication, revealing its title.")] string FormatStory(string title, string story) => $""" **Title**: {title} - **Date**: {DateTime.Today.ToShortDateString()} {story} """; diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs index d28cdae1fbc..0a7b28e6d6d 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs @@ -14,7 +14,7 @@ // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory // dotnet user-secrets set AzureOpenAI:Endpoint https://YOUR-DEPLOYMENT-NAME.openai.azure.com -var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint. See README for details.")), "/openai/v1"); +var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint.")), "/openai/v1"); #pragma warning disable OPENAI001 // OpenAIClient(AuthenticationPolicy, OpenAIClientOptions) and GetOpenAIResponseClient(string) are experimental and subject to change or removal in future updates. var azureOpenAI = new OpenAIClient( new BearerTokenPolicy(new DefaultAzureCredential(), "https://ai.azure.com/.default"), @@ -30,8 +30,8 @@ builder.AddAIAgent("editor", (sp, key) => new ChatClientAgent( chatClient, name: key, - instructions: "You edit short stories to improve grammar and style. You ensure the stories are less than 300 words.", - tools: [ AIFunctionFactory.Create(FormatStory) ] + instructions: "You edit short stories to improve grammar and style, ensuring the stories are less than 300 words. Once finished editing, you select a title and format the story for publishing.", + tools: [AIFunctionFactory.Create(FormatStory)] )); builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( @@ -40,35 +40,30 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -if (builder.Environment.IsDevelopment()) -{ - // Add the Agent Framework developer UI (DevUI) services in development environments - builder.AddDevUI(); -} +// Register services for OpenAI responses and conversations +// This is also required for DevUI +builder.Services.AddOpenAIResponses(); +builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Expose the agents using the OpenAI Responses API -// This is also needed for DevUI to function +// Map endpoints for OpenAI responses and conversations +// This is also required for DevUI app.MapOpenAIResponses(); - -// Expose the conversations using the OpenAI Conversations API -// This is also needed for DevUI to manage stateful conversations app.MapOpenAIConversations(); -if (app.Environment.IsDevelopment()) +if (builder.Environment.IsDevelopment()) { - // Map the Agent Framework developer UI to /devui/ in development environments + // Map DevUI endpoint to /devui app.MapDevUI(); } app.Run(); -[Description("Formats the story for display.")] +[Description("Formats the story for publication, revealing its title.")] string FormatStory(string title, string story) => $""" **Title**: {title} - **Date**: {DateTime.Today.ToShortDateString()} {story} """; diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs index 99fb24ee9e0..fb80562fd7e 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs @@ -6,6 +6,7 @@ using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; using OpenAI; +using OpenAI.Chat; var builder = WebApplication.CreateBuilder(args); @@ -13,11 +14,11 @@ // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory // dotnet user-secrets set GitHubModels:Token YOUR-GITHUB-TOKEN -var credential = new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token. See README for details.")); -var openAIOptions = new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }; - -var chatClient = new OpenAIClient(credential, openAIOptions) - .GetChatClient("gpt-4o-mini").AsIChatClient(); +var chatClient = new ChatClient( + "gpt-4o-mini", + new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token.")), + new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }) + .AsIChatClient(); builder.Services.AddChatClient(chatClient); @@ -26,8 +27,8 @@ builder.AddAIAgent("editor", (sp, key) => new ChatClientAgent( chatClient, name: key, - instructions: "You edit short stories to improve grammar and style. You ensure the stories are less than 300 words.", - tools: [ AIFunctionFactory.Create(FormatStory) ] + instructions: "You edit short stories to improve grammar and style, ensuring the stories are less than 300 words. Once finished editing, you select a title and format the story for publishing.", + tools: [AIFunctionFactory.Create(FormatStory)] )); builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( @@ -36,35 +37,30 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -if (builder.Environment.IsDevelopment()) -{ - // Add the Agent Framework developer UI (DevUI) services in development environments - builder.AddDevUI(); -} +// Register services for OpenAI responses and conversations +// This is also required for DevUI +builder.Services.AddOpenAIResponses(); +builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Expose the agents using the OpenAI Responses API -// This is also needed for DevUI to function +// Map endpoints for OpenAI responses and conversations +// This is also required for DevUI app.MapOpenAIResponses(); - -// Expose the conversations using the OpenAI Conversations API -// This is also needed for DevUI to manage stateful conversations app.MapOpenAIConversations(); -if (app.Environment.IsDevelopment()) +if (builder.Environment.IsDevelopment()) { - // Map the Agent Framework developer UI to /devui/ in development environments + // Map DevUI endpoint to /devui app.MapDevUI(); } app.Run(); -[Description("Formats the story for display.")] +[Description("Formats the story for publication, revealing its title.")] string FormatStory(string title, string story) => $""" **Title**: {title} - **Date**: {DateTime.Today.ToShortDateString()} {story} """; diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs index 0a3d90ee4f1..900061e9694 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs @@ -5,6 +5,7 @@ using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; using OpenAI; +using OpenAI.Chat; var builder = WebApplication.CreateBuilder(args); @@ -12,11 +13,11 @@ // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory // dotnet user-secrets set GitHubModels:Token YOUR-GITHUB-TOKEN -var credential = new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token. See README for details.")); -var openAIOptions = new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }; - -var chatClient = new OpenAIClient(credential, openAIOptions) - .GetChatClient("gpt-4o-mini").AsIChatClient(); +var chatClient = new ChatClient( + "gpt-4o-mini", + new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token.")), + new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }) + .AsIChatClient(); builder.Services.AddChatClient(chatClient); @@ -25,8 +26,8 @@ builder.AddAIAgent("editor", (sp, key) => new ChatClientAgent( chatClient, name: key, - instructions: "You edit short stories to improve grammar and style. You ensure the stories are less than 300 words.", - tools: [ AIFunctionFactory.Create(FormatStory) ] + instructions: "You edit short stories to improve grammar and style, ensuring the stories are less than 300 words. Once finished editing, you select a title and format the story for publishing.", + tools: [AIFunctionFactory.Create(FormatStory)] )); builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( @@ -35,21 +36,22 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); +// Register services for OpenAI responses and conversations +builder.Services.AddOpenAIResponses(); +builder.Services.AddOpenAIConversations(); + var app = builder.Build(); app.UseHttpsRedirection(); -// Expose the agents using the OpenAI Responses API +// Map endpoints for OpenAI responses and conversations app.MapOpenAIResponses(); - -// Expose the conversations using the OpenAI Conversations API app.MapOpenAIConversations(); app.Run(); -[Description("Formats the story for display.")] +[Description("Formats the story for publication, revealing its title.")] string FormatStory(string title, string story) => $""" **Title**: {title} - **Date**: {DateTime.Today.ToShortDateString()} {story} """; diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs index 99fb24ee9e0..fb80562fd7e 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs @@ -6,6 +6,7 @@ using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; using OpenAI; +using OpenAI.Chat; var builder = WebApplication.CreateBuilder(args); @@ -13,11 +14,11 @@ // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory // dotnet user-secrets set GitHubModels:Token YOUR-GITHUB-TOKEN -var credential = new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token. See README for details.")); -var openAIOptions = new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }; - -var chatClient = new OpenAIClient(credential, openAIOptions) - .GetChatClient("gpt-4o-mini").AsIChatClient(); +var chatClient = new ChatClient( + "gpt-4o-mini", + new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token.")), + new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }) + .AsIChatClient(); builder.Services.AddChatClient(chatClient); @@ -26,8 +27,8 @@ builder.AddAIAgent("editor", (sp, key) => new ChatClientAgent( chatClient, name: key, - instructions: "You edit short stories to improve grammar and style. You ensure the stories are less than 300 words.", - tools: [ AIFunctionFactory.Create(FormatStory) ] + instructions: "You edit short stories to improve grammar and style, ensuring the stories are less than 300 words. Once finished editing, you select a title and format the story for publishing.", + tools: [AIFunctionFactory.Create(FormatStory)] )); builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( @@ -36,35 +37,30 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -if (builder.Environment.IsDevelopment()) -{ - // Add the Agent Framework developer UI (DevUI) services in development environments - builder.AddDevUI(); -} +// Register services for OpenAI responses and conversations +// This is also required for DevUI +builder.Services.AddOpenAIResponses(); +builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Expose the agents using the OpenAI Responses API -// This is also needed for DevUI to function +// Map endpoints for OpenAI responses and conversations +// This is also required for DevUI app.MapOpenAIResponses(); - -// Expose the conversations using the OpenAI Conversations API -// This is also needed for DevUI to manage stateful conversations app.MapOpenAIConversations(); -if (app.Environment.IsDevelopment()) +if (builder.Environment.IsDevelopment()) { - // Map the Agent Framework developer UI to /devui/ in development environments + // Map DevUI endpoint to /devui app.MapDevUI(); } app.Run(); -[Description("Formats the story for display.")] +[Description("Formats the story for publication, revealing its title.")] string FormatStory(string title, string story) => $""" **Title**: {title} - **Date**: {DateTime.Today.ToShortDateString()} {story} """; diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs index a53b31a48e1..967d7ac819c 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs @@ -19,8 +19,8 @@ builder.AddAIAgent("editor", (sp, key) => new ChatClientAgent( chatClient, name: key, - instructions: "You edit short stories to improve grammar and style. You ensure the stories are less than 300 words.", - tools: [ AIFunctionFactory.Create(FormatStory) ] + instructions: "You edit short stories to improve grammar and style, ensuring the stories are less than 300 words. Once finished editing, you select a title and format the story for publishing.", + tools: [AIFunctionFactory.Create(FormatStory)] )); builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( @@ -29,35 +29,30 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -if (builder.Environment.IsDevelopment()) -{ - // Add the Agent Framework developer UI (DevUI) services in development environments - builder.AddDevUI(); -} +// Register services for OpenAI responses and conversations +// This is also required for DevUI +builder.Services.AddOpenAIResponses(); +builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Expose the agents using the OpenAI Responses API -// This is also needed for DevUI to function +// Map endpoints for OpenAI responses and conversations +// This is also required for DevUI app.MapOpenAIResponses(); - -// Expose the conversations using the OpenAI Conversations API -// This is also needed for DevUI to manage stateful conversations app.MapOpenAIConversations(); -if (app.Environment.IsDevelopment()) +if (builder.Environment.IsDevelopment()) { - // Map the Agent Framework developer UI to /devui/ in development environments + // Map DevUI endpoint to /devui app.MapDevUI(); } app.Run(); -[Description("Formats the story for display.")] +[Description("Formats the story for publication, revealing its title.")] string FormatStory(string title, string story) => $""" **Title**: {title} - **Date**: {DateTime.Today.ToShortDateString()} {story} """; diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs index 2bb9d029d64..7b0ea0024ff 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs @@ -14,7 +14,7 @@ // cd this-project-directory // dotnet user-secrets set OpenAI:Key YOUR-API-KEY var openAIClient = new OpenAIClient( - new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key. See README for details."))); + new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key."))); #pragma warning disable OPENAI001 // GetOpenAIResponseClient(string) is experimental and subject to change or removal in future updates. var chatClient = openAIClient.GetOpenAIResponseClient("gpt-4o-mini").AsIChatClient(); @@ -27,8 +27,8 @@ builder.AddAIAgent("editor", (sp, key) => new ChatClientAgent( chatClient, name: key, - instructions: "You edit short stories to improve grammar and style. You ensure the stories are less than 300 words.", - tools: [ AIFunctionFactory.Create(FormatStory) ] + instructions: "You edit short stories to improve grammar and style, ensuring the stories are less than 300 words. Once finished editing, you select a title and format the story for publishing.", + tools: [AIFunctionFactory.Create(FormatStory)] )); builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( @@ -37,35 +37,30 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -if (builder.Environment.IsDevelopment()) -{ - // Add the Agent Framework developer UI (DevUI) services in development environments - builder.AddDevUI(); -} +// Register services for OpenAI responses and conversations +// This is also required for DevUI +builder.Services.AddOpenAIResponses(); +builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Expose the agents using the OpenAI Responses API -// This is also needed for DevUI to function +// Map endpoints for OpenAI responses and conversations +// This is also required for DevUI app.MapOpenAIResponses(); - -// Expose the conversations using the OpenAI Conversations API -// This is also needed for DevUI to manage stateful conversations app.MapOpenAIConversations(); -if (app.Environment.IsDevelopment()) +if (builder.Environment.IsDevelopment()) { - // Map the Agent Framework developer UI to /devui/ in development environments + // Map DevUI endpoint to /devui app.MapDevUI(); } app.Run(); -[Description("Formats the story for display.")] +[Description("Formats the story for publication, revealing its title.")] string FormatStory(string title, string story) => $""" **Title**: {title} - **Date**: {DateTime.Today.ToShortDateString()} {story} """; From 9205c3f0efac8a186f6a99f87d72ba583f120867 Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Sat, 8 Nov 2025 01:38:50 -0800 Subject: [PATCH 3/9] Remove --no-devui. Fix OpenAI clients. Augment execution test sandbox ignores. --- src/ProjectTemplates/.gitignore | 4 +- src/ProjectTemplates/GeneratedContent.targets | 7 +- .../.template.config/dotnetcli.host.json | 7 - .../.template.config/ide.host.json | 8 -- .../.template.config/template.json | 18 --- .../WebApiAgent/WebApiAgent-CSharp/Program.cs | 63 ++++----- ...chSettings.json.in => launchSettings.json} | 8 -- .../WebApiAgent/WebApiAgent-CSharp/README.md | 2 - .../WebApiAgent-CSharp.csproj.in | 2 - ...Microsoft.Agents.AI.Templates.Tests.csproj | 3 + .../aiagent-webapi/Program.cs | 17 ++- .../aiagent-webapi/Program.cs | 18 +-- .../aiagent-webapi/Program.cs | 6 +- .../aiagent-webapi/Program.cs | 57 -------- .../Properties/launchSettings.json | 23 ---- .../aiagent-webapi/README.md | 127 ------------------ .../aiagent-webapi/aiagent-webapi.csproj | 18 --- .../aiagent-webapi/appsettings.json | 9 -- .../aiagent-webapi/Program.cs | 6 +- .../aiagent-webapi/Program.cs | 6 +- .../aiagent-webapi/Program.cs | 18 +-- .../WebApiAgentTemplateExecutionTests.cs | 1 - .../WebApiAgentTemplateSnapshotTests.cs | 6 - ...osoft.Extensions.AI.Templates.Tests.csproj | 3 + 24 files changed, 67 insertions(+), 370 deletions(-) rename src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/{launchSettings.json.in => launchSettings.json} (82%) delete mode 100644 test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs delete mode 100644 test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Properties/launchSettings.json delete mode 100644 test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/README.md delete mode 100644 test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/aiagent-webapi.csproj delete mode 100644 test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/appsettings.json diff --git a/src/ProjectTemplates/.gitignore b/src/ProjectTemplates/.gitignore index 10ca9b380a7..95062be5dba 100644 --- a/src/ProjectTemplates/.gitignore +++ b/src/ProjectTemplates/.gitignore @@ -12,8 +12,8 @@ package-lock.json */src/**/Directory.Build.props */src/**/ingestioncache.* -# The aichatweb template includes hard-coded launchSettings.json files in the template -!Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/*/Properties/launchSettings.json +# The project templates include hard-coded launchSettings.json files +!*/src/**/Properties/launchSettings.json # Templates include JS dependencies in dist folders. !**/dist/* diff --git a/src/ProjectTemplates/GeneratedContent.targets b/src/ProjectTemplates/GeneratedContent.targets index 8743c058127..0dc791a6d10 100644 --- a/src/ProjectTemplates/GeneratedContent.targets +++ b/src/ProjectTemplates/GeneratedContent.targets @@ -37,8 +37,8 @@ Specifies external packages that get referenced in generated template content. --> - 1.0.0-preview.251107.2 - 1.0.0-alpha.251107.2 + 1.0.0-local.251108.1 + 1.0.0-local.251108.1 9.5.1 9.5.1-preview.1.25502.11 1.0.0 @@ -94,9 +94,6 @@ - diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json index a61ccf07665..94096fec7c7 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json @@ -16,13 +16,6 @@ "longName": "managed-identity", "shortName": "" }, - "UseDevUI": { - "isHidden": "true" - }, - "DoNotUseDevUI": { - "longName": "no-devui", - "shortName": "" - }, "httpPort": { "isHidden": "true", "longName": "httpPort", diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json index 28d717c8506..f91c03c283d 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json @@ -15,14 +15,6 @@ { "id": "UseManagedIdentity", "isVisible": true - }, - { - "id": "UseDevUI", - "isVisible": true - }, - { - "id": "DoNotUseDevUI", - "isVisible": false } ] } diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json index 4d4ef9883a8..6aff00cbd63 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json @@ -93,20 +93,6 @@ "isEnabled": "(AiServiceProvider == \"azureopenai\")", "description": "Use managed identity to access Azure services" }, - "UseDevUI": { - "type": "parameter", - "displayName": "Enable the Agent Framework developer UI", - "datatype": "bool", - "defaultValue": "true", - "description": "Add the Agent Framework developer UI for use in the development environment" - }, - "DoNotUseDevUI": { - "type": "parameter", - "displayName": "Disable the Agent Framework developer UI", - "datatype": "bool", - "defaultValue": "false", - "description": "Do not add the Agent Framework developer UI" - }, "ChatModel": { "type": "parameter", "displayName": "Model/deployment for chat completions. Example: gpt-4o-mini", @@ -116,10 +102,6 @@ "type": "computed", "value": "(UseManagedIdentity)" }, - "IsDevUIEnabled": { - "type": "computed", - "value": "(UseDevUI && !DoNotUseDevUI)" - }, "IsAzureOpenAI": { "type": "computed", "value": "(AiServiceProvider == \"azureopenai\")" diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs index 058b9b1842b..b8bdce11f3f 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs @@ -8,18 +8,17 @@ using Azure.Identity; #endif using Microsoft.Agents.AI; -#if (IsDevUIEnabled) using Microsoft.Agents.AI.DevUI; -#endif using Microsoft.Agents.AI.Hosting; using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; #if (IsOllama) using OllamaSharp; -#elif (IsGHModels || IsOpenAI || IsAzureOpenAI) +#endif +#if (IsGHModels || IsAzureOpenAI) using OpenAI; #endif -#if (IsGHModels) +#if (IsGHModels || IsOpenAI || IsAzureOpenAI) using OpenAI.Chat; #endif @@ -35,21 +34,15 @@ new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token.")), new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }) .AsIChatClient(); -#elif (IsOllama) -// You will need to have Ollama running locally with the llama3.2 model installed -// Visit https://ollama.com for installation instructions -var chatClient = new OllamaApiClient(new Uri("http://localhost:11434"), "llama3.2"); #elif (IsOpenAI) // You will need to set the API key to your own value // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory // dotnet user-secrets set OpenAI:Key YOUR-API-KEY -var openAIClient = new OpenAIClient( - new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key."))); - -#pragma warning disable OPENAI001 // GetOpenAIResponseClient(string) is experimental and subject to change or removal in future updates. -var chatClient = openAIClient.GetOpenAIResponseClient("gpt-4o-mini").AsIChatClient(); -#pragma warning restore OPENAI001 +var chatClient = new ChatClient( + "gpt-4o-mini", + new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key."))) + .AsIChatClient(); #elif (IsAzureOpenAI) // You will need to set the endpoint to your own value // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: @@ -59,20 +52,26 @@ // dotnet user-secrets set AzureOpenAI:Key YOUR-API-KEY #endif var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint.")), "/openai/v1"); -#if (IsManagedIdentity) -#pragma warning disable OPENAI001 // OpenAIClient(AuthenticationPolicy, OpenAIClientOptions) and GetOpenAIResponseClient(string) are experimental and subject to change or removal in future updates. -var azureOpenAI = new OpenAIClient( - new BearerTokenPolicy(new DefaultAzureCredential(), "https://ai.azure.com/.default"), - new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }); - -#elif (!IsManagedIdentity) -var openAIOptions = new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }; -var azureOpenAI = new OpenAIClient(new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key.")), openAIOptions); -#pragma warning disable OPENAI001 // GetOpenAIResponseClient(string) is experimental and subject to change or removal in future updates. -#endif -var chatClient = azureOpenAI.GetOpenAIResponseClient("gpt-4o-mini").AsIChatClient(); +#if (IsManagedIdentity) +#pragma warning disable OPENAI001 // The overload accepting an AuthenticationPolicy is experimental and may change or be removed in future releases. +var chatClient = new ChatClient( + "gpt-4o-mini", + new BearerTokenPolicy(new DefaultAzureCredential(), "https://ai.azure.com/.default"), + new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }) + .AsIChatClient(); #pragma warning restore OPENAI001 +#else +var chatClient = new ChatClient( + "gpt-4o-mini", + new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key.")), + new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }) + .AsIChatClient(); +#endif +#elif (IsOllama) +// You will need to have Ollama running locally with the llama3.2 model installed +// Visit https://ollama.com for installation instructions +var chatClient = new OllamaApiClient(new Uri("http://localhost:11434"), "llama3.2"); #endif builder.Services.AddChatClient(chatClient); @@ -92,31 +91,23 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -// Register services for OpenAI responses and conversations -#if (IsDevUIEnabled) -// This is also required for DevUI -#endif +// Register services for OpenAI responses and conversations (also required for DevUI) builder.Services.AddOpenAIResponses(); builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Map endpoints for OpenAI responses and conversations -#if (IsDevUIEnabled) -// This is also required for DevUI -#endif +// Map endpoints for OpenAI responses and conversations (also required for DevUI) app.MapOpenAIResponses(); app.MapOpenAIConversations(); -#if (IsDevUIEnabled) if (builder.Environment.IsDevelopment()) { // Map DevUI endpoint to /devui app.MapDevUI(); } -#endif app.Run(); [Description("Formats the story for publication, revealing its title.")] diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json.in b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json similarity index 82% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json.in rename to src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json index c6738271d14..27165ad4a22 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json.in +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json @@ -4,12 +4,8 @@ "http": { "commandName": "Project", "dotnetRunMessages": true, -//#if (IsDevUIEnabled) "launchBrowser": true, "launchUrl": "devui/", -//#else - "launchBrowser": false, -//#endif "applicationUrl": "http://localhost:5056", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -18,12 +14,8 @@ "https": { "commandName": "Project", "dotnetRunMessages": true, -//#if (IsDevUIEnabled) "launchBrowser": true, "launchUrl": "devui/", -//#else - "launchBrowser": false, -//#endif "applicationUrl": "https://localhost:7041;http://localhost:5056", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md index 0d8ed99e232..f4ea3c26625 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md @@ -165,10 +165,8 @@ The application will start and listen on: The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. - In development environments, a `/devui/` route is mapped to the Agent Framework development UI (DevUI), and when the app is launched through an IDE a browser will open to this URL. DevUI provides a web-based UI for interacting with agents and workflows. DevUI operates as an OpenAI-compatible client using the Responses and Conversations endpoints. - ## How It Works This application demonstrates Agent Framework with: diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in index ac18e7ced67..5da32659a61 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in +++ b/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in @@ -9,9 +9,7 @@ - - diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Microsoft.Agents.AI.Templates.Tests.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Microsoft.Agents.AI.Templates.Tests.csproj index 732ecb74f15..4dbaace47b9 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Microsoft.Agents.AI.Templates.Tests.csproj +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Microsoft.Agents.AI.Templates.Tests.csproj @@ -17,12 +17,15 @@ + + + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs index 7db2e3c2795..720e0a381f0 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs @@ -6,6 +6,7 @@ using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; using OpenAI; +using OpenAI.Chat; var builder = WebApplication.CreateBuilder(args); @@ -15,12 +16,12 @@ // dotnet user-secrets set AzureOpenAI:Endpoint https://YOUR-DEPLOYMENT-NAME.openai.azure.com // dotnet user-secrets set AzureOpenAI:Key YOUR-API-KEY var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint.")), "/openai/v1"); -var openAIOptions = new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }; -var azureOpenAI = new OpenAIClient(new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key.")), openAIOptions); -#pragma warning disable OPENAI001 // GetOpenAIResponseClient(string) is experimental and subject to change or removal in future updates. -var chatClient = azureOpenAI.GetOpenAIResponseClient("gpt-4o-mini").AsIChatClient(); -#pragma warning restore OPENAI001 +var chatClient = new ChatClient( + "gpt-4o-mini", + new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key.")), + new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }) + .AsIChatClient(); builder.Services.AddChatClient(chatClient); @@ -39,16 +40,14 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -// Register services for OpenAI responses and conversations -// This is also required for DevUI +// Register services for OpenAI responses and conversations (also required for DevUI) builder.Services.AddOpenAIResponses(); builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Map endpoints for OpenAI responses and conversations -// This is also required for DevUI +// Map endpoints for OpenAI responses and conversations (also required for DevUI) app.MapOpenAIResponses(); app.MapOpenAIConversations(); diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs index 0a7b28e6d6d..02d8d079340 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs @@ -7,6 +7,7 @@ using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; using OpenAI; +using OpenAI.Chat; var builder = WebApplication.CreateBuilder(args); @@ -15,12 +16,13 @@ // cd this-project-directory // dotnet user-secrets set AzureOpenAI:Endpoint https://YOUR-DEPLOYMENT-NAME.openai.azure.com var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint.")), "/openai/v1"); -#pragma warning disable OPENAI001 // OpenAIClient(AuthenticationPolicy, OpenAIClientOptions) and GetOpenAIResponseClient(string) are experimental and subject to change or removal in future updates. -var azureOpenAI = new OpenAIClient( - new BearerTokenPolicy(new DefaultAzureCredential(), "https://ai.azure.com/.default"), - new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }); -var chatClient = azureOpenAI.GetOpenAIResponseClient("gpt-4o-mini").AsIChatClient(); +#pragma warning disable OPENAI001 // The overload accepting an AuthenticationPolicy is experimental and may change or be removed in future releases. +var chatClient = new ChatClient( + "gpt-4o-mini", + new BearerTokenPolicy(new DefaultAzureCredential(), "https://ai.azure.com/.default"), + new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }) + .AsIChatClient(); #pragma warning restore OPENAI001 builder.Services.AddChatClient(chatClient); @@ -40,16 +42,14 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -// Register services for OpenAI responses and conversations -// This is also required for DevUI +// Register services for OpenAI responses and conversations (also required for DevUI) builder.Services.AddOpenAIResponses(); builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Map endpoints for OpenAI responses and conversations -// This is also required for DevUI +// Map endpoints for OpenAI responses and conversations (also required for DevUI) app.MapOpenAIResponses(); app.MapOpenAIConversations(); diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs index fb80562fd7e..b71e007bb7a 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs @@ -37,16 +37,14 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -// Register services for OpenAI responses and conversations -// This is also required for DevUI +// Register services for OpenAI responses and conversations (also required for DevUI) builder.Services.AddOpenAIResponses(); builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Map endpoints for OpenAI responses and conversations -// This is also required for DevUI +// Map endpoints for OpenAI responses and conversations (also required for DevUI) app.MapOpenAIResponses(); app.MapOpenAIConversations(); diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs deleted file mode 100644 index 900061e9694..00000000000 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Program.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.ClientModel; -using System.ComponentModel; -using Microsoft.Agents.AI; -using Microsoft.Agents.AI.Hosting; -using Microsoft.Agents.AI.Workflows; -using Microsoft.Extensions.AI; -using OpenAI; -using OpenAI.Chat; - -var builder = WebApplication.CreateBuilder(args); - -// You will need to set the token to your own value -// You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: -// cd this-project-directory -// dotnet user-secrets set GitHubModels:Token YOUR-GITHUB-TOKEN -var chatClient = new ChatClient( - "gpt-4o-mini", - new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token.")), - new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }) - .AsIChatClient(); - -builder.Services.AddChatClient(chatClient); - -builder.AddAIAgent("writer", "You write short stories (300 words or less) about the specified topic."); - -builder.AddAIAgent("editor", (sp, key) => new ChatClientAgent( - chatClient, - name: key, - instructions: "You edit short stories to improve grammar and style, ensuring the stories are less than 300 words. Once finished editing, you select a title and format the story for publishing.", - tools: [AIFunctionFactory.Create(FormatStory)] -)); - -builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( - workflowName: key, - sp.GetRequiredKeyedService("writer"), - sp.GetRequiredKeyedService("editor") -)).AddAsAIAgent(); - -// Register services for OpenAI responses and conversations -builder.Services.AddOpenAIResponses(); -builder.Services.AddOpenAIConversations(); - -var app = builder.Build(); -app.UseHttpsRedirection(); - -// Map endpoints for OpenAI responses and conversations -app.MapOpenAIResponses(); -app.MapOpenAIConversations(); - -app.Run(); - -[Description("Formats the story for publication, revealing its title.")] -string FormatStory(string title, string story) => $""" - **Title**: {title} - - {story} - """; diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Properties/launchSettings.json deleted file mode 100644 index 61e7634bcbb..00000000000 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/Properties/launchSettings.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "http://localhost:9999", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "https://localhost:9999;http://localhost:9999", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/README.md deleted file mode 100644 index b400819b591..00000000000 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/README.md +++ /dev/null @@ -1,127 +0,0 @@ -# AI Agent Web API - -This is an AI Agent Web API application created from the `aiagent-webapi` template. This template is currently in a preview stage. If you have feedback, please take a [brief survey](https://aka.ms/dotnet/aiagent-webapi/preview1/survey). - -## Prerequisites - -- A GitHub Models API token (free to get started) - -## Getting Started - -### 1. Configure Your AI Service - -#### GitHub Models Configuration - -This application uses GitHub Models (model: gpt-4o-mini) for AI functionality. You'll need to configure your GitHub Models API token: - -**Option A: Using User Secrets (Recommended for Development)** - -```bash -dotnet user-secrets set "GitHubModels:Token" "your-github-models-token-here" -``` - -**Option B: Using Environment Variables** - -Set the `GitHubModels__Token` environment variable: - -- **Windows (PowerShell)**: - ```powershell - $env:GitHubModels__Token = "your-github-models-token-here" - ``` - -- **Linux/macOS**: - ```bash - export GitHubModels__Token="your-github-models-token-here" - ``` - -#### Get a GitHub Models Token - -1. Visit [GitHub Models](https://github.com/marketplace/models) -2. Sign in with your GitHub account -3. Select a model (e.g., gpt-4o-mini) -4. Click "Get API Key" or follow the authentication instructions -5. Copy your personal access token - - -### 2. Run the Application - -```bash -dotnet run -lp https -``` - -The application will start and listen on: -- HTTP: `http://localhost:9999` -- HTTPS: `https://localhost:9999` - -### 3. Test the Application - -The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. - -## How It Works - -This application demonstrates Agent Framework with: - -1. **Writer Agent**: Writes short stories (300 words or less) about specified topics -2. **Editor Agent**: Edits stories to improve grammar and style, ensuring they stay under 300 words -3. **Publisher Workflow Agent**: A sequential workflow agent that combines the writer and editor agents - -The agents are exposed through OpenAI-compatible API endpoints, making them easy to integrate with existing tools and applications. - -## Template Parameters - -When creating a new project, you can customize it using template parameters: - -```bash -# Specify AI service provider -dotnet new aiagent-webapi --provider azureopenai - -# Specify a custom chat model -dotnet new aiagent-webapi --chat-model gpt-4o - -# Use API key authentication for Azure OpenAI -dotnet new aiagent-webapi --provider azureopenai --managed-identity false - -# Use Ollama with a different model -dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 -``` - -### Available Parameters - -- **`--provider`**: Choose the AI service provider - - `githubmodels` (default) - GitHub Models - - `azureopenai` - Azure OpenAI - - `openai` - OpenAI Platform - - `ollama` - Ollama (local development) - -- **`--chat-model`**: Specify the chat model/deployment name - - Default for OpenAI/Azure OpenAI/GitHub Models: `gpt-4o-mini` - - Default for Ollama: `llama3.2` - -- **`--managed-identity`**: Use managed identity for Azure services (default: `true`) - - Only applicable when `--provider azureopenai` - -- **`--framework`**: Target framework (default: `net10.0`) - - Options: `net10.0`, `net9.0`, `net8.0` - -## Project Structure - -- `Program.cs` - Application entry point and configuration -- `appsettings.json` - Application configuration -- `Properties/launchSettings.json` - Launch profiles for development - -## Learn More - -- [AI apps for .NET developers](https://learn.microsoft.com/dotnet/ai) -- [Microsoft Agent Framework Documentation](https://aka.ms/dotnet/agent-framework/docs) -- [GitHub Models](https://github.com/marketplace/models) - -## Troubleshooting - -**Problem**: Application fails with "Missing configuration: GitHubModels:Token" - -**Solution**: Make sure you've configured your GitHub Models API token using one of the methods described above. - -**Problem**: API requests fail with authentication errors - -**Solution**: Verify your GitHub Models token is valid and hasn't expired. You may need to regenerate it from the GitHub Models website. - diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/aiagent-webapi.csproj deleted file mode 100644 index 352213bdc90..00000000000 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/aiagent-webapi.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - net10.0 - enable - enable - secret - - - - - - - - - - - diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/appsettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/appsettings.json deleted file mode 100644 index 223027717b4..00000000000 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DisableDevUI.verified/aiagent-webapi/appsettings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs index fb80562fd7e..b71e007bb7a 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs @@ -37,16 +37,14 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -// Register services for OpenAI responses and conversations -// This is also required for DevUI +// Register services for OpenAI responses and conversations (also required for DevUI) builder.Services.AddOpenAIResponses(); builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Map endpoints for OpenAI responses and conversations -// This is also required for DevUI +// Map endpoints for OpenAI responses and conversations (also required for DevUI) app.MapOpenAIResponses(); app.MapOpenAIConversations(); diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs index 967d7ac819c..2e9c6d25484 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs @@ -29,16 +29,14 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -// Register services for OpenAI responses and conversations -// This is also required for DevUI +// Register services for OpenAI responses and conversations (also required for DevUI) builder.Services.AddOpenAIResponses(); builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Map endpoints for OpenAI responses and conversations -// This is also required for DevUI +// Map endpoints for OpenAI responses and conversations (also required for DevUI) app.MapOpenAIResponses(); app.MapOpenAIConversations(); diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs index 7b0ea0024ff..0467783dfab 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs @@ -5,7 +5,7 @@ using Microsoft.Agents.AI.Hosting; using Microsoft.Agents.AI.Workflows; using Microsoft.Extensions.AI; -using OpenAI; +using OpenAI.Chat; var builder = WebApplication.CreateBuilder(args); @@ -13,12 +13,10 @@ // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory // dotnet user-secrets set OpenAI:Key YOUR-API-KEY -var openAIClient = new OpenAIClient( - new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key."))); - -#pragma warning disable OPENAI001 // GetOpenAIResponseClient(string) is experimental and subject to change or removal in future updates. -var chatClient = openAIClient.GetOpenAIResponseClient("gpt-4o-mini").AsIChatClient(); -#pragma warning restore OPENAI001 +var chatClient = new ChatClient( + "gpt-4o-mini", + new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key."))) + .AsIChatClient(); builder.Services.AddChatClient(chatClient); @@ -37,16 +35,14 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -// Register services for OpenAI responses and conversations -// This is also required for DevUI +// Register services for OpenAI responses and conversations (also required for DevUI) builder.Services.AddOpenAIResponses(); builder.Services.AddOpenAIConversations(); var app = builder.Build(); app.UseHttpsRedirection(); -// Map endpoints for OpenAI responses and conversations -// This is also required for DevUI +// Map endpoints for OpenAI responses and conversations (also required for DevUI) app.MapOpenAIResponses(); app.MapOpenAIConversations(); diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs index e18f19430f4..f9dc4861c65 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs @@ -55,7 +55,6 @@ public async Task CreateRestoreAndBuild(params string[] args) private static readonly (string name, string[] values)[] _templateOptions = [ ("--provider", ["azureopenai", "githubmodels", "ollama", "openai"]), ("--managed-identity", ["true", "false"]), - ("--no-devui", ["true", "false"]), ]; private static IEnumerable GetFilteredTemplateOptions(params string[] filter) diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs index b5b118248d2..fb907ca36fd 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs @@ -73,12 +73,6 @@ public async Task Ollama() await TestTemplateCoreAsync(scenarioName: nameof(Ollama), templateArgs: ["--provider", "ollama"]); } - [Fact] - public async Task DisableDevUI() - { - await TestTemplateCoreAsync(scenarioName: nameof(DisableDevUI), templateArgs: ["--no-devui"]); - } - private async Task TestTemplateCoreAsync(string scenarioName, IEnumerable? templateArgs = null) { string workingDir = TestUtils.CreateTemporaryFolder(); diff --git a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj index bd83d4fa93e..11a0e4b736f 100644 --- a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj +++ b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj @@ -21,12 +21,15 @@ + + + From 9211fa4f6a73ca18868e88a16fc862ec2b01769b Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Mon, 10 Nov 2025 17:06:48 -0800 Subject: [PATCH 4/9] Rename to Microsoft.Agents.AI.ProjectTemplates --- src/ProjectTemplates/GeneratedContent.targets | 2 +- .../Microsoft.Agents.AI.ProjectTemplates.csproj} | 0 .../README.md | 2 +- .../THIRD-PARTY-NOTICES.TXT | 0 .../.template.config/dotnetcli.host.json | 0 .../.template.config/ide.host.json | 0 .../.template.config/ide/agent-framework.ico | Bin .../.template.config/template.json | 2 +- .../src/WebApiAgent/WebApiAgent-CSharp/Program.cs | 0 .../Properties/launchSettings.json | 0 .../src/WebApiAgent/WebApiAgent-CSharp/README.md | 0 .../WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in | 0 .../WebApiAgent/WebApiAgent-CSharp/appsettings.json | 0 src/ProjectTemplates/README.md | 8 ++++---- ...crosoft.Agents.AI.ProjectTemplates.Tests.csproj} | 2 +- .../ProjectRootHelper.cs | 0 .../README.md | 4 ++-- .../Snapshots/README.md | 0 .../aiagent-webapi/Program.cs | 0 .../aiagent-webapi/Properties/launchSettings.json | 0 .../aiagent-webapi/README.md | 0 .../aiagent-webapi/aiagent-webapi.csproj | 0 .../aiagent-webapi/appsettings.json | 0 .../aiagent-webapi/Program.cs | 0 .../aiagent-webapi/Properties/launchSettings.json | 0 .../aiagent-webapi/README.md | 0 .../aiagent-webapi/aiagent-webapi.csproj | 0 .../aiagent-webapi/appsettings.json | 0 .../aiagent-webapi/Program.cs | 0 .../aiagent-webapi/Properties/launchSettings.json | 0 .../aiagent-webapi/README.md | 0 .../aiagent-webapi/aiagent-webapi.csproj | 0 .../aiagent-webapi/appsettings.json | 0 .../aiagent-webapi/Program.cs | 0 .../aiagent-webapi/Properties/launchSettings.json | 0 .../aiagent-webapi/README.md | 0 .../aiagent-webapi/aiagent-webapi.csproj | 0 .../aiagent-webapi/appsettings.json | 0 .../aiagent-webapi/Program.cs | 0 .../aiagent-webapi/Properties/launchSettings.json | 0 .../aiagent-webapi/README.md | 0 .../aiagent-webapi/aiagent-webapi.csproj | 0 .../aiagent-webapi/appsettings.json | 0 .../aiagent-webapi/Program.cs | 0 .../aiagent-webapi/Properties/launchSettings.json | 0 .../aiagent-webapi/README.md | 0 .../aiagent-webapi/aiagent-webapi.csproj | 0 .../aiagent-webapi/appsettings.json | 0 .../WebApiAgentTemplateExecutionTests.cs | 4 ++-- .../WebApiAgentTemplateSnapshotTests.cs | 6 +++--- 50 files changed, 15 insertions(+), 15 deletions(-) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates/Microsoft.Agents.AI.Templates.csproj => Microsoft.Agents.AI.ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.csproj} (100%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/README.md (57%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/THIRD-PARTY-NOTICES.TXT (100%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json (100%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json (100%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide/agent-framework.ico (100%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json (98%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/src/WebApiAgent/WebApiAgent-CSharp/Program.cs (100%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json (100%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/src/WebApiAgent/WebApiAgent-CSharp/README.md (100%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in (100%) rename src/ProjectTemplates/{Microsoft.Agents.AI.Templates => Microsoft.Agents.AI.ProjectTemplates}/src/WebApiAgent/WebApiAgent-CSharp/appsettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests/Microsoft.Agents.AI.Templates.Tests.csproj => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Microsoft.Agents.AI.ProjectTemplates.Tests.csproj} (92%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/ProjectRootHelper.cs (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/README.md (75%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/README.md (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Properties/launchSettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/aiagent-webapi.csproj (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/appsettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Properties/launchSettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/appsettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Properties/launchSettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/aiagent-webapi.csproj (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/appsettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Properties/launchSettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/aiagent-webapi.csproj (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/appsettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Properties/launchSettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/appsettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Properties/launchSettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/aiagent-webapi.csproj (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/appsettings.json (100%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/WebApiAgentTemplateExecutionTests.cs (97%) rename test/ProjectTemplates/{Microsoft.Agents.AI.Templates.IntegrationTests => Microsoft.Agents.AI.ProjectTemplates.IntegrationTests}/WebApiAgentTemplateSnapshotTests.cs (96%) diff --git a/src/ProjectTemplates/GeneratedContent.targets b/src/ProjectTemplates/GeneratedContent.targets index 0dc791a6d10..112cb900824 100644 --- a/src/ProjectTemplates/GeneratedContent.targets +++ b/src/ProjectTemplates/GeneratedContent.targets @@ -9,7 +9,7 @@ --> <_LocalChatTemplateVariant>aspire - <_WebApiAgentRoot>$(MSBuildThisFileDirectory)Microsoft.Agents.AI.Templates\src\WebApiAgent\ + <_WebApiAgentRoot>$(MSBuildThisFileDirectory)Microsoft.Agents.AI.ProjectTemplates\src\WebApiAgent\ <_ChatWithCustomDataContentRoot>$(MSBuildThisFileDirectory)Microsoft.Extensions.AI.Templates\src\ChatWithCustomData\ <_McpServerContentRoot>$(MSBuildThisFileDirectory)Microsoft.Extensions.AI.Templates\src\McpServer\ diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/Microsoft.Agents.AI.Templates.csproj b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.csproj similarity index 100% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/Microsoft.Agents.AI.Templates.csproj rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.csproj diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/README.md b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/README.md similarity index 57% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/README.md rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/README.md index 59056439776..0df92140794 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/README.md +++ b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/README.md @@ -1,3 +1,3 @@ -# Microsoft.Agents.AI.Templates +# Microsoft.Agents.AI.ProjectTemplates Provides project templates for Microsoft.Agents.AI. diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/THIRD-PARTY-NOTICES.TXT b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/THIRD-PARTY-NOTICES.TXT similarity index 100% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/THIRD-PARTY-NOTICES.TXT rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/THIRD-PARTY-NOTICES.TXT diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json similarity index 100% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json similarity index 100% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide/agent-framework.ico b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide/agent-framework.ico similarity index 100% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide/agent-framework.ico rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide/agent-framework.ico diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json similarity index 98% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json index 6aff00cbd63..dfcaf42475c 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json +++ b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/template", "author": "Microsoft", "classifications": [ "Common", "AI", "API", "Web", "Web API", "WebAPI", "Service" ], - "identity": "Microsoft.Agents.AI.Templates.WebApiAgent.CSharp", + "identity": "Microsoft.Agents.AI.ProjectTemplates.WebApiAgent.CSharp", "name": "AI Agent Web API", "description": "A project template for creating an AI Agent Web API application.", "shortName": "aiagent-webapi", diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs similarity index 100% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json similarity index 100% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/Properties/launchSettings.json diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md similarity index 100% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in similarity index 100% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/appsettings.json b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/appsettings.json similarity index 100% rename from src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/appsettings.json rename to src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/appsettings.json diff --git a/src/ProjectTemplates/README.md b/src/ProjectTemplates/README.md index c3fa66cf6ff..f527c08d74e 100644 --- a/src/ProjectTemplates/README.md +++ b/src/ProjectTemplates/README.md @@ -35,7 +35,7 @@ By default the templates use just-built versions of library packages from this r Once the library packages are built, the template packages can be built with references to the local package versions using the following commands: ```pwsh -.\build.cmd -pack -projects .\src\ProjectTemplates\Microsoft.Agents.AI.Templates\Microsoft.Extensions.AI.Templates.csproj +.\build.cmd -pack -projects .\src\ProjectTemplates\Microsoft.Agents.AI.ProjectTemplates\Microsoft.Extensions.AI.Templates.csproj .\build.cmd -pack -projects .\src\ProjectTemplates\Microsoft.Extensions.AI.Templates\Microsoft.Extensions.AI.Templates.csproj ``` @@ -44,7 +44,7 @@ Once the library packages are built, the template packages can be built with ref The templates can also be built to reference pinned versions of the library packages. This approach is used when a templates package is updated off-cycle from the library packages. The pinned versions are hard-coded in the `GeneratedContent.targets` file in this directory. To build the templates package using the pinned versions, run: ```pwsh -.\build.cmd -pack -projects .\src\ProjectTemplates\Microsoft.Agents.AI.Templates\Microsoft.Agents.AI.Templates.csproj /p:TemplateUsePinnedPackageVersions=true +.\build.cmd -pack -projects .\src\ProjectTemplates\Microsoft.Agents.AI.ProjectTemplates\Microsoft.Agents.AI.ProjectTemplates.csproj /p:TemplateUsePinnedPackageVersions=true .\build.cmd -pack -projects .\src\ProjectTemplates\Microsoft.Extensions.AI.Templates\Microsoft.Extensions.AI.Templates.csproj /p:TemplateUsePinnedPackageVersions=true ``` @@ -62,7 +62,7 @@ After building the templates package using one of the approaches above, it can b ```pwsh # Uninstall any existing version of the templates -dotnet new uninstall Microsoft.Agents.AI.Templates +dotnet new uninstall Microsoft.Agents.AI.ProjectTemplates dotnet new uninstall Microsoft.Extensions.AI.Templates # Clear the packages from the NuGet cache since the local package version does not change @@ -70,7 +70,7 @@ Remove-Item ~\.nuget\packages\Microsoft.Agents.AI* -Recurse -Force Remove-Item ~\.nuget\packages\Microsoft.Extensions.AI* -Recurse -Force # Install the templates from the generated .nupkg file (in the artifacts/packages folder) -dotnet new install .\artifacts\packages\Debug\Shipping\Microsoft.Agents.AI.Templates*.nupkg +dotnet new install .\artifacts\packages\Debug\Shipping\Microsoft.Agents.AI.ProjectTemplates*.nupkg dotnet new install .\artifacts\packages\Debug\Shipping\Microsoft.Extensions.AI.Templates*.nupkg ``` diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Microsoft.Agents.AI.Templates.Tests.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Microsoft.Agents.AI.ProjectTemplates.Tests.csproj similarity index 92% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Microsoft.Agents.AI.Templates.Tests.csproj rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Microsoft.Agents.AI.ProjectTemplates.Tests.csproj index 4dbaace47b9..1c529dff3f3 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Microsoft.Agents.AI.Templates.Tests.csproj +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Microsoft.Agents.AI.ProjectTemplates.Tests.csproj @@ -1,7 +1,7 @@ - Tests for Microsoft.Agents.AI.Templates. + Tests for Microsoft.Agents.AI.ProjectTemplates. false true diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/ProjectRootHelper.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/ProjectRootHelper.cs similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/ProjectRootHelper.cs rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/ProjectRootHelper.cs diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/README.md similarity index 75% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/README.md rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/README.md index babe77c2f9e..259022bfa73 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/README.md @@ -1,6 +1,6 @@ -# Microsoft.Agents.AI.Templates tests +# Microsoft.Agents.AI.ProjectTemplates tests -Contains snapshot and execution tests for `Microsoft.Agents.AI.Templates`. +Contains snapshot and execution tests for `Microsoft.Agents.AI.ProjectTemplates`. To update test snapshots, install and run the `DiffEngineTray` tool following [these instructions](https://github.com/VerifyTests/DiffEngine/blob/main/docs/tray.md), run the snapshot tests either in VS or using `dotnet test`, and use `DiffEngineTray` to accept or discard changes. diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/README.md similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/README.md rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/README.md diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Properties/launchSettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Properties/launchSettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Properties/launchSettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/aiagent-webapi.csproj similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/aiagent-webapi.csproj rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/aiagent-webapi.csproj diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/appsettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/appsettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/appsettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/appsettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Properties/launchSettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Properties/launchSettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Properties/launchSettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/appsettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/appsettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/appsettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/appsettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Properties/launchSettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Properties/launchSettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Properties/launchSettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/aiagent-webapi.csproj similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/aiagent-webapi.csproj rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/aiagent-webapi.csproj diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/appsettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/appsettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/appsettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/appsettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Properties/launchSettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Properties/launchSettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Properties/launchSettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/aiagent-webapi.csproj similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/aiagent-webapi.csproj rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/aiagent-webapi.csproj diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/appsettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/appsettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/appsettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/appsettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Program.cs diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Properties/launchSettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Properties/launchSettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Properties/launchSettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/appsettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/appsettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/appsettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/appsettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Properties/launchSettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Properties/launchSettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Properties/launchSettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/aiagent-webapi.csproj similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/aiagent-webapi.csproj rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/aiagent-webapi.csproj diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/appsettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/appsettings.json similarity index 100% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/appsettings.json rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/appsettings.json diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs similarity index 97% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs index f9dc4861c65..2462a7bd002 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/WebApiAgentTemplateExecutionTests.cs @@ -8,7 +8,7 @@ using Xunit; using Xunit.Abstractions; -namespace Microsoft.Agents.AI.Templates.Tests; +namespace Microsoft.Agents.AI.ProjectTemplates.Tests; /// /// Contains execution tests for the "AI Agent Web API" template. @@ -30,7 +30,7 @@ public WebApiAgentTemplateExecutionTests(TemplateExecutionTestFixture fixture, I public static TemplateExecutionTestConfiguration Configuration { get; } = new() { - TemplatePackageName = "Microsoft.Agents.AI.Templates", + TemplatePackageName = "Microsoft.Agents.AI.ProjectTemplates", TestOutputFolderPrefix = "WebApiAgent" }; diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs similarity index 96% rename from test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs rename to test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs index fb907ca36fd..dce7ca19646 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/WebApiAgentTemplateSnapshotTests.cs @@ -12,11 +12,11 @@ using Xunit; using Xunit.Abstractions; -namespace Microsoft.Agents.AI.Templates.Tests; +namespace Microsoft.Agents.AI.ProjectTemplates.Tests; public class WebApiAgentTemplateSnapshotTests { - // Keep the exclude patterns below in sync with those in Microsoft.Agents.AI.Templates.csproj. + // Keep the exclude patterns below in sync with those in Microsoft.Agents.AI.ProjectTemplates.csproj. private static readonly string[] _verificationExcludePatterns = [ "**/bin/**", "**/obj/**", @@ -79,7 +79,7 @@ private async Task TestTemplateCoreAsync(string scenarioName, IEnumerable Date: Mon, 10 Nov 2025 17:21:55 -0800 Subject: [PATCH 5/9] Set Microsoft.Agents.AI package versions --- src/ProjectTemplates/GeneratedContent.targets | 4 ++-- .../Microsoft.Agents.AI.ProjectTemplates.csproj | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ProjectTemplates/GeneratedContent.targets b/src/ProjectTemplates/GeneratedContent.targets index 112cb900824..9014b892d98 100644 --- a/src/ProjectTemplates/GeneratedContent.targets +++ b/src/ProjectTemplates/GeneratedContent.targets @@ -37,8 +37,8 @@ Specifies external packages that get referenced in generated template content. --> - 1.0.0-local.251108.1 - 1.0.0-local.251108.1 + 1.0.0-preview.251110.2 + 1.0.0-alpha.251110.2 9.5.1 9.5.1-preview.1.25502.11 1.0.0 diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.csproj b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.csproj index ca7eeb7faf0..62bebc3ee06 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.csproj +++ b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.csproj @@ -7,7 +7,14 @@ dotnet-new;templates;ai;agent preview - 1 + + + 1 + 0 + 0 + preview + preview.251110.2 + AI 0 0 From 0e4e4d915dd7f3575dae45bf1db25b35bb7783ea Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Mon, 10 Nov 2025 19:27:21 -0800 Subject: [PATCH 6/9] Simplify the GitHub and OpenAI key config vars for aiagent-webapi --- .../WebApiAgent/WebApiAgent-CSharp/Program.cs | 12 +++++------ .../WebApiAgent/WebApiAgent-CSharp/README.md | 20 +++++++++---------- .../aiagent-webapi/Program.cs | 4 ++-- .../aiagent-webapi/Program.cs | 2 +- .../aiagent-webapi/Program.cs | 4 ++-- .../aiagent-webapi/README.md | 10 +++++----- .../aiagent-webapi/Program.cs | 4 ++-- .../aiagent-webapi/README.md | 10 +++++----- .../aiagent-webapi/Program.cs | 4 ++-- .../aiagent-webapi/README.md | 10 +++++----- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs index b8bdce11f3f..743658f6c8a 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs +++ b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs @@ -28,20 +28,20 @@ // You will need to set the token to your own value // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory -// dotnet user-secrets set GitHubModels:Token YOUR-GITHUB-TOKEN +// dotnet user-secrets set "GITHUB_TOKEN" "your-github-models-token-here" var chatClient = new ChatClient( "gpt-4o-mini", - new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token.")), + new ApiKeyCredential(builder.Configuration["GITHUB_TOKEN"] ?? throw new InvalidOperationException("Missing configuration: GITHUB_TOKEN")), new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }) .AsIChatClient(); #elif (IsOpenAI) // You will need to set the API key to your own value // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory -// dotnet user-secrets set OpenAI:Key YOUR-API-KEY +// dotnet user-secrets set "OPENAI_KEY" "your-openai-api-key-here" var chatClient = new ChatClient( "gpt-4o-mini", - new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key."))) + new ApiKeyCredential(builder.Configuration["OPENAI_KEY"] ?? throw new InvalidOperationException("Missing configuration: OPENAI_KEY"))) .AsIChatClient(); #elif (IsAzureOpenAI) // You will need to set the endpoint to your own value @@ -51,7 +51,7 @@ #if (!IsManagedIdentity) // dotnet user-secrets set AzureOpenAI:Key YOUR-API-KEY #endif -var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint.")), "/openai/v1"); +var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint")), "/openai/v1"); #if (IsManagedIdentity) #pragma warning disable OPENAI001 // The overload accepting an AuthenticationPolicy is experimental and may change or be removed in future releases. @@ -64,7 +64,7 @@ #else var chatClient = new ChatClient( "gpt-4o-mini", - new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key.")), + new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key")), new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }) .AsIChatClient(); #endif diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md index f4ea3c26625..7ac15668503 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md @@ -26,21 +26,21 @@ This application uses GitHub Models (model: gpt-4o-mini) for AI functionality. Y **Option A: Using User Secrets (Recommended for Development)** ```bash -dotnet user-secrets set "GitHubModels:Token" "your-github-models-token-here" +dotnet user-secrets set "GITHUB_TOKEN" "your-github-models-token-here" ``` **Option B: Using Environment Variables** -Set the `GitHubModels__Token` environment variable: +Set the `GITHUB_TOKEN` environment variable: - **Windows (PowerShell)**: ```powershell - $env:GitHubModels__Token = "your-github-models-token-here" + $env:GITHUB_TOKEN = "your-github-models-token-here" ``` - **Linux/macOS**: ```bash - export GitHubModels__Token="your-github-models-token-here" + export GITHUB_TOKEN="your-github-models-token-here" ``` #### Get a GitHub Models Token @@ -59,21 +59,21 @@ This application uses the OpenAI Platform (model: gpt-4o-mini). You'll need to c **Using User Secrets (Recommended for Development)** ```bash -dotnet user-secrets set "OpenAI:Key" "your-openai-api-key-here" +dotnet user-secrets set "OPENAI_KEY" "your-openai-api-key-here" ``` **Using Environment Variables** -Set the `OpenAI__Key` environment variable: +Set the `OPENAI_KEY` environment variable: - **Windows (PowerShell)**: ```powershell - $env:OpenAI__Key = "your-openai-api-key-here" + $env:OPENAI_KEY = "your-openai-api-key-here" ``` - **Linux/macOS**: ```bash - export OpenAI__Key="your-openai-api-key-here" + export OPENAI_KEY="your-openai-api-key-here" ``` #### Get an OpenAI API Key @@ -236,7 +236,7 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 ## Troubleshooting -**Problem**: Application fails with "Missing configuration: GitHubModels:Token" +**Problem**: Application fails with "Missing configuration: GITHUB_TOKEN" **Solution**: Make sure you've configured your GitHub Models API token using one of the methods described above. @@ -245,7 +245,7 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 **Solution**: Verify your GitHub Models token is valid and hasn't expired. You may need to regenerate it from the GitHub Models website. -**Problem**: Application fails with "Missing configuration: OpenAI:Key" +**Problem**: Application fails with "Missing configuration: OPENAI_KEY" **Solution**: Make sure you've configured your OpenAI API key using one of the methods described above. diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs index 720e0a381f0..ddc551393fa 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs @@ -15,11 +15,11 @@ // cd this-project-directory // dotnet user-secrets set AzureOpenAI:Endpoint https://YOUR-DEPLOYMENT-NAME.openai.azure.com // dotnet user-secrets set AzureOpenAI:Key YOUR-API-KEY -var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint.")), "/openai/v1"); +var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint")), "/openai/v1"); var chatClient = new ChatClient( "gpt-4o-mini", - new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key.")), + new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key")), new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint }) .AsIChatClient(); diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs index 02d8d079340..3749e820b45 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs @@ -15,7 +15,7 @@ // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory // dotnet user-secrets set AzureOpenAI:Endpoint https://YOUR-DEPLOYMENT-NAME.openai.azure.com -var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint.")), "/openai/v1"); +var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint")), "/openai/v1"); #pragma warning disable OPENAI001 // The overload accepting an AuthenticationPolicy is experimental and may change or be removed in future releases. var chatClient = new ChatClient( diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs index b71e007bb7a..025dffc9c9f 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs @@ -13,10 +13,10 @@ // You will need to set the token to your own value // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory -// dotnet user-secrets set GitHubModels:Token YOUR-GITHUB-TOKEN +// dotnet user-secrets set "GITHUB_TOKEN" "your-github-models-token-here" var chatClient = new ChatClient( "gpt-4o-mini", - new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token.")), + new ApiKeyCredential(builder.Configuration["GITHUB_TOKEN"] ?? throw new InvalidOperationException("Missing configuration: GITHUB_TOKEN")), new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }) .AsIChatClient(); diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md index eb5e909ee9b..f13529d763e 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md @@ -17,21 +17,21 @@ This application uses GitHub Models (model: gpt-4o-mini) for AI functionality. Y **Option A: Using User Secrets (Recommended for Development)** ```bash -dotnet user-secrets set "GitHubModels:Token" "your-github-models-token-here" +dotnet user-secrets set "GITHUB_TOKEN" "your-github-models-token-here" ``` **Option B: Using Environment Variables** -Set the `GitHubModels__Token` environment variable: +Set the `GITHUB_TOKEN` environment variable: - **Windows (PowerShell)**: ```powershell - $env:GitHubModels__Token = "your-github-models-token-here" + $env:GITHUB_TOKEN = "your-github-models-token-here" ``` - **Linux/macOS**: ```bash - export GitHubModels__Token="your-github-models-token-here" + export GITHUB_TOKEN="your-github-models-token-here" ``` #### Get a GitHub Models Token @@ -119,7 +119,7 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 ## Troubleshooting -**Problem**: Application fails with "Missing configuration: GitHubModels:Token" +**Problem**: Application fails with "Missing configuration: GITHUB_TOKEN" **Solution**: Make sure you've configured your GitHub Models API token using one of the methods described above. diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs index b71e007bb7a..025dffc9c9f 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs @@ -13,10 +13,10 @@ // You will need to set the token to your own value // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory -// dotnet user-secrets set GitHubModels:Token YOUR-GITHUB-TOKEN +// dotnet user-secrets set "GITHUB_TOKEN" "your-github-models-token-here" var chatClient = new ChatClient( "gpt-4o-mini", - new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token.")), + new ApiKeyCredential(builder.Configuration["GITHUB_TOKEN"] ?? throw new InvalidOperationException("Missing configuration: GITHUB_TOKEN")), new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") }) .AsIChatClient(); diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md index eb5e909ee9b..f13529d763e 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md @@ -17,21 +17,21 @@ This application uses GitHub Models (model: gpt-4o-mini) for AI functionality. Y **Option A: Using User Secrets (Recommended for Development)** ```bash -dotnet user-secrets set "GitHubModels:Token" "your-github-models-token-here" +dotnet user-secrets set "GITHUB_TOKEN" "your-github-models-token-here" ``` **Option B: Using Environment Variables** -Set the `GitHubModels__Token` environment variable: +Set the `GITHUB_TOKEN` environment variable: - **Windows (PowerShell)**: ```powershell - $env:GitHubModels__Token = "your-github-models-token-here" + $env:GITHUB_TOKEN = "your-github-models-token-here" ``` - **Linux/macOS**: ```bash - export GitHubModels__Token="your-github-models-token-here" + export GITHUB_TOKEN="your-github-models-token-here" ``` #### Get a GitHub Models Token @@ -119,7 +119,7 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 ## Troubleshooting -**Problem**: Application fails with "Missing configuration: GitHubModels:Token" +**Problem**: Application fails with "Missing configuration: GITHUB_TOKEN" **Solution**: Make sure you've configured your GitHub Models API token using one of the methods described above. diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs index 0467783dfab..15009d121cd 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Program.cs @@ -12,10 +12,10 @@ // You will need to set the API key to your own value // You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line: // cd this-project-directory -// dotnet user-secrets set OpenAI:Key YOUR-API-KEY +// dotnet user-secrets set "OPENAI_KEY" "your-openai-api-key-here" var chatClient = new ChatClient( "gpt-4o-mini", - new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key."))) + new ApiKeyCredential(builder.Configuration["OPENAI_KEY"] ?? throw new InvalidOperationException("Missing configuration: OPENAI_KEY"))) .AsIChatClient(); builder.Services.AddChatClient(chatClient); diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md index 50e9252c0ff..a989e78b7d7 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md @@ -17,21 +17,21 @@ This application uses the OpenAI Platform (model: gpt-4o-mini). You'll need to c **Using User Secrets (Recommended for Development)** ```bash -dotnet user-secrets set "OpenAI:Key" "your-openai-api-key-here" +dotnet user-secrets set "OPENAI_KEY" "your-openai-api-key-here" ``` **Using Environment Variables** -Set the `OpenAI__Key` environment variable: +Set the `OPENAI_KEY` environment variable: - **Windows (PowerShell)**: ```powershell - $env:OpenAI__Key = "your-openai-api-key-here" + $env:OPENAI_KEY = "your-openai-api-key-here" ``` - **Linux/macOS**: ```bash - export OpenAI__Key="your-openai-api-key-here" + export OPENAI_KEY="your-openai-api-key-here" ``` #### Get an OpenAI API Key @@ -119,7 +119,7 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 ## Troubleshooting -**Problem**: Application fails with "Missing configuration: OpenAI:Key" +**Problem**: Application fails with "Missing configuration: OPENAI_KEY" **Solution**: Make sure you've configured your OpenAI API key using one of the methods described above. From 874fa8138b58940201d61f456424351fa9732a82 Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Mon, 10 Nov 2025 19:36:59 -0800 Subject: [PATCH 7/9] Sort package references --- .../WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in | 8 ++++---- .../aiagent-webapi/aiagent-webapi.csproj | 2 +- .../aiagent-webapi/aiagent-webapi.csproj | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in index 5da32659a61..a0363fb6848 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in +++ b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in @@ -8,6 +8,9 @@ + + + @@ -15,13 +18,10 @@ + - - - - diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj index df14d27b60b..a915b9e428c 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj @@ -8,12 +8,12 @@ + - diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj index ed108d406e6..2bdbe9ad84a 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj @@ -12,8 +12,8 @@ - + From 4fac0c97ca15bd9d8bd26401e73264a0a3ffe119 Mon Sep 17 00:00:00 2001 From: Mackinnon Buck Date: Mon, 10 Nov 2025 21:14:29 -0800 Subject: [PATCH 8/9] Fix troubleshooting section in READMEs --- .../WebApiAgent/WebApiAgent-CSharp/README.md | 24 +++++++++++++------ .../aiagent-webapi/README.md | 4 ++++ .../aiagent-webapi/README.md | 16 +++++++++++++ .../aiagent-webapi/README.md | 2 +- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md index 7ac15668503..a8811969839 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md +++ b/src/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md @@ -254,27 +254,37 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 **Solution**: Verify your OpenAI API key is valid. Check your usage limits and billing status on the OpenAI Platform. -**Problem**: Application fails with "Missing configuration: AzureOpenAI:Endpoint" or "Missing configuration: AzureOpenAI:Key" + +**Problem**: Application fails with "Missing configuration: AzureOpenAI:Endpoint" or "Missing configuration: AzureOpenAI:Key" -**Solution**: Make sure you've configured your Azure OpenAI endpoint and API key using one of the methods described above. +**Solution**: Make sure you've configured your Azure OpenAI endpoint and API key using one of the methods described above. + +**Problem**: API requests fail with authentication errors + +**Solution**: Verify your Azure OpenAI endpoint is correct and your API key is valid. + + +**Problem**: Application fails with "Missing configuration: AzureOpenAI:Endpoint" + +**Solution**: Make sure you've configured your Azure OpenAI endpoint using one of the methods described above. - **Problem**: Managed identity authentication fails -**Solution**: +**Solution**: - Ensure your Azure resource has a system-assigned or user-assigned managed identity enabled - Verify the managed identity has been granted the "Cognitive Services OpenAI User" role on your Azure OpenAI resource - For local development, ensure you're signed in to Azure CLI: `az login` - **Problem**: API requests fail with authentication errors -**Solution**: Verify your Azure OpenAI endpoint is correct and your API key is valid your managed identity has the correct permissions. +**Solution**: Verify your Azure OpenAI endpoint is correct and your managed identity has the correct permissions. + + **Problem**: Application fails to connect to Ollama -**Solution**: +**Solution**: - Ensure Ollama is running. On macOS/Linux, check with `pgrep ollama`. On Windows, check Task Manager. - Verify Ollama is accessible at `http://localhost:11434` - Make sure you've downloaded the llama3.2 model: `ollama pull llama3.2` diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md index 76b5b021b7c..de250a2916e 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md @@ -117,8 +117,12 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 ## Troubleshooting +**Problem**: Application fails with "Missing configuration: AzureOpenAI:Endpoint" or "Missing configuration: AzureOpenAI:Key" +**Solution**: Make sure you've configured your Azure OpenAI endpoint and API key using one of the methods described above. **Problem**: API requests fail with authentication errors +**Solution**: Verify your Azure OpenAI endpoint is correct and your API key is valid. + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md index 3c15487dec6..3cb72789072 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md @@ -89,3 +89,19 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 ## Troubleshooting +**Problem**: Application fails with "Missing configuration: AzureOpenAI:Endpoint" + +**Solution**: Make sure you've configured your Azure OpenAI endpoint using one of the methods described above. + +**Problem**: Managed identity authentication fails + +**Solution**: +- Ensure your Azure resource has a system-assigned or user-assigned managed identity enabled +- Verify the managed identity has been granted the "Cognitive Services OpenAI User" role on your Azure OpenAI resource +- For local development, ensure you're signed in to Azure CLI: `az login` + +**Problem**: API requests fail with authentication errors + +**Solution**: Verify your Azure OpenAI endpoint is correct and your managed identity has the correct permissions. + + diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md index d12ccbd2aa2..411f6c90acc 100644 --- a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md @@ -102,7 +102,7 @@ dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 **Problem**: Application fails to connect to Ollama -**Solution**: +**Solution**: - Ensure Ollama is running. On macOS/Linux, check with `pgrep ollama`. On Windows, check Task Manager. - Verify Ollama is accessible at `http://localhost:9999` - Make sure you've downloaded the llama3.2 model: `ollama pull llama3.2` From 69c3bcf03fc7cf1a06c78e68c55add792dacd53d Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Mon, 10 Nov 2025 21:23:32 -0800 Subject: [PATCH 9/9] Revert MEAI.Templates change. Make launchSettings .gitignore more specific. --- src/ProjectTemplates/.gitignore | 2 +- .../Microsoft.Extensions.AI.Templates.Tests.csproj | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ProjectTemplates/.gitignore b/src/ProjectTemplates/.gitignore index 95062be5dba..ee4a515c3d2 100644 --- a/src/ProjectTemplates/.gitignore +++ b/src/ProjectTemplates/.gitignore @@ -13,7 +13,7 @@ package-lock.json */src/**/ingestioncache.* # The project templates include hard-coded launchSettings.json files -!*/src/**/Properties/launchSettings.json +!*/src/ProjectTemplates/**/Properties/launchSettings.json # Templates include JS dependencies in dist folders. !**/dist/* diff --git a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj index 11a0e4b736f..bd83d4fa93e 100644 --- a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj +++ b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj @@ -21,15 +21,12 @@ - - -