mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
e7441ee29e
* Add agent hosting package and update sample * Review feedback and cleanup * Include the narrator * wip * wip * Remove workaround for empty state writes. * Handle changes to AgentThread. * One more. * Fix. --------- Co-authored-by: Aditya Mandaleeka <adityam@microsoft.com>
29 lines
1.0 KiB
C#
29 lines
1.0 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Text.Json;
|
|
using Microsoft.Extensions.AI.Agents.Hosting;
|
|
|
|
namespace AgentWebChat.Web;
|
|
|
|
public class AgentDiscoveryClient(HttpClient httpClient, ILogger<AgentDiscoveryClient> logger)
|
|
{
|
|
public async Task<List<AgentDiscoveryCard>> GetAgentsAsync(CancellationToken cancellationToken = default)
|
|
{
|
|
var response = await httpClient.GetAsync(new Uri("/agents", UriKind.Relative), cancellationToken);
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
var json = await response.Content.ReadAsStringAsync(cancellationToken);
|
|
var agents = JsonSerializer.Deserialize<List<AgentDiscoveryCard>>(json, AgentHostingJsonUtilities.DefaultOptions) ?? [];
|
|
|
|
logger.LogInformation("Retrieved {AgentCount} agents from the API", agents.Count);
|
|
_ = new HttpActorClient(null!);
|
|
return agents;
|
|
}
|
|
|
|
public class AgentDiscoveryCard
|
|
{
|
|
public string? Name { get; set; }
|
|
public string? Description { get; set; }
|
|
}
|
|
}
|