db620d33df
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Text.Json.Serialization;
|
|
using Microsoft.Agents.AI;
|
|
|
|
namespace AgentWebChat.AgentHost;
|
|
|
|
internal static class ActorFrameworkWebApplicationExtensions
|
|
{
|
|
public static void MapAgentDiscovery(this IEndpointRouteBuilder endpoints, [StringSyntax("Route")] string path)
|
|
{
|
|
var registeredAIAgents = endpoints.ServiceProvider.GetKeyedServices<AIAgent>(KeyedService.AnyKey);
|
|
|
|
var routeGroup = endpoints.MapGroup(path);
|
|
routeGroup.MapGet("/", async (CancellationToken cancellationToken) =>
|
|
{
|
|
var results = new List<AgentDiscoveryCard>();
|
|
foreach (var result in registeredAIAgents)
|
|
{
|
|
results.Add(new AgentDiscoveryCard
|
|
{
|
|
Name = result.Name!,
|
|
Description = result.Description,
|
|
});
|
|
}
|
|
|
|
return Results.Ok(results);
|
|
})
|
|
.WithName("GetAgents");
|
|
}
|
|
|
|
internal sealed class AgentDiscoveryCard
|
|
{
|
|
public required string Name { get; set; }
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public string? Description { get; set; }
|
|
}
|
|
}
|