diff --git a/dotnet/samples/GettingStarted/DevUI/DevUI_Step01_BasicUsage/Program.cs b/dotnet/samples/GettingStarted/DevUI/DevUI_Step01_BasicUsage/Program.cs index e2e6e6b727..94950e8336 100644 --- a/dotnet/samples/GettingStarted/DevUI/DevUI_Step01_BasicUsage/Program.cs +++ b/dotnet/samples/GettingStarted/DevUI/DevUI_Step01_BasicUsage/Program.cs @@ -61,13 +61,14 @@ private static void Main(string[] args) [assistantBuilder, reviewerBuilder]) .AddAsAIAgent(); - if (builder.Environment.IsDevelopment()) - { - builder.AddDevUI(); - } + builder.Services.AddOpenAIResponses(); + builder.Services.AddOpenAIConversations(); var app = builder.Build(); + app.MapOpenAIResponses(); + app.MapOpenAIConversations(); + if (builder.Environment.IsDevelopment()) { app.MapDevUI(); diff --git a/dotnet/samples/GettingStarted/DevUI/DevUI_Step01_BasicUsage/README.md b/dotnet/samples/GettingStarted/DevUI/DevUI_Step01_BasicUsage/README.md index 2b6cc28644..0bf24dfb26 100644 --- a/dotnet/samples/GettingStarted/DevUI/DevUI_Step01_BasicUsage/README.md +++ b/dotnet/samples/GettingStarted/DevUI/DevUI_Step01_BasicUsage/README.md @@ -63,17 +63,23 @@ To add DevUI to your ASP.NET Core application: .AddAsAIAgent(); ``` -3. Add DevUI services and map the endpoint: +3. Add OpenAI services and map the endpoints for OpenAI and DevUI: ```csharp - builder.AddDevUI(); + // Register services for OpenAI responses and conversations (also required for DevUI) + builder.Services.AddOpenAIResponses(); + builder.Services.AddOpenAIConversations(); + var app = builder.Build(); - - app.MapDevUI(); - - // Add required endpoints - app.MapEntities(); + + // 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(); ``` diff --git a/dotnet/samples/GettingStarted/DevUI/README.md b/dotnet/samples/GettingStarted/DevUI/README.md index 155d3f2b9d..45b2f6f63b 100644 --- a/dotnet/samples/GettingStarted/DevUI/README.md +++ b/dotnet/samples/GettingStarted/DevUI/README.md @@ -38,19 +38,22 @@ builder.Services.AddChatClient(chatClient); // Register your agents builder.AddAIAgent("my-agent", "You are a helpful assistant."); -// Add DevUI services -builder.AddDevUI(); +// Register services for OpenAI responses and conversations (also required for DevUI) +builder.Services.AddOpenAIResponses(); +builder.Services.AddOpenAIConversations(); var app = builder.Build(); -// Map the DevUI endpoint -app.MapDevUI(); - -// Add required endpoints -app.MapEntities(); +// 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(); ``` diff --git a/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs b/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs index 4a85de121a..bbbf332f8b 100644 --- a/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs @@ -9,23 +9,23 @@ namespace Microsoft.Agents.AI.DevUI; /// public static class DevUIExtensions { - /// - /// Adds the necessary services for the DevUI to the application builder. - /// - public static IHostApplicationBuilder AddDevUI(this IHostApplicationBuilder builder) - { - ArgumentNullException.ThrowIfNull(builder); - builder.Services.AddOpenAIConversations(); - builder.Services.AddOpenAIResponses(); - - return builder; - } - /// /// Maps an endpoint that serves the DevUI from the '/devui' path. /// + /// + /// DevUI requires the OpenAI Responses and Conversations services to be registered with + /// and + /// , + /// and the corresponding endpoints to be mapped using + /// and + /// . + /// /// The to add the endpoint to. /// A that can be used to add authorization or other endpoint configuration. + /// + /// + /// + /// /// Thrown when is null. public static IEndpointConventionBuilder MapDevUI( this IEndpointRouteBuilder endpoints) @@ -33,8 +33,6 @@ public static IEndpointConventionBuilder MapDevUI( var group = endpoints.MapGroup(""); group.MapDevUI(pattern: "/devui"); group.MapEntities(); - group.MapOpenAIConversations(); - group.MapOpenAIResponses(); return group; } diff --git a/dotnet/src/Microsoft.Agents.AI.DevUI/README.md b/dotnet/src/Microsoft.Agents.AI.DevUI/README.md index 1f106e29ef..b55869748d 100644 --- a/dotnet/src/Microsoft.Agents.AI.DevUI/README.md +++ b/dotnet/src/Microsoft.Agents.AI.DevUI/README.md @@ -24,14 +24,16 @@ var builder = WebApplication.CreateBuilder(args); // Register your agents builder.AddAIAgent("assistant", "You are a helpful assistant."); -if (builder.Environment.IsDevelopment()) -{ - // Add DevUI services - builder.AddDevUI(); -} +// Register services for OpenAI responses and conversations (also required for DevUI) +builder.Services.AddOpenAIResponses(); +builder.Services.AddOpenAIConversations(); var app = builder.Build(); +// Map endpoints for OpenAI responses and conversations (also required for DevUI) +app.MapOpenAIResponses(); +app.MapOpenAIConversations(); + if (builder.Environment.IsDevelopment()) { // Map DevUI endpoint to /devui