// </classVariables> // <mainLoop> static void Main(string[] args) { Console.WriteLine($"Welcome to this Personalizer Quickstart!\n" + $"This code will help you understand how to use the Personalizer APIs (multislot rank and multislot reward).\n" + $"Each iteration represents a user interaction and will demonstrate how context, actions, slots, and rewards work.\n" + $"Note: Personalizer AI models learn from a large number of user interactions:\n" + $"You won't be able to tell the difference in what Personalizer returns by simulating a few events by hand.\n" + $"If you want a sample that focuses on seeing how Personalizer learns, see the Python Notebook sample."); int iteration = 1; bool runLoop = true; IList <PersonalizerRankableAction> actions = GetActions(); IList <PersonalizerSlotOptions> slots = GetSlots(); PersonalizerClient client = InitializePersonalizerClient(new Uri(ServiceEndpoint)); do { Console.WriteLine("\nIteration: " + iteration++); string timeOfDayFeature = GetTimeOfDayForContext(); string deviceFeature = GetDeviceForContext(); IList <object> currentContext = GetContext(timeOfDayFeature, deviceFeature); string eventId = Guid.NewGuid().ToString(); var multiSlotRankOptions = new PersonalizerRankMultiSlotOptions(actions, slots, currentContext, eventId); PersonalizerMultiSlotRankResult multiSlotRankResult = client.RankMultiSlot(multiSlotRankOptions); for (int i = 0; i < multiSlotRankResult.Slots.Count(); ++i) { string slotId = multiSlotRankResult.Slots[i].SlotId; Console.WriteLine($"\nPersonalizer service decided you should display: { multiSlotRankResult.Slots[i].RewardActionId} in slot {slotId}. Is this correct? (y/n)"); string answer = GetKey(); if (answer == "Y") { client.RewardMultiSlot(eventId, slotId, 1f); Console.WriteLine("\nGreat! The application will send Personalizer a reward of 1 so it learns from this choice of action for this slot."); } else if (answer == "N") { client.RewardMultiSlot(eventId, slotId, 0f); Console.WriteLine("\nYou didn't like the recommended item. The application will send Personalizer a reward of 0 for this choice of action for this slot."); } else { client.RewardMultiSlot(eventId, slotId, 0f); Console.WriteLine("\nEntered choice is invalid. Service assumes that you didn't like the recommended item."); } } Console.WriteLine("\nPress q to break, any other key to continue:"); runLoop = !(GetKey() == "Q"); } while (runLoop); }