You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -131,6 +168,59 @@ public static IList<PromptMessage> ToPromptMessages(this ChatMessage chatMessage
131
168
/// <summary>Creates a new <see cref="AIContent"/> from the content of a <see cref="Content"/>.</summary>
132
169
/// <param name="content">The <see cref="Content"/> to convert.</param>
133
170
/// <returns>The created <see cref="AIContent"/>.</returns>
171
+
/// <remarks>
172
+
/// <para>
173
+
/// This method converts Model Context Protocol content types to the equivalent Microsoft.Extensions.AI
174
+
/// content types, enabling seamless integration between the protocol and AI client libraries.
175
+
/// </para>
176
+
/// <para>
177
+
/// The conversion follows these rules:
178
+
/// <list type="bullet">
179
+
/// <item><description>When <see cref="Content.Type"/> is "image" or "audio" with data → <see cref="DataContent"/> with base64-decoded data and preserved MIME type</description></item>
180
+
/// <item><description>When <see cref="Content.Resource"/> is not null → Uses <see cref="ToAIContent(ResourceContents)"/> for the resource</description></item>
181
+
/// <item><description>Otherwise → <see cref="TextContent"/> using the text content</description></item>
182
+
/// </list>
183
+
/// </para>
184
+
/// <para>
185
+
/// The original <see cref="Content"/> object is stored in the <see cref="AIContent.RawRepresentation"/>
186
+
/// property, enabling round-trip conversions if needed.
@@ -157,6 +247,65 @@ public static AIContent ToAIContent(this Content content)
157
247
/// <summary>Creates a new <see cref="AIContent"/> from the content of a <see cref="ResourceContents"/>.</summary>
158
248
/// <param name="content">The <see cref="ResourceContents"/> to convert.</param>
159
249
/// <returns>The created <see cref="AIContent"/>.</returns>
250
+
/// <remarks>
251
+
/// <para>
252
+
/// This method converts Model Context Protocol resource types to the equivalent Microsoft.Extensions.AI
253
+
/// content types, enabling seamless integration between the protocol and AI client libraries.
254
+
/// </para>
255
+
/// <para>
256
+
/// The conversion follows these rules:
257
+
/// <list type="bullet">
258
+
/// <item><description><see cref="BlobResourceContents"/> → <see cref="DataContent"/> with base64-decoded data and preserved MIME type</description></item>
259
+
/// <item><description><see cref="TextResourceContents"/> → <see cref="TextContent"/> with the text preserved</description></item>
260
+
/// </list>
261
+
/// </para>
262
+
/// <para>
263
+
/// The URI of the resource is preserved in the <see cref="AIContent.AdditionalProperties"/> dictionary
264
+
/// with the key "uri", allowing applications to maintain resource identifiers.
265
+
/// </para>
266
+
/// <para>
267
+
/// The original <see cref="ResourceContents"/> object is stored in the <see cref="AIContent.RawRepresentation"/>
268
+
/// property, enabling round-trip conversions if needed.
269
+
/// </para>
270
+
/// </remarks>
271
+
/// <example>
272
+
/// <code>
273
+
/// // Convert a TextResourceContents to AIContent
0 commit comments