// Copyright (c) Microsoft. All rights reserved. using System.Collections.Generic; using System.Linq; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.ChatCompletion; using ModelContextProtocol.Protocol; namespace MCPClient; /// /// Extension methods for . /// internal static class PromptResultExtensions { /// /// Converts a to chat message contents. /// /// The prompt result to convert. /// The corresponding . public static IList ToChatMessageContents(this GetPromptResult result) { return [.. result.Messages.Select(ToChatMessageContent)]; } /// /// Converts a to a . /// /// The to convert. /// The corresponding . public static ChatMessageContent ToChatMessageContent(this PromptMessage message) { return new ChatMessageContent(role: message.Role.ToAuthorRole(), items: [message.Content.ToKernelContent()]); } }