mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
1da9107f4a
* wip * resolve non-agent workflows as well! * add tests for devui registrations and resolving * fixes * devui for net8 as well! * simplify TFM * update tfm... * tfm rules.... * wip * roll * verify entities are registered with a devui call * tests * add a proper support for non-keyed workflows * resolve default aiagent registration * sort usings :) * cleanup tests
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; }
|
|
}
|
|
}
|