mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
dc2b109b50
* Upgrade to .NET 10 - Require .NET 10 SDK - Include net10.0 assets in all assemblies - Move net9.0-only targets to net10.0 - Update LangVersion to latest - Remove complicated distinctions between debug target TFMs and release target TFMs - Remove unnecessary package dependencies when built into netcoreapp - Clean up some ifdefs - Clean up some analyzer warnings * Fix CI
dc2b109b50
ยท
2025-11-22 04:14:15 +00:00
History
DevUI Step 01 - Basic Usage
This sample demonstrates how to add the DevUI to an ASP.NET Core application with AI agents.
What is DevUI?
The DevUI provides an interactive web interface for testing and debugging AI agents during development.
Configuration
Set the following environment variables:
AZURE_OPENAI_ENDPOINT- Your Azure OpenAI endpoint URL (required)AZURE_OPENAI_DEPLOYMENT_NAME- Your deployment name (defaults to "gpt-4o-mini")
Running the Sample
- Set your Azure OpenAI credentials as environment variables
- Run the application:
dotnet run - Open your browser to https://localhost:50516/devui
- Select an agent or workflow from the dropdown and start chatting!
Sample Agents and Workflows
This sample includes:
Agents:
- assistant - A helpful assistant
- poet - A creative poet
- coder - An expert programmer
Workflows:
- review-workflow - A sequential workflow that generates a response and then reviews it
Adding DevUI to Your Own Project
To add DevUI to your ASP.NET Core application:
-
Add the DevUI package and hosting packages:
dotnet add package Microsoft.Agents.AI.DevUI dotnet add package Microsoft.Agents.AI.Hosting dotnet add package Microsoft.Agents.AI.Hosting.OpenAI -
Register your agents and workflows:
var builder = WebApplication.CreateBuilder(args); // Set up your chat client builder.Services.AddChatClient(chatClient); // Register agents builder.AddAIAgent("assistant", "You are a helpful assistant."); // Register workflows var agent1Builder = builder.AddAIAgent("workflow-agent1", "You are agent 1."); var agent2Builder = builder.AddAIAgent("workflow-agent2", "You are agent 2."); builder.AddSequentialWorkflow("my-workflow", [agent1Builder, agent2Builder]) .AddAsAIAgent(); -
Add OpenAI services and map the endpoints for OpenAI and DevUI:
// 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 app.MapDevUI(); } app.Run(); -
Navigate to
/devuiin your browser