Skip to content

Commit 57e65a7

Browse files
committed
Update SemanticRerankResult.cs
1 parent e8445e7 commit 57e65a7

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

Microsoft.Azure.Cosmos/src/Inference/SemanticRerankResult.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Microsoft.Azure.Cosmos
66
{
77
using System;
88
using System.Collections.Generic;
9+
using System.IO;
910
using System.Net.Http;
1011
using System.Net.Http.Headers;
1112
using System.Threading.Tasks;
@@ -68,14 +69,16 @@ private SemanticRerankResult(
6869
/// <returns>A task that represents the asynchronous operation. The task result contains the deserialized <see cref="SemanticRerankResult"/>.</returns>
6970
internal static async Task<SemanticRerankResult> DeserializeSemanticRerankResultAsync(HttpResponseMessage responseMessage)
7071
{
71-
// Read the response content as a string.
72-
string content = await responseMessage.Content.ReadAsStringAsync();
72+
Stream content = await responseMessage.Content.ReadAsStreamAsync();
7373

7474
// Deserialize the JSON content into a dictionary.
75-
Dictionary<string, object> responseJson = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(content);
76-
77-
// Log the response JSON for debugging purposes.
78-
Console.WriteLine("Response JSON: " + content);
75+
Dictionary<string, object> responseJson;
76+
using (StreamReader streamReader = new StreamReader(content))
77+
using (Newtonsoft.Json.JsonTextReader jsonReader = new Newtonsoft.Json.JsonTextReader(streamReader))
78+
{
79+
Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer();
80+
responseJson = serializer.Deserialize<Dictionary<string, object>>(jsonReader);
81+
}
7982

8083
// Parse the rerank scores, latency, and token usage from the response.
8184
return new SemanticRerankResult(

0 commit comments

Comments
 (0)