Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cleaned up usings
  • Loading branch information
KrzysztofCwalina committed Jun 27, 2025
commit f8d5c6f86873342cf95a72df14a740951900b8ab
7 changes: 3 additions & 4 deletions docs/guides/mcp/chat_with_mcp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#:package ModelContextProtocol.Core@*-*
#:property PublishAot=false

using System.Text.Json;
using ModelContextProtocol;
using ModelContextProtocol.Client;
using OpenAI.Chat;
Expand Down Expand Up @@ -68,9 +67,9 @@ public static ChatMessage ToMessage(this ChatToolCall openaiCall, IEnumerable<Mi
List<ChatMessageContentPart> parts = new();
foreach (Microsoft.Extensions.AI.AIContent content in contents)
{
string serialized = JsonSerializer.Serialize(content.RawRepresentation);
using JsonDocument json = JsonDocument.Parse(serialized);
JsonElement text = json.RootElement.GetProperty("text");
string serialized = System.Text.Json.JsonSerializer.Serialize(content.RawRepresentation);
using System.Text.Json.JsonDocument json = System.Text.Json.JsonDocument.Parse(serialized);
System.Text.Json.JsonElement text = json.RootElement.GetProperty("text");
string textValue = text.GetString() ?? string.Empty;
parts.Add(ChatMessageContentPart.CreateTextPart(textValue));
}
Expand Down