diff --git a/src/Custom/Chat/ChatCompletion.cs b/src/Custom/Chat/ChatCompletion.cs index 0efd2e53..b53f8d5a 100644 --- a/src/Custom/Chat/ChatCompletion.cs +++ b/src/Custom/Chat/ChatCompletion.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text; namespace OpenAI.Chat; @@ -65,5 +66,14 @@ public partial class ChatCompletion /// Returns text representation of the first part of the first choice. /// /// - public override string ToString() => Content[0].Text; + public override string ToString() + { + IReadOnlyList content = Content; + if (content.Count == 1) + { + return content[0].ToString(); + } + + return string.Join(Environment.NewLine, content); + } } diff --git a/src/Custom/Chat/ChatMessageContentPart.cs b/src/Custom/Chat/ChatMessageContentPart.cs index f76b7842..fd850583 100644 --- a/src/Custom/Chat/ChatMessageContentPart.cs +++ b/src/Custom/Chat/ChatMessageContentPart.cs @@ -129,7 +129,13 @@ public static ChatMessageContentPart CreateImageMessageContentPart(BinaryData im /// Returns text representation of this part. /// /// - public override string ToString() => Text; + public override string ToString() + { + if (Kind == ChatMessageContentPartKind.Text) { + return String.IsNullOrWhiteSpace(Text) ? "" : Text; + } + return $"<{Kind.ToString().ToLowerInvariant()}>"; + } /// /// Implicitly creates a new instance from an item of plain text.