forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c586920
commit 43967d3
Showing
18 changed files
with
502 additions
and
36 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
sdk/core/Azure.Core.TestFramework/src/Azure.Core.TestFramework.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 47 additions & 17 deletions
64
...alizer/Azure.AI.Personalizer/src/Generated/Models/PersonalizerRankResult.Serialization.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 13 additions & 2 deletions
15
sdk/personalizer/Azure.AI.Personalizer/src/Generated/MultiSlotClient.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 21 additions & 3 deletions
24
sdk/personalizer/Azure.AI.Personalizer/src/Generated/RankClient.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
sdk/personalizer/Azure.AI.Personalizer/src/Generated/RankProcessor.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
sdk/personalizer/Azure.AI.Personalizer/src/Models/DecisionContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Azure.AI.Personalizer | ||
{ | ||
/// <summary> The Decision Context. </summary> | ||
public class DecisionContext | ||
{ | ||
/// <summary> The Decision Context. </summary> | ||
public DecisionContext() | ||
{ | ||
} | ||
|
||
/// <summary> Initializes a new instance of DecisionContext. </summary> | ||
/// <param name="rankRequest"> Personalizer Rank Options </param> | ||
public DecisionContext(PersonalizerRankOptions rankRequest) | ||
{ | ||
List<string> jsonFeatures = rankRequest.ContextFeatures.Select(f => JsonConvert.SerializeObject(f)).ToList(); | ||
this.SharedFromUrl = jsonFeatures; | ||
|
||
this.Documents = rankRequest.Actions | ||
.Select(action => | ||
{ | ||
string ids = null; | ||
List<string> jsonFeatures = action.Features.Select(f => JsonConvert.SerializeObject(f)).ToList(); | ||
|
||
//if (action.Ids != null) | ||
//{ | ||
// ids = string.Join(",", action.Ids); | ||
//} | ||
|
||
var doc = new DecisionContextDocument | ||
{ | ||
ID = ids, | ||
JSON = jsonFeatures, | ||
}; | ||
|
||
//if (action.ActionSet != null && action.ActionSet?.Id != null) | ||
// doc.Source = new DecisionContextDocumentSource | ||
// { | ||
// Set = action.ActionSet.Id.Id, | ||
// Parameter = action.ActionSet.Parameter | ||
// }; | ||
|
||
return doc; | ||
}).ToArray(); | ||
|
||
//this.Slots = decisionRequest.Slots? | ||
// .Select(slot => new DecisionContextDocument { | ||
// SlotId = slot.Id, | ||
// SlotJson = slot.JsonFeatures | ||
// }).ToArray(); | ||
} | ||
|
||
/// <summary> Properties from url </summary> | ||
[JsonProperty("FromUrl", NullValueHandling = NullValueHandling.Ignore)] | ||
[JsonConverter(typeof(JsonRawStringListConverter))] | ||
#pragma warning disable CA2227 // Collection properties should be read only | ||
public List<string> SharedFromUrl { get; set; } | ||
#pragma warning restore CA2227 // Collection properties should be read only | ||
|
||
/// <summary> Properties of documents </summary> | ||
[JsonProperty("_multi")] | ||
public DecisionContextDocument[] Documents { get; set; } | ||
|
||
/// <summary> Properties of slots </summary> | ||
[JsonProperty("_slots", NullValueHandling = NullValueHandling.Ignore)] | ||
public DecisionContextDocument[] Slots { get; set; } | ||
} | ||
} |
Oops, something went wrong.