Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
```
Expand Down
17 changes: 10 additions & 7 deletions dotnet/samples/GettingStarted/DevUI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
```

Expand Down
26 changes: 12 additions & 14 deletions dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,30 @@ namespace Microsoft.Agents.AI.DevUI;
/// </summary>
public static class DevUIExtensions
{
/// <summary>
/// Adds the necessary services for the DevUI to the application builder.
/// </summary>
public static IHostApplicationBuilder AddDevUI(this IHostApplicationBuilder builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.Services.AddOpenAIConversations();
builder.Services.AddOpenAIResponses();

return builder;
}

/// <summary>
/// Maps an endpoint that serves the DevUI from the '/devui' path.
/// </summary>
/// <remarks>
/// DevUI requires the OpenAI Responses and Conversations services to be registered with
/// <see cref="MicrosoftAgentAIHostingOpenAIServiceCollectionExtensions.AddOpenAIResponses(IServiceCollection)"/> and
/// <see cref="MicrosoftAgentAIHostingOpenAIServiceCollectionExtensions.AddOpenAIConversations(IServiceCollection)"/>,
/// and the corresponding endpoints to be mapped using
/// <see cref="MicrosoftAgentAIHostingOpenAIEndpointRouteBuilderExtensions.MapOpenAIResponses(IEndpointRouteBuilder)"/> and
/// <see cref="MicrosoftAgentAIHostingOpenAIEndpointRouteBuilderExtensions.MapOpenAIConversations(IEndpointRouteBuilder)"/>.
/// </remarks>
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/> to add the endpoint to.</param>
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to add authorization or other endpoint configuration.</returns>
/// <seealso cref="MicrosoftAgentAIHostingOpenAIServiceCollectionExtensions.AddOpenAIResponses(IServiceCollection)"/>
/// <seealso cref="MicrosoftAgentAIHostingOpenAIServiceCollectionExtensions.AddOpenAIConversations(IServiceCollection)"/>
/// <seealso cref="MicrosoftAgentAIHostingOpenAIEndpointRouteBuilderExtensions.MapOpenAIResponses(IEndpointRouteBuilder)"/>
/// <seealso cref="MicrosoftAgentAIHostingOpenAIEndpointRouteBuilderExtensions.MapOpenAIConversations(IEndpointRouteBuilder)"/>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="endpoints"/> is null.</exception>
public static IEndpointConventionBuilder MapDevUI(
this IEndpointRouteBuilder endpoints)
{
var group = endpoints.MapGroup("");
group.MapDevUI(pattern: "/devui");
group.MapEntities();
group.MapOpenAIConversations();
group.MapOpenAIResponses();
return group;
}

Expand Down
12 changes: 7 additions & 5 deletions dotnet/src/Microsoft.Agents.AI.DevUI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading