Skip to content

Commit c1ce5a6

Browse files
authored
.Net: Exposing conversion helpers from SK Contents to MEAI Content primitives (#12676)
### Motivation and Context Exposing valuable utilities to convert your existing SK types into MEAI primitives. This can be particularly useful when you are working with SK types and need to convert them to MEAI primitives for custom scenarios or comparison/evaluation purposes. CC: @shyamnamboodiripad
1 parent 7401b45 commit c1ce5a6

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

dotnet/src/SemanticKernel.Abstractions/Contents/ChatMessageContentExtensions.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

3+
using System.Diagnostics.CodeAnalysis;
34
using Microsoft.Extensions.AI;
45

56
namespace Microsoft.SemanticKernel;
67

7-
internal static class ChatMessageContentExtensions
8+
/// <summary>Provides extension methods for <see cref="ChatMessageContent"/>.</summary>
9+
[Experimental("SKEXP0001")]
10+
public static class ChatMessageContentExtensions
811
{
912
/// <summary>Converts a <see cref="ChatMessageContent"/> to a <see cref="ChatMessage"/>.</summary>
1013
/// <remarks>This conversion should not be necessary once SK eventually adopts the shared content types.</remarks>
11-
internal static ChatMessage ToChatMessage(this ChatMessageContent content)
14+
public static ChatMessage ToChatMessage(this ChatMessageContent content)
1215
{
16+
Verify.NotNull(content);
17+
1318
ChatMessage message = new()
1419
{
1520
AdditionalProperties = content.Metadata is not null ? new(content.Metadata) : null,

dotnet/src/SemanticKernel.Abstractions/Contents/StreamingChatMessageContentExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

33
using System.Collections.Generic;
4+
using System.Diagnostics.CodeAnalysis;
45
using System.Text.Json;
56
using Microsoft.Extensions.AI;
67

78
namespace Microsoft.SemanticKernel;
89

910
/// <summary>Provides extension methods for <see cref="StreamingChatMessageContent"/>.</summary>
10-
internal static class StreamingChatMessageContentExtensions
11+
[Experimental("SKEXP0001")]
12+
public static class StreamingChatMessageContentExtensions
1113
{
1214
/// <summary>Converts a <see cref="StreamingChatMessageContent"/> to a <see cref="ChatResponseUpdate"/>.</summary>
1315
/// <remarks>This conversion should not be necessary once SK eventually adopts the shared content types.</remarks>
14-
internal static ChatResponseUpdate ToChatResponseUpdate(this StreamingChatMessageContent content)
16+
public static ChatResponseUpdate ToChatResponseUpdate(this StreamingChatMessageContent content)
1517
{
18+
Verify.NotNull(content);
19+
1620
ChatResponseUpdate update = new()
1721
{
1822
AdditionalProperties = content.Metadata is not null ? new AdditionalPropertiesDictionary(content.Metadata) : null,

0 commit comments

Comments
 (0)