|
1 | | -# AI Agent Web API |
| 1 | +# IAW DevUI |
2 | 2 |
|
3 | | -This is an AI Agent Web API application created from the `aiagent-webapi` template. This template is currently in a preview stage. If you have feedback, please take a [brief survey](https://aka.ms/dotnet/aiagent-webapi/preview1/survey). |
| 3 | +Web-based chat UI for interacting with IAW Orleans agents, built on [Microsoft Agent Framework DevUI](https://aka.ms/dotnet/agent-framework/docs). |
4 | 4 |
|
5 | | -## Prerequisites |
| 5 | +## Architecture |
6 | 6 |
|
7 | | -- A GitHub Models API token (free to get started) |
| 7 | +DevUI runs as an **Orleans client** (not a silo), connecting to the `samples` silo via gateway port 30000. |
8 | 8 |
|
9 | | -## Getting Started |
10 | | - |
11 | | -### 1. Configure Your AI Service |
12 | | - |
13 | | -#### GitHub Models Configuration |
14 | | - |
15 | | -This application uses GitHub Models (model: gpt-4o-mini) for AI functionality. You'll need to configure your GitHub Models API token: |
16 | | - |
17 | | -**Option A: Using User Secrets (Recommended for Development)** |
18 | | - |
19 | | -```bash |
20 | | -dotnet user-secrets set "GITHUB_TOKEN" "your-github-models-token-here" |
21 | 9 | ``` |
22 | | - |
23 | | -**Option B: Using Environment Variables** |
24 | | - |
25 | | -Set the `GITHUB_TOKEN` environment variable: |
26 | | - |
27 | | -- **Windows (PowerShell)**: |
28 | | - ```powershell |
29 | | - $env:GITHUB_TOKEN = "your-github-models-token-here" |
30 | | - ``` |
31 | | - |
32 | | -- **Linux/macOS**: |
33 | | - ```bash |
34 | | - export GITHUB_TOKEN="your-github-models-token-here" |
35 | | - ``` |
36 | | - |
37 | | -#### Get a GitHub Models Token |
38 | | - |
39 | | -1. Visit [GitHub Models](https://github.com/marketplace/models) |
40 | | -2. Sign in with your GitHub account |
41 | | -3. Select a model (e.g., gpt-4o-mini) |
42 | | -4. Click "Get API Key" or follow the authentication instructions |
43 | | -5. Copy your personal access token |
44 | | - |
45 | | - |
46 | | -### 2. Run the Application |
47 | | - |
48 | | -```bash |
49 | | -dotnet run -lp https |
| 10 | +DevUI (Orleans Client) |
| 11 | + └── OrleansAgentChatClient : IChatClient |
| 12 | + └── IClusterClient.GetGrain<IAgent>(agentId).RespondAsync() |
| 13 | + └── Agent grain in samples silo (with UseOpenTelemetry pipeline) |
50 | 14 | ``` |
51 | 15 |
|
52 | | -The application will start and listen on: |
53 | | -- HTTP: `http://localhost:5191` |
54 | | -- HTTPS: `https://localhost:7283` |
55 | | - |
56 | | -### 3. Test the Application |
57 | | - |
58 | | -The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools. |
59 | | - |
60 | | -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. |
61 | | - |
62 | | -## How It Works |
| 16 | +`OrleansAgentChatClient` bridges `Microsoft.Extensions.AI.IChatClient` to Orleans `IAgent` grains. The `AddAIAgent()` registration passes the grain ID as `instructions`, which the client uses for routing. |
63 | 17 |
|
64 | | -This application demonstrates Agent Framework with: |
| 18 | +## Running |
65 | 19 |
|
66 | | -1. **Writer Agent**: Writes short stories (300 words or less) about specified topics |
67 | | -2. **Editor Agent**: Edits stories to improve grammar and style, ensuring they stay under 300 words |
68 | | -3. **Publisher Workflow Agent**: A sequential workflow agent that combines the writer and editor agents |
69 | | - |
70 | | -The agents are exposed through OpenAI-compatible API endpoints, making them easy to integrate with existing tools and applications. |
71 | | - |
72 | | -## Template Parameters |
73 | | - |
74 | | -When creating a new project, you can customize it using template parameters: |
| 20 | +Always start via Aspire (never `dotnet run` directly): |
75 | 21 |
|
76 | 22 | ```bash |
77 | | -# Specify AI service provider |
78 | | -dotnet new aiagent-webapi --provider azureopenai |
79 | | - |
80 | | -# Specify a custom chat model |
81 | | -dotnet new aiagent-webapi --chat-model gpt-4o |
82 | | - |
83 | | -# Use API key authentication for Azure OpenAI |
84 | | -dotnet new aiagent-webapi --provider azureopenai --managed-identity false |
85 | | - |
86 | | -# Use Ollama with a different model |
87 | | -dotnet new aiagent-webapi --provider ollama --chat-model llama3.1 |
| 23 | +aspire run |
88 | 24 | ``` |
89 | 25 |
|
90 | | -### Available Parameters |
91 | | - |
92 | | -- **`--provider`**: Choose the AI service provider |
93 | | - - `githubmodels` (default) - GitHub Models |
94 | | - - `azureopenai` - Azure OpenAI |
95 | | - - `openai` - OpenAI Platform |
96 | | - - `ollama` - Ollama (local development) |
97 | | - |
98 | | -- **`--chat-model`**: Specify the chat model/deployment name |
99 | | - - Default for OpenAI/Azure OpenAI/GitHub Models: `gpt-4o-mini` |
100 | | - - Default for Ollama: `llama3.2` |
101 | | - |
102 | | -- **`--managed-identity`**: Use managed identity for Azure services (default: `true`) |
103 | | - - Only applicable when `--provider azureopenai` |
104 | | - |
105 | | -- **`--framework`**: Target framework (default: `net10.0`) |
106 | | - - Options: `net10.0`, `net9.0`, `net8.0` |
107 | | - |
108 | | -## Project Structure |
109 | | - |
110 | | -- `Program.cs` - Application entry point and configuration |
111 | | -- `appsettings.json` - Application configuration |
112 | | -- `Properties/launchSettings.json` - Launch profiles for development |
113 | | - |
114 | | -## Learn More |
115 | | - |
116 | | -- [AI apps for .NET developers](https://learn.microsoft.com/dotnet/ai) |
117 | | -- [Microsoft Agent Framework Documentation](https://aka.ms/dotnet/agent-framework/docs) |
118 | | -- [GitHub Models](https://github.com/marketplace/models) |
119 | | - |
120 | | -## Troubleshooting |
121 | | - |
122 | | -**Problem**: Application fails with "Missing configuration: GITHUB_TOKEN" |
123 | | - |
124 | | -**Solution**: Make sure you've configured your GitHub Models API token using one of the methods described above. |
125 | | - |
126 | | -**Problem**: API requests fail with authentication errors |
127 | | - |
128 | | -**Solution**: Verify your GitHub Models token is valid and hasn't expired. You may need to regenerate it from the GitHub Models website. |
129 | | - |
| 26 | +DevUI is available at the `/devui/` path shown in the Aspire dashboard. |
| 27 | + |
| 28 | +## Registered Agents |
| 29 | + |
| 30 | +Well-known agents registered in `Program.cs`: |
| 31 | + |
| 32 | +| Agent | Grain ID | Role | |
| 33 | +|-------|----------|------| |
| 34 | +| PersonalAssistant | personal-assistant | Task decomposition and delegation | |
| 35 | +| Roslyn | roslyn | C# code intelligence | |
| 36 | +| DotNet | dotnet | Build, test, format | |
| 37 | +| NuGet | nuget | Package management | |
| 38 | +| GitHub | github | PRs, issues, releases | |
| 39 | +| Reviewer | reviewer | Code quality review | |
| 40 | +| FileSystem | fs | File read/write/search | |
| 41 | +| Shell | shell | Shell command execution | |
| 42 | +| Git | git | Version control | |
| 43 | +| Build | build | Generic build runner | |
| 44 | +| Knowledge | knowledge | Project knowledge store | |
| 45 | +| User | user | Preferences, memories | |
| 46 | +| Planning | planning | Execution plan generation | |
| 47 | +| Notification | notification | User alerts | |
| 48 | + |
| 49 | +## Telemetry |
| 50 | + |
| 51 | +GenAI telemetry flows through the agent pipeline: |
| 52 | +- `agent.respond` spans from `AgentV2.RespondAsync()` |
| 53 | +- `agent.llm` + GenAI spans when agents call `RespondWithLlmAsync()` |
| 54 | +- Trace sample ratio set to 1.0 for full capture in development |
| 55 | + |
| 56 | +## Key Files |
| 57 | + |
| 58 | +- `Program.cs` -- Orleans client setup, agent registration, DevUI mapping |
| 59 | +- `OrleansAgentChatClient.cs` -- IChatClient → IAgent grain bridge |
| 60 | +- `appsettings.json` -- Telemetry config (SampleRatio: 1.0) |
0 commit comments