Skip to content
Open
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 @@ -5,21 +5,14 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="/Users/lokinfey/Desktop/AOAI/Foundry/agent-framework/dotnet/src/Microsoft.Agents.AI.DevUI/Microsoft.Agents.AI.DevUI.csproj" />
<ProjectReference Include="/Users/lokinfey/Desktop/AOAI/Foundry/agent-framework/dotnet/src/Microsoft.Agents.AI.Hosting/Microsoft.Agents.AI.Hosting.csproj" />
<ProjectReference Include="/Users/lokinfey/Desktop/AOAI/Foundry/agent-framework/dotnet/src/Microsoft.Agents.AI.Workflows/Microsoft.Agents.AI.Workflows.csproj" />
<ProjectReference Include="/Users/lokinfey/Desktop/AOAI/Foundry/agent-framework/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Microsoft.Agents.AI.Hosting.OpenAI.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
<PackageReference Include="Azure.Identity" Version="1.17.1" />
<PackageReference Include="DotNetEnv" Version="3.1.1" />
<PackageReference Include="Azure.AI.Projects" Version="1.2.0-beta.5" />
<PackageReference Include="Azure.AI.Projects.OpenAI" Version="1.0.0-beta.5" />
<PackageReference Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.8" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.2.0-preview.1.26063.2" />
<PackageReference Include="DotNetEnv" Version="3.2.0" />
<PackageReference Include="Microsoft.Agents.AI.DevUI" Version="1.15.0-preview.260722.1" />
<PackageReference Include="Microsoft.Agents.AI.Hosting" Version="1.15.0-preview.260722.1" />
<PackageReference Include="Microsoft.Agents.AI.Hosting.OpenAI" Version="1.15.0-alpha.260722.1" />
<PackageReference Include="Microsoft.Agents.AI.Workflows" Version="1.15.0" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.8.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@

// using System.ComponentModel;
// using Azure.AI.OpenAI;
// 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 System;
using System.ComponentModel;
using System.ClientModel;
using Azure.Identity;
using DotNetEnv;
using OpenAI;

using Microsoft.Agents.AI;
using Microsoft.Agents.AI.DevUI;
using Microsoft.Agents.AI.Hosting;
using Microsoft.Agents.AI.Workflows;
using Microsoft.Agents.AI.Workflows.Reflection;
using Microsoft.Extensions.AI;


namespace GHModel.dotNET.AI.Workflow.DevUI;

/// <summary>
Expand Down Expand Up @@ -53,26 +39,27 @@ internal static class Program
private static void Main(string[] args)
{
// Load environment variables from .env file
Env.Load("../../../../.env");
Env.Load("../../.env");

var builder = WebApplication.CreateBuilder(args);

// Set up the Azure OpenAI client
var github_endpoint = Environment.GetEnvironmentVariable("GITHUB_ENDPOINT") ?? throw new InvalidOperationException("GITHUB_ENDPOINT is not set.");
var github_model_id = "openai/gpt-5";
var github_token = Environment.GetEnvironmentVariable("GITHUB_TOKEN") ?? throw new InvalidOperationException("GITHUB_TOKEN is not set.");
var githubEndpoint = GetRequiredEnvironmentVariable("GITHUB_ENDPOINT");
var githubModelId = GetRequiredEnvironmentVariable("GITHUB_MODEL_ID");
var githubToken = GetRequiredEnvironmentVariable("GITHUB_TOKEN");

var openAIOptions = new OpenAIClientOptions()
{
Endpoint = new Uri(github_endpoint)
Endpoint = new Uri(githubEndpoint)
};

var openAIClient = new OpenAIClient(new ApiKeyCredential(github_token), openAIOptions);

var chatClient = openAIClient.GetChatClient(github_model_id).AsIChatClient();

var openAIClient = new OpenAIClient(new ApiKeyCredential(githubToken), openAIOptions);
var chatClient = openAIClient.GetChatClient(githubModelId).AsIChatClient();

builder.Services.AddChatClient(chatClient);
if (builder.Environment.IsDevelopment())
{
builder.Services.AddDevUI();
}

// Register sample agents with tools
builder.AddAIAgent("GPTAssistant", "You are a helpful assistant. Answer questions concisely and accurately.");
Expand Down Expand Up @@ -101,7 +88,8 @@ Consider suggestions when refining an idea.

builder.AddWorkflow("gh-model-workflow", (sp, key) =>
{
var agents = new List<IHostedAgentBuilder>() { reviewerAgentBuilder, frontDeskAgentBuilder }.Select(ab => sp.GetRequiredKeyedService<AIAgent>(ab.Name));
var agents = new[] { frontDeskAgentBuilder, reviewerAgentBuilder }
.Select(agentBuilder => sp.GetRequiredKeyedService<AIAgent>(agentBuilder.Name));
return AgentWorkflowBuilder.BuildSequential(workflowName: key, agents: agents);
}).AddAsAIAgent();

Expand All @@ -111,19 +99,26 @@ Consider suggestions when refining an idea.
var app = builder.Build();


app.UseHttpsRedirection();

app.MapOpenAIResponses();
app.MapOpenAIConversations();

if (builder.Environment.IsDevelopment())
{
app.MapDevUI();
Console.WriteLine("DevUI is available at: http://localhost:50518/devui");
}

Console.WriteLine("DevUI is available at: http://localhost:50518/devui");
Console.WriteLine("OpenAI Responses API is available at: http://localhost:50518/v1/responses");
Console.WriteLine("Press Ctrl+C to stop the server.");
app.Run();
}

private static string GetRequiredEnvironmentVariable(string name)
{
var value = Environment.GetEnvironmentVariable(name);
return !string.IsNullOrWhiteSpace(value)
? value
: throw new InvalidOperationException(
$"{name} is not set. Add it to 09.Cases/GHModel.AI/.env or set it in your environment.");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"profiles": {
"Dev_UI_Applcaiton": {
"Dev_UI_Application": {
"commandName": "Project",
"launchUrl": "devui",
"launchBrowser": true,
Expand Down
36 changes: 28 additions & 8 deletions 09.Cases/GHModel.AI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The project uses a dual-agent sequential workflow:

### Prerequisites

- Python 3.10+ / .NET 8.0+
- Python 3.10+ / .NET 10.0+
- GitHub Models API access (or Azure OpenAI / OpenAI)
- Docker (optional, for running Aspire Dashboard)

Expand All @@ -85,12 +85,15 @@ cd GHModel.AI

### 2. Configure Environment Variables

Create a `.env` file in each example directory:
Set these environment variables in your shell or in the `.env` location used by
the example you are running. The .NET DevUI example loads
`09.Cases/GHModel.AI/.env`:

```env
GITHUB_ENDPOINT=https://models.inference.ai.azure.com
GITHUB_ENDPOINT=https://models.github.ai/inference
# Fine-grained PAT with "Models: read" permission
GITHUB_TOKEN=your_github_token
GITHUB_MODEL_ID=gpt-4o
GITHUB_MODEL_ID=openai/gpt-4.1-mini
```

---
Expand Down Expand Up @@ -230,10 +233,13 @@ python main.py
```bash
cd GHModel.dotNET.AI/GHModel.dotNET.AI.Workflow.DevUI
dotnet run
# DevUI: https://localhost:50516/devui
# OpenAI API: https://localhost:50516/v1/responses
# DevUI: http://localhost:50518/devui
# OpenAI API: http://localhost:50518/v1/responses
```

Select `gh-model-workflow` in DevUI to run the sequential FrontDesk and
Concierge workflow.

#### Code Snippets

```python
Expand All @@ -244,9 +250,23 @@ serve(entities=[workflow], port=8090, auto_open=True, tracing_enabled=True)

```csharp
// .NET — ASP.NET Core integration
if (builder.Environment.IsDevelopment())
{
builder.Services.AddDevUI();
}
builder.AddAIAgent("FrontDesk", FrontDeskAgentInstructions);
builder.AddWorkflow("gh-model-workflow", ...);
app.MapDevUI();

builder.Services.AddOpenAIResponses();
builder.Services.AddOpenAIConversations();

app.MapOpenAIResponses();
app.MapOpenAIConversations();

if (app.Environment.IsDevelopment())
{
app.MapDevUI();
}
```

---
Expand Down Expand Up @@ -390,4 +410,4 @@ This project is licensed under the [MIT License](LICENSE).

## 🤝 Contributing

Contributions are welcome! Feel free to submit Issues and Pull Requests. For questions or suggestions, please open an issue on GitHub.
Contributions are welcome! Feel free to submit Issues and Pull Requests. For questions or suggestions, please open an issue on GitHub.