diff --git a/Microsoft.Azure.Cosmos/src/Inference/RerankScore.cs b/Microsoft.Azure.Cosmos/src/Inference/RerankScore.cs index 407658cbe7..15c7200b7d 100644 --- a/Microsoft.Azure.Cosmos/src/Inference/RerankScore.cs +++ b/Microsoft.Azure.Cosmos/src/Inference/RerankScore.cs @@ -18,7 +18,7 @@ class RerankScore /// /// Gets the document content or identifier that was reranked. /// - public object Document { get; } + public string Document { get; } /// /// Gets the score assigned to the document after reranking. @@ -36,7 +36,7 @@ class RerankScore /// The document content or identifier. /// The reranked score for the document. /// The original index of the document. - public RerankScore(object document, double score, int index) + public RerankScore(string document, double score, int index) { this.Document = document; this.Score = score; diff --git a/Microsoft.Azure.Cosmos/src/Inference/SemanticRerankResult.cs b/Microsoft.Azure.Cosmos/src/Inference/SemanticRerankResult.cs index e228f8d0fe..0f1208d7e8 100644 --- a/Microsoft.Azure.Cosmos/src/Inference/SemanticRerankResult.cs +++ b/Microsoft.Azure.Cosmos/src/Inference/SemanticRerankResult.cs @@ -83,17 +83,19 @@ internal static async Task DeserializeSemanticRerankResult { foreach (JsonElement item in scoresElement.EnumerateArray()) { - object document = null; + string document = string.Empty; if (item.TryGetProperty("document", out JsonElement docElement)) { // Try to deserialize as an object switch (docElement.ValueKind) { case JsonValueKind.Object: - document = JsonSerializer.Deserialize>(docElement.GetRawText()); + document = docElement.GetRawText(); break; - case JsonValueKind.Null: - document = null; + case JsonValueKind.String: + document = docElement.GetString(); + break; + default: break; } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.net6.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.net6.json index 59663795dd..39964c87a1 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.net6.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.net6.json @@ -1452,22 +1452,22 @@ "Attributes": [], "MethodInfo": "Int32 Index;CanRead:True;CanWrite:False;Int32 get_Index();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, - "System.Object Document": { + "System.String Document": { "Type": "Property", "Attributes": [], - "MethodInfo": "System.Object Document;CanRead:True;CanWrite:False;System.Object get_Document();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + "MethodInfo": "System.String Document;CanRead:True;CanWrite:False;System.String get_Document();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, - "System.Object get_Document()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "System.String get_Document()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { "Type": "Method", "Attributes": [ "CompilerGeneratedAttribute" ], - "MethodInfo": "System.Object get_Document();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + "MethodInfo": "System.String get_Document();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, - "Void .ctor(System.Object, Double, Int32)": { + "Void .ctor(System.String, Double, Int32)": { "Type": "Constructor", "Attributes": [], - "MethodInfo": "Void .ctor(System.Object, Double, Int32)" + "MethodInfo": "Void .ctor(System.String, Double, Int32)" } }, "NestedTypes": {}