diff --git a/src/ProjectTemplates/.gitignore b/src/ProjectTemplates/.gitignore index ceffca4abbc..ee4a515c3d2 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 project templates include hard-coded launchSettings.json files +!*/src/ProjectTemplates/**/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..9014b892d98 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\ @@ -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.251110.2 + 1.0.0-alpha.251110.2 9.5.1 9.5.1-preview.1.25502.11 1.0.0 @@ -91,6 +91,9 @@ + @@ -100,9 +103,6 @@ - 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 85% 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 index ca7eeb7faf0..62bebc3ee06 100644 --- a/src/ProjectTemplates/Microsoft.Agents.AI.Templates/Microsoft.Agents.AI.Templates.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 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 52% 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 index aadc8b70181..743658f6c8a 100644 --- 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 @@ -8,14 +8,19 @@ using Azure.Identity; #endif using Microsoft.Agents.AI; +using Microsoft.Agents.AI.DevUI; 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 || IsOpenAI || IsAzureOpenAI) +using OpenAI.Chat; +#endif var builder = WebApplication.CreateBuilder(args); @@ -23,27 +28,21 @@ // 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(); -#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"); +// dotnet user-secrets set "GITHUB_TOKEN" "your-github-models-token-here" +var chatClient = new ChatClient( + "gpt-4o-mini", + 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 -var openAIClient = new OpenAIClient( - new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key. See README for details."))); - -#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 +// 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"))) + .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: @@ -52,21 +51,27 @@ #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"); -#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. See README for details.")), openAIOptions); +var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint")), "/openai/v1"); -#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); @@ -76,8 +81,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( @@ -86,17 +91,28 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +// 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 (also required for DevUI) app.MapOpenAIResponses(); +app.MapOpenAIConversations(); + +if (builder.Environment.IsDevelopment()) +{ + // 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/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 82% 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 index 9bc26dbafff..27165ad4a22 100644 --- 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 @@ -4,7 +4,8 @@ "http": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "applicationUrl": "http://localhost:5056", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -13,7 +14,8 @@ "https": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "devui/", "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.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/README.md similarity index 84% 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 index 9355df92141..a8811969839 100644 --- 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 @@ -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 @@ -165,6 +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: @@ -234,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. @@ -243,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. @@ -252,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` @@ -280,5 +292,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.ProjectTemplates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in similarity index 91% 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 index 7ab75edde39..a0363fb6848 100644 --- 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 @@ -8,19 +8,20 @@ + + + + + - - - - 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 77% 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 732ecb74f15..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 @@ -17,12 +17,15 @@ + + + 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 57% 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 index da628ffb782..ddc551393fa 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.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Program.cs @@ -1,10 +1,12 @@ 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; using OpenAI; +using OpenAI.Chat; var builder = WebApplication.CreateBuilder(args); @@ -13,13 +15,13 @@ // 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 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 azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint")), "/openai/v1"); -#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); @@ -28,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( @@ -38,17 +40,28 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +// 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 (also required for DevUI) app.MapOpenAIResponses(); +app.MapOpenAIConversations(); + +if (builder.Environment.IsDevelopment()) +{ + // 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/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/Properties/launchSettings.json similarity index 82% 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_ApiKey.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.ProjectTemplates.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.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.verified/aiagent-webapi/README.md similarity index 84% 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 index f524a1b6191..de250a2916e 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.ProjectTemplates.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: @@ -115,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.Templates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.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 89% 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.AzureOpenAI_ApiKey.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.ProjectTemplates.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_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 56% 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 index ced383f0234..3749e820b45 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.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Program.cs @@ -2,10 +2,12 @@ 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; using OpenAI; +using OpenAI.Chat; var builder = WebApplication.CreateBuilder(args); @@ -13,13 +15,14 @@ // 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"); -#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 azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint")), "/openai/v1"); -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); @@ -29,8 +32,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,17 +42,28 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +// 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 (also required for DevUI) app.MapOpenAIResponses(); +app.MapOpenAIConversations(); + +if (builder.Environment.IsDevelopment()) +{ + // 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/Properties/launchSettings.json b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/Properties/launchSettings.json similarity index 82% 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.AzureOpenAI_ManagedIdentity.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.ProjectTemplates.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.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/README.md similarity index 72% 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 index f912ccb7bc0..3cb72789072 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.ProjectTemplates.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: @@ -87,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.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 90% 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 index d1029ebe6a1..a915b9e428c 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.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ManagedIdentity.verified/aiagent-webapi/aiagent-webapi.csproj @@ -8,11 +8,12 @@ + + - 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.GitHubModels.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/Program.cs similarity index 51% 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.DefaultParameters.verified/aiagent-webapi/Program.cs index 9ed14c2c652..025dffc9c9f 100644 --- 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.DefaultParameters.verified/aiagent-webapi/Program.cs @@ -1,22 +1,24 @@ 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; 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 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(); +// dotnet user-secrets set "GITHUB_TOKEN" "your-github-models-token-here" +var chatClient = new ChatClient( + "gpt-4o-mini", + 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(); builder.Services.AddChatClient(chatClient); @@ -25,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( @@ -35,17 +37,28 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +// 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 (also required for DevUI) app.MapOpenAIResponses(); +app.MapOpenAIConversations(); + +if (builder.Environment.IsDevelopment()) +{ + // 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_ApiKey.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 82% 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.DefaultParameters.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.ProjectTemplates.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.GitHubModels.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.DefaultParameters.verified/aiagent-webapi/README.md similarity index 85% 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.DefaultParameters.verified/aiagent-webapi/README.md index b400819b591..f13529d763e 100644 --- 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.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 @@ -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: @@ -117,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.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 89% 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 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.ProjectTemplates.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.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.DefaultParameters.verified/aiagent-webapi/Program.cs b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/Program.cs similarity index 51% 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.GitHubModels.verified/aiagent-webapi/Program.cs index 9ed14c2c652..025dffc9c9f 100644 --- 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.GitHubModels.verified/aiagent-webapi/Program.cs @@ -1,22 +1,24 @@ 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; 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 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(); +// dotnet user-secrets set "GITHUB_TOKEN" "your-github-models-token-here" +var chatClient = new ChatClient( + "gpt-4o-mini", + 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(); builder.Services.AddChatClient(chatClient); @@ -25,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( @@ -35,17 +37,28 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +// 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 (also required for DevUI) app.MapOpenAIResponses(); +app.MapOpenAIConversations(); + +if (builder.Environment.IsDevelopment()) +{ + // 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.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 82% 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 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.ProjectTemplates.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.DefaultParameters.verified/aiagent-webapi/README.md b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.GitHubModels.verified/aiagent-webapi/README.md similarity index 85% 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.GitHubModels.verified/aiagent-webapi/README.md index b400819b591..f13529d763e 100644 --- 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.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 @@ -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: @@ -117,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.Templates.IntegrationTests/Snapshots/aiagent-webapi.AzureOpenAI_ApiKey.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 89% 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.GitHubModels.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.ProjectTemplates.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.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 63% 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 index 4015d7fdc98..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.ProjectTemplates.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; @@ -18,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( @@ -28,17 +29,28 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +// 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 (also required for DevUI) app.MapOpenAIResponses(); +app.MapOpenAIConversations(); + +if (builder.Environment.IsDevelopment()) +{ + // 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.ProjectTemplates.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 new file mode 100644 index 00000000000..c242aacc025 --- /dev/null +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/Properties/launchSettings.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "devui/", + "applicationUrl": "http://localhost:9999", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "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.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/README.md similarity index 91% 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 index 3cb101869fe..411f6c90acc 100644 --- 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 @@ -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: @@ -100,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` @@ -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.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj similarity index 89% 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 index 09e26e73acc..2bdbe9ad84a 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.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.Ollama.verified/aiagent-webapi/aiagent-webapi.csproj @@ -9,10 +9,11 @@ + - + 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 53% 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 index 4bf9e2b74b8..15009d121cd 100644 --- 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 @@ -1,23 +1,22 @@ 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; -using OpenAI; +using OpenAI.Chat; var builder = WebApplication.CreateBuilder(args); // 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. See README for details."))); - -#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 +// 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"))) + .AsIChatClient(); builder.Services.AddChatClient(chatClient); @@ -26,8 +25,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,17 +35,28 @@ sp.GetRequiredKeyedService("editor") )).AddAsAIAgent(); -var app = builder.Build(); +// 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 (also required for DevUI) app.MapOpenAIResponses(); +app.MapOpenAIConversations(); + +if (builder.Environment.IsDevelopment()) +{ + // 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.ProjectTemplates.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 new file mode 100644 index 00000000000..c242aacc025 --- /dev/null +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/Properties/launchSettings.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "devui/", + "applicationUrl": "http://localhost:9999", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "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.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/README.md similarity index 85% 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 index 898c82c2098..a989e78b7d7 100644 --- 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 @@ -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 @@ -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: @@ -117,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. diff --git a/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.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 new file mode 100644 index 00000000000..337bfdd220c --- /dev/null +++ b/test/ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.IntegrationTests/Snapshots/aiagent-webapi.OpenAI.verified/aiagent-webapi/aiagent-webapi.csproj @@ -0,0 +1,19 @@ + + + + net10.0 + enable + enable + secret + + + + + + + + + + + + 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 - - - net10.0 - enable - enable - secret - - - - - - - - - - -