mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* add support for baackground responses to a2a agent * fix line endings * address pr review comments * address pr review comments * update sample to net10.0 * Update dotnet/samples/GettingStarted/A2A/A2AAgent_PollingForTaskCompletion/README.md Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> * Update dotnet/src/Microsoft.Agents.AI.A2A/Extensions/A2AAgentTaskExtensions.cs Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> * Update dotnet/samples/GettingStarted/A2A/A2AAgent_PollingForTaskCompletion/Program.cs Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> * address pr review feedback * add clarification regarding background responses --------- Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.AI;
|
|
using Microsoft.Shared.Diagnostics;
|
|
|
|
namespace A2A;
|
|
|
|
/// <summary>
|
|
/// Extension methods for the <see cref="AgentTask"/> class.
|
|
/// </summary>
|
|
internal static class A2AAgentTaskExtensions
|
|
{
|
|
internal static IList<ChatMessage>? ToChatMessages(this AgentTask agentTask)
|
|
{
|
|
_ = Throw.IfNull(agentTask);
|
|
|
|
List<ChatMessage>? messages = null;
|
|
|
|
if (agentTask?.Artifacts is { Count: > 0 })
|
|
{
|
|
foreach (var artifact in agentTask.Artifacts)
|
|
{
|
|
(messages ??= []).Add(artifact.ToChatMessage());
|
|
}
|
|
}
|
|
|
|
return messages;
|
|
}
|
|
|
|
internal static IList<AIContent>? ToAIContents(this AgentTask agentTask)
|
|
{
|
|
_ = Throw.IfNull(agentTask);
|
|
|
|
List<AIContent>? aiContents = null;
|
|
|
|
if (agentTask.Artifacts is not null)
|
|
{
|
|
foreach (var artifact in agentTask.Artifacts)
|
|
{
|
|
(aiContents ??= []).AddRange(artifact.ToAIContents());
|
|
}
|
|
}
|
|
|
|
return aiContents;
|
|
}
|
|
}
|