-
Notifications
You must be signed in to change notification settings - Fork 3
Basic version of create segment using azure open ai and semantic kernel sdk #6
Conversation
@@ -25,58 +25,58 @@ public static async Task Main() | |||
await Example_00_03_OpenApiSkill_PlayFab.RunAsync().SafeWaitAsync(cancelToken); | |||
|
|||
// Run examples | |||
await Example01_NativeFunctions.RunAsync().SafeWaitAsync(cancelToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can ignore changes to this file for the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will revert. But all the examples will run whenever we run the project, so these are not required and save time if we comment.
.WithAzureTextCompletionService("text-davinci-003", TestConfiguration.AzureOpenAI.Endpoint, TestConfiguration.AzureOpenAI.ApiKey) // Note: Action Planner works with old models like text-davinci-002 | ||
.Build(); | ||
|
||
string folder = RepoFiles.SampleSkillsPath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Console.WriteLine("======== Action Planner ========"); | ||
var kernel2 = new KernelBuilder() | ||
.WithLogger(ConsoleLogger.Logger) | ||
.WithAzureTextCompletionService("text-davinci-003", TestConfiguration.AzureOpenAI.Endpoint, TestConfiguration.AzureOpenAI.ApiKey) // Note: Action Planner works with old models like text-davinci-002 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Create a segment skill | ||
{ | ||
Console.WriteLine("======== Action Planner ========"); | ||
var kernel2 = new KernelBuilder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static async Task CreateSegmentExample(string goal) | ||
{ | ||
// Create a segment skill | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ [](http://example.com/codeflow?start=1&length=8)
remove brackets #Resolved
"Create a segment with name WelcomeEgyptNewPlayers for the players located in the Egypt with entered segment action of email notification?", // With entered segment action | ||
"Create a segment with name EgyptNewPlayers for the players located in the Egypt?" // If the segment already exist, create a segment with name appended with guid | ||
}; | ||
await CreateSegmentExample(goals[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are create operations, same segment name won't work every time for now. Later I will add logic to rename if the segment already exist.
/// </summary> | ||
public sealed class SegmentSkill | ||
{ | ||
ContextVariables contextVariables = new ContextVariables(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
//ToDo: Create payload json using Playfab dlls/sdk | ||
// Set properties to create a Segment using swagger.json | ||
ContextVariables contextVariables = new ContextVariables(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
countryCodes.Add("Australia", "AU"); | ||
countryCodes.Add("Kenya", "KE"); | ||
countryCodes.Add("Egypt", "EG"); | ||
countryCodes.Add("China", "CN"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this shouldn't be needed. With an appropriate description, the model should return an appropriate country codes. Country codes are well known and the model should just have the right documentation to tell it to do so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wav.. It worked just by updating the description :)
string segmentPayload = "{\n \"SegmentModel\": {\n \"Name\": \"<SegmentName>\",\n \"SegmentOrDefinitions\": [\n {\n \"SegmentAndDefinitions\": [\n {\n \"<SegmentDefinition>\": {\n \"LogInDate\": \"<SegmentComparisonValue>T00:00:00Z\",\n \"Comparison\": \"<SegmentComparison>\"\n }\n }\n ]\n }\n ]\n }\n }"; | ||
string locationPayload = "{\n \"SegmentModel\": {\n \"Name\": \"<SegmentName>\",\n \"SegmentOrDefinitions\": [\n {\n \"SegmentAndDefinitions\": [\n {\n \"<SegmentDefinition>\": {\n \"CountryCode\": \"<SegmentComparisonValue>\",\n \"Comparison\": \"<SegmentComparison>\"\n }\n }\n ]\n }\n ]\n }\n }"; | ||
|
||
if (segmentdefinition == "LocationFilter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wav.. It worked just by updating description :)
ContextVariables contextVariables = new(); | ||
contextVariables.Set("content_type", "application/json"); | ||
contextVariables.Set("server_url", TestConfiguration.PlayFab.Endpoint); | ||
string segmentPayload = GetSegmentPayload(segmentname, segmentdefinition, segmentcomparison, segmentcomparisonvalue, segmentaction, segmentactioncode, segmentactionvalue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I will look into it after this pr. Just want to keep some working code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Motivation and Context
This pr contains 3 basic examples of create segments.
Its having create segment skill and make it work with example file.
Description
Contribution Checklist