// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Collections.Generic;
using A2A;
namespace Microsoft.Extensions.AI;
///
/// Extension methods for the class.
///
internal static class ChatMessageExtensions
{
internal static Message ToA2AMessage(this IEnumerable messages)
{
List allParts = [];
foreach (var message in messages)
{
if (message.Contents.ToParts() is { Count: > 0 } ps)
{
allParts.AddRange(ps);
}
}
return new Message
{
MessageId = Guid.NewGuid().ToString("N"),
Role = Role.User,
Parts = allParts,
};
}
}