diff --git a/examples/Chat/Example08_ChatSerialization.cs b/examples/Chat/Example08_ChatSerialization.cs index 2fd2df195..da3467cc4 100644 --- a/examples/Chat/Example08_ChatSerialization.cs +++ b/examples/Chat/Example08_ChatSerialization.cs @@ -39,7 +39,7 @@ public static BinaryData SerializeMessages(IEnumerable messages) writer.WriteEndArray(); writer.Flush(); - return BinaryData.FromBytes(stream.ToArray()); + return BinaryData.FromBytes(stream.GetBuffer().AsMemory(0, (int)stream.Length)); } #endregion diff --git a/src/Custom/Embeddings/EmbeddingClient.cs b/src/Custom/Embeddings/EmbeddingClient.cs index cf99c7405..f58018a50 100644 --- a/src/Custom/Embeddings/EmbeddingClient.cs +++ b/src/Custom/Embeddings/EmbeddingClient.cs @@ -217,7 +217,7 @@ private void CreateEmbeddingGenerationOptions(string input, ref EmbeddingGenerat writer.WriteStringValue(input); writer.Flush(); - options.Input = BinaryData.FromBytes(stream.ToArray()); + options.Input = BinaryData.FromBytes(stream.GetBuffer().AsMemory(0, (int)stream.Length)); options.Model = _model; options.EncodingFormat = InternalCreateEmbeddingRequestEncodingFormat.Base64; } @@ -237,7 +237,7 @@ private void CreateEmbeddingGenerationOptions(IEnumerable inputs, ref Em writer.WriteEndArray(); writer.Flush(); - options.Input = BinaryData.FromBytes(stream.ToArray()); + options.Input = BinaryData.FromBytes(stream.GetBuffer().AsMemory(0, (int)stream.Length)); options.Model = _model; options.EncodingFormat = InternalCreateEmbeddingRequestEncodingFormat.Base64; } @@ -264,7 +264,7 @@ private void CreateEmbeddingGenerationOptions(IEnumerable> i writer.WriteEndArray(); writer.Flush(); - options.Input = BinaryData.FromBytes(stream.ToArray()); + options.Input = BinaryData.FromBytes(stream.GetBuffer().AsMemory(0, (int)stream.Length)); options.Model = _model; options.EncodingFormat = InternalCreateEmbeddingRequestEncodingFormat.Base64; } diff --git a/src/Custom/Moderations/ModerationClient.cs b/src/Custom/Moderations/ModerationClient.cs index e450ec874..beae28782 100644 --- a/src/Custom/Moderations/ModerationClient.cs +++ b/src/Custom/Moderations/ModerationClient.cs @@ -170,7 +170,7 @@ private void CreateModerationOptions(string input, ref ModerationOptions options writer.WriteStringValue(input); writer.Flush(); - options.Input = BinaryData.FromBytes(stream.ToArray()); + options.Input = BinaryData.FromBytes(stream.GetBuffer().AsMemory(0, (int)stream.Length)); options.Model = _model; } @@ -189,7 +189,7 @@ private void CreateModerationOptions(IEnumerable inputs, ref ModerationO writer.WriteEndArray(); writer.Flush(); - options.Input = BinaryData.FromBytes(stream.ToArray()); + options.Input = BinaryData.FromBytes(stream.GetBuffer().AsMemory(0, (int)stream.Length)); options.Model = _model; } }