// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
using System.Linq;
using Microsoft.SemanticKernel;
using ModelContextProtocol.Protocol;
namespace MCPClient;
///
/// Extension methods for .
///
public static class SamplingMessageExtensions
{
///
/// Converts a collection of to a list of .
///
/// The collection of to convert.
/// The corresponding list of .
public static List ToChatMessageContents(this IEnumerable samplingMessages)
{
return [.. samplingMessages.Select(ToChatMessageContent)];
}
///
/// Converts a to a .
///
/// The to convert.
/// The corresponding .
public static ChatMessageContent ToChatMessageContent(this SamplingMessage message)
{
return new ChatMessageContent(role: message.Role.ToAuthorRole(), items: [message.Content.ToKernelContent()]);
}
}