From c19b91f3b52b69938598f2101366f6be0872ed14 Mon Sep 17 00:00:00 2001 From: qasimikram Date: Mon, 8 Jul 2024 21:41:20 +0200 Subject: [PATCH 1/5] Tests Added --- .../Test/EntityText/app.json | 29 +++ .../src/MktTextAccuracyBCCT.Codeunit.al | 240 ++++++++++++++++++ .../src/MktTextRedTeamBCCT.Codeunit.al | 156 ++++++++++++ 3 files changed, 425 insertions(+) create mode 100644 src/System Application/Test/EntityText/app.json create mode 100644 src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al create mode 100644 src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al diff --git a/src/System Application/Test/EntityText/app.json b/src/System Application/Test/EntityText/app.json new file mode 100644 index 0000000000..f15d2fc885 --- /dev/null +++ b/src/System Application/Test/EntityText/app.json @@ -0,0 +1,29 @@ +{ + "id": "fb54748b-71f1-4a4a-9dc8-8f1d32a60c8d", + "name": "Entity Text Test", + "publisher": "Microsoft", + "brief": "", + "description": "Tests for Entity Text", + "version": "25.0.0.0", + "privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724011", + "EULA": "https://go.microsoft.com/fwlink/?LinkId=724011", + "help": "https://go.microsoft.com/fwlink/?LinkId=724011", + "url": "https://go.microsoft.com/fwlink/?LinkId=724011", + "logo": "", + "dependencies": [ + { + "id": "2156302a-872f-4568-be0b-60968696f0d5", + "name": "AI Test Toolkit", + "publisher": "Microsoft", + "version": "25.0.0.0" + } + ], + "platform": "24.0.0.0", + "target": "OnPrem", + "idRanges": [ + { + "from": 134640, + "to": 134641 + } + ] +} \ No newline at end of file diff --git a/src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al b/src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al new file mode 100644 index 0000000000..52633c9b48 --- /dev/null +++ b/src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al @@ -0,0 +1,240 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.Test.EntityText; + +using System.TestTools.AITestToolkit; +using System.Text; + +codeunit 134640 "Mkt Text Accuracy BCCT" +{ + Subtype = Test; + + [Test] + procedure TaglineParagraphInspiring() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + Category: Text; + InputPrompt: Text; + Response: Text; + begin + InputPrompt := AITestContext.GetInput(); + Facts := LineInputToDictionary(InputPrompt); + Format := Enum::"Entity Text Format"::TaglineParagraph; + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Inspiring, Format, Enum::"Entity Text Emphasis"::None); + + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts, Category), Category, Response, Enum::"Entity Text Tone"::Inspiring, Format)); + end; + + [Test] + procedure TaglineParagraphFormal() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + Category: Text; + InputPrompt: Text; + Response: Text; + begin + InputPrompt := AITestContext.GetInput(); + Facts := LineInputToDictionary(InputPrompt); + Format := Enum::"Entity Text Format"::TaglineParagraph; + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Formal, Format, Enum::"Entity Text Emphasis"::None); + + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts, Category), Category, Response, Enum::"Entity Text Tone"::Formal, Format)); + end; + + [Test] + procedure TaglineParagraphCreative() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + Category: Text; + InputPrompt: Text; + Response: Text; + begin + InputPrompt := AITestContext.GetInput(); + Facts := LineInputToDictionary(InputPrompt); + Format := Enum::"Entity Text Format"::TaglineParagraph; + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Creative, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts, Category), Category, Response, Enum::"Entity Text Tone"::Creative, Format)); + end; + + [Test] + procedure TaglineInspiring() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + Category: Text; + InputPrompt: Text; + Response: Text; + begin + InputPrompt := AITestContext.GetInput(); + Facts := LineInputToDictionary(InputPrompt); + Format := Enum::"Entity Text Format"::Tagline; + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Inspiring, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts, Category), Category, Response, Enum::"Entity Text Tone"::Inspiring, Format)); + end; + + [Test] + procedure TaglineFormal() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + Category: Text; + InputPrompt: Text; + Response: Text; + begin + InputPrompt := AITestContext.GetInput(); + Facts := LineInputToDictionary(InputPrompt); + Format := Enum::"Entity Text Format"::Tagline; + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Formal, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts, Category), Category, Response, Enum::"Entity Text Tone"::Formal, Format)); + end; + + [Test] + procedure TaglineCreative() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + Category: Text; + InputPrompt: Text; + Response: Text; + begin + InputPrompt := AITestContext.GetInput(); + Facts := LineInputToDictionary(InputPrompt); + Format := Enum::"Entity Text Format"::Tagline; + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Creative, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts, Category), Category, Response, Enum::"Entity Text Tone"::Creative, Format)); + end; + + [Test] + procedure BriefInspiring() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + Category: Text; + InputPrompt: Text; + Response: Text; + begin + InputPrompt := AITestContext.GetInput(); + Facts := LineInputToDictionary(InputPrompt); + Format := Enum::"Entity Text Format"::Brief; + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Inspiring, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts, Category), Category, Response, Enum::"Entity Text Tone"::Inspiring, Format)); + end; + + [Test] + procedure BriefFormal() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + Category: Text; + InputPrompt: Text; + Response: Text; + begin + InputPrompt := AITestContext.GetInput(); + Facts := LineInputToDictionary(InputPrompt); + Format := Enum::"Entity Text Format"::Brief; + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Formal, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts, Category), Category, Response, Enum::"Entity Text Tone"::Formal, Format)); + end; + + [Test] + procedure BriefCreative() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + Category: Text; + InputPrompt: Text; + Response: Text; + begin + InputPrompt := AITestContext.GetInput(); + Facts := LineInputToDictionary(InputPrompt); + Format := Enum::"Entity Text Format"::Brief; + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Creative, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts, Category), Category, Response, Enum::"Entity Text Tone"::Creative, Format)); + end; + + local procedure BuildFactsText(var Facts: Dictionary of [Text, Text]; var Category: Text): Text + var + FactTemplateTxt: Label '- %1: %2%3', Locked = true; + FactKey: Text; + FactValue: Text; + FactsList: Text; + NewLineChar: Char; + MaxFacts: Integer; + TotalFacts: Integer; + MaxFactLength: Integer; + begin + NewLineChar := 10; + TotalFacts := Facts.Count(); + + MaxFacts := 20; + MaxFactLength := 250; + + TotalFacts := 0; + foreach FactKey in Facts.Keys() do begin + if TotalFacts < MaxFacts then begin + Facts.Get(FactKey, FactValue); + FactKey := FactKey.Replace(NewLineChar, '').Trim(); + FactValue := FactValue.Replace(NewLineChar, '').Trim(); + if (Category = '') and FactKey.Contains('Category') then + Category := FactValue + else + FactsList += StrSubstNo(FactTemplateTxt, CopyStr(FactKey, 1, MaxFactLength), CopyStr(FactValue, 1, MaxFactLength), NewLineChar); + end; + TotalFacts += 1; + end; + exit(FactsList); + end; + + local procedure LineInputToDictionary(Input: Text): Dictionary of [Text, Text]; + var + Attributes: Dictionary of [Text, Text]; + InputJson: JsonObject; + AttributeValueToken: JsonToken; + AttributeKey: Text; + begin + InputJson.ReadFrom(Input); + + foreach AttributeKey in InputJson.Keys() do begin + InputJson.Get(AttributeKey, AttributeValueToken); + Attributes.Add(AttributeKey, AttributeValueToken.AsValue().AsText()); + end; + exit(Attributes); + end; + + local procedure PrepareOutput(Facts: Text; Category: Text; Response: Text; Tone: Enum "Entity Text Tone"; Format: Enum "Entity Text Format"): Text; + var + Context: Text; + FormatLbl: Label '{"question": "METAPROMPT: %1", "answer": "%2", "context": "%3", "ground_truth": "%4", "tone": "%5", "format" : "%6"}', Comment = '%1= Input Prompt, %2= Response Prompt, %3= Context, %4= Ground Truth, %5= Tone, %6= Format'; + EncodedNewlineTok: Label '
', Locked = true; + NewLineChar: Char; + begin + NewLineChar := 10; + Context := 'Here are some facts about the item:

' + Facts.Replace(NewLineChar, EncodedNewlineTok) + '
This is in the category of: ' + Category.Replace(NewLineChar, EncodedNewlineTok); + exit(StrSubstNo(FormatLbl, Facts.Replace(NewLineChar, EncodedNewlineTok), Response.Replace(NewLineChar, EncodedNewlineTok), Context, '', Tone.Names.Get(Tone.Ordinals.IndexOf(Tone.AsInteger())), Format.Names.Get(Format.Ordinals.IndexOf(Format.AsInteger())))); + end; + +} \ No newline at end of file diff --git a/src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al b/src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al new file mode 100644 index 0000000000..a5ce1af200 --- /dev/null +++ b/src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al @@ -0,0 +1,156 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.Test.EntityText; + +using System.TestTools.AITestToolkit; +using System.Text; + +codeunit 134641 "Mkt Text RedTeam BCCT" +{ + Subtype = Test; + + [Test] + procedure TaglineTest() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + InputJson: JsonObject; + InputToken: JsonToken; + InputPrompt: Text; + Response: Text; + begin + InputJson.ReadFrom(AITestContext.GetInput()); + InputJson.Get('inputPrompt', InputToken); + InputPrompt := InputToken.AsValue().AsText(); + + Format := Enum::"Entity Text Format"::Tagline; + AddFacts(Facts, InputPrompt, Format); + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Inspiring, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts), Response, Enum::"Entity Text Tone"::Inspiring, Format)); + end; + + [Test] + procedure TaglineParagraphTest() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + InputJson: JsonObject; + InputToken: JsonToken; + InputPrompt: Text; + Response: Text; + begin + InputJson.ReadFrom(AITestContext.GetInput()); + InputJson.Get('inputPrompt', InputToken); + InputPrompt := InputToken.AsValue().AsText(); + + Format := Enum::"Entity Text Format"::TaglineParagraph; + AddFacts(Facts, InputPrompt, Format); + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Inspiring, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts), Response, Enum::"Entity Text Tone"::Inspiring, Format)); + end; + + [Test] + procedure ParagraphTest() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + InputJson: JsonObject; + InputToken: JsonToken; + InputPrompt: Text; + Response: Text; + begin + InputJson.ReadFrom(AITestContext.GetInput()); + InputJson.Get('inputPrompt', InputToken); + InputPrompt := InputToken.AsValue().AsText(); + + Format := Enum::"Entity Text Format"::Paragraph; + AddFacts(Facts, InputPrompt, Format); + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Inspiring, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts), Response, Enum::"Entity Text Tone"::Inspiring, Format)); + end; + + [Test] + procedure BriefTest() + var + AITestContext: Codeunit "AIT Test Context"; + EntityTextCod: Codeunit "Entity Text"; + Facts: Dictionary of [Text, Text]; + Format: Enum "Entity Text Format"; + InputJson: JsonObject; + InputToken: JsonToken; + InputPrompt: Text; + Response: Text; + begin + InputJson.ReadFrom(AITestContext.GetInput()); + InputJson.Get('inputPrompt', InputToken); + InputPrompt := InputToken.AsValue().AsText(); + + Format := Enum::"Entity Text Format"::Brief; + AddFacts(Facts, InputPrompt, Format); + Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Inspiring, Format, Enum::"Entity Text Emphasis"::None); + AITestContext.SetTestOutput(PrepareOutput(BuildFactsText(Facts), Response, Enum::"Entity Text Tone"::Inspiring, Format)); + end; + + local procedure AddFacts(var Facts: Dictionary of [Text, Text]; InputPrompt: Text; Format: Enum "Entity Text Format") + begin + Facts.Add('Name', InputPrompt); + Facts.Add(InputPrompt, InputPrompt); + if Format <> Enum::"Entity Text Format"::Tagline then begin + Facts.Add('Fact', InputPrompt); + Facts.Add('No', InputPrompt); + end; + end; + + local procedure BuildFactsText(var Facts: Dictionary of [Text, Text]): Text + var + FactTemplateTxt: Label '- %1: %2%3', Locked = true; + FactKey: Text; + FactValue: Text; + FactsList: Text; + NewLineChar: Char; + MaxFacts: Integer; + TotalFacts: Integer; + MaxFactLength: Integer; + begin + NewLineChar := 10; + TotalFacts := Facts.Count(); + + MaxFacts := 20; + MaxFactLength := 250; + + TotalFacts := 0; + foreach FactKey in Facts.Keys() do begin + if TotalFacts < MaxFacts then begin + Facts.Get(FactKey, FactValue); + FactKey := FactKey.Replace(NewLineChar, '').Trim(); + FactValue := FactValue.Replace(NewLineChar, '').Trim(); + FactsList += StrSubstNo(FactTemplateTxt, CopyStr(FactKey, 1, MaxFactLength), CopyStr(FactValue, 1, MaxFactLength), NewLineChar); + end; + TotalFacts += 1; + end; + exit(FactsList); + end; + + local procedure PrepareOutput(Facts: Text; Response: Text; Tone: Enum "Entity Text Tone"; Format: Enum "Entity Text Format"): Text; + var + Context: Text; + FormatLbl: Label '{"question": "METAPROMPT %1", "answer": "%2", "context": "%3", "ground_truth": "%4", "tone": "%5", "format" : "%6"}', Comment = '%1= Input Prompt, %2= Response Prompt, %3= Context, %4= Ground Truth, %5= Tone, %6= Format'; + EncodedNewlineTok: Label '
', Locked = true; + NewLineChar: Char; + begin + NewLineChar := 10; + Context := 'Here are some facts about the item:

' + Facts.Replace(NewLineChar, EncodedNewlineTok); + exit(StrSubstNo(FormatLbl, Facts.Replace(NewLineChar, EncodedNewlineTok), Response.Replace(NewLineChar, EncodedNewlineTok), Context, '', Tone.Names.Get(Tone.Ordinals.IndexOf(Tone.AsInteger())), Format.Names.Get(Format.Ordinals.IndexOf(Format.AsInteger())))); + end; + + +} \ No newline at end of file From f4ae6f75b96cfa1fb18fdb9e3beb76173212fdeb Mon Sep 17 00:00:00 2001 From: qasimikram Date: Tue, 9 Jul 2024 11:21:14 +0200 Subject: [PATCH 2/5] Tests Fixed --- .../Test/EntityText/app.json | 2 +- .../src/MktTextAccuracyBCCT.Codeunit.al | 18 +++++++++--------- .../src/MktTextRedTeamBCCT.Codeunit.al | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/System Application/Test/EntityText/app.json b/src/System Application/Test/EntityText/app.json index f15d2fc885..8cdeabc428 100644 --- a/src/System Application/Test/EntityText/app.json +++ b/src/System Application/Test/EntityText/app.json @@ -18,7 +18,7 @@ "version": "25.0.0.0" } ], - "platform": "24.0.0.0", + "platform": "25.0.0.0", "target": "OnPrem", "idRanges": [ { diff --git a/src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al b/src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al index 52633c9b48..c07178b09d 100644 --- a/src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al +++ b/src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al @@ -23,7 +23,7 @@ codeunit 134640 "Mkt Text Accuracy BCCT" InputPrompt: Text; Response: Text; begin - InputPrompt := AITestContext.GetInput(); + InputPrompt := AITestContext.GetInput().ValueAsText(); Facts := LineInputToDictionary(InputPrompt); Format := Enum::"Entity Text Format"::TaglineParagraph; Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Inspiring, Format, Enum::"Entity Text Emphasis"::None); @@ -42,7 +42,7 @@ codeunit 134640 "Mkt Text Accuracy BCCT" InputPrompt: Text; Response: Text; begin - InputPrompt := AITestContext.GetInput(); + InputPrompt := AITestContext.GetInput().ValueAsText(); Facts := LineInputToDictionary(InputPrompt); Format := Enum::"Entity Text Format"::TaglineParagraph; Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Formal, Format, Enum::"Entity Text Emphasis"::None); @@ -61,7 +61,7 @@ codeunit 134640 "Mkt Text Accuracy BCCT" InputPrompt: Text; Response: Text; begin - InputPrompt := AITestContext.GetInput(); + InputPrompt := AITestContext.GetInput().ValueAsText(); Facts := LineInputToDictionary(InputPrompt); Format := Enum::"Entity Text Format"::TaglineParagraph; Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Creative, Format, Enum::"Entity Text Emphasis"::None); @@ -79,7 +79,7 @@ codeunit 134640 "Mkt Text Accuracy BCCT" InputPrompt: Text; Response: Text; begin - InputPrompt := AITestContext.GetInput(); + InputPrompt := AITestContext.GetInput().ValueAsText(); Facts := LineInputToDictionary(InputPrompt); Format := Enum::"Entity Text Format"::Tagline; Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Inspiring, Format, Enum::"Entity Text Emphasis"::None); @@ -97,7 +97,7 @@ codeunit 134640 "Mkt Text Accuracy BCCT" InputPrompt: Text; Response: Text; begin - InputPrompt := AITestContext.GetInput(); + InputPrompt := AITestContext.GetInput().ValueAsText(); Facts := LineInputToDictionary(InputPrompt); Format := Enum::"Entity Text Format"::Tagline; Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Formal, Format, Enum::"Entity Text Emphasis"::None); @@ -115,7 +115,7 @@ codeunit 134640 "Mkt Text Accuracy BCCT" InputPrompt: Text; Response: Text; begin - InputPrompt := AITestContext.GetInput(); + InputPrompt := AITestContext.GetInput().ValueAsText(); Facts := LineInputToDictionary(InputPrompt); Format := Enum::"Entity Text Format"::Tagline; Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Creative, Format, Enum::"Entity Text Emphasis"::None); @@ -133,7 +133,7 @@ codeunit 134640 "Mkt Text Accuracy BCCT" InputPrompt: Text; Response: Text; begin - InputPrompt := AITestContext.GetInput(); + InputPrompt := AITestContext.GetInput().ValueAsText(); Facts := LineInputToDictionary(InputPrompt); Format := Enum::"Entity Text Format"::Brief; Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Inspiring, Format, Enum::"Entity Text Emphasis"::None); @@ -151,7 +151,7 @@ codeunit 134640 "Mkt Text Accuracy BCCT" InputPrompt: Text; Response: Text; begin - InputPrompt := AITestContext.GetInput(); + InputPrompt := AITestContext.GetInput().ValueAsText(); Facts := LineInputToDictionary(InputPrompt); Format := Enum::"Entity Text Format"::Brief; Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Formal, Format, Enum::"Entity Text Emphasis"::None); @@ -169,7 +169,7 @@ codeunit 134640 "Mkt Text Accuracy BCCT" InputPrompt: Text; Response: Text; begin - InputPrompt := AITestContext.GetInput(); + InputPrompt := AITestContext.GetInput().ValueAsText(); Facts := LineInputToDictionary(InputPrompt); Format := Enum::"Entity Text Format"::Brief; Response := EntityTextCod.GenerateText(Facts, Enum::"Entity Text Tone"::Creative, Format, Enum::"Entity Text Emphasis"::None); diff --git a/src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al b/src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al index a5ce1af200..db1d5d430a 100644 --- a/src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al +++ b/src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al @@ -24,7 +24,7 @@ codeunit 134641 "Mkt Text RedTeam BCCT" InputPrompt: Text; Response: Text; begin - InputJson.ReadFrom(AITestContext.GetInput()); + InputJson.ReadFrom(AITestContext.GetInput().ValueAsText()); InputJson.Get('inputPrompt', InputToken); InputPrompt := InputToken.AsValue().AsText(); @@ -46,7 +46,7 @@ codeunit 134641 "Mkt Text RedTeam BCCT" InputPrompt: Text; Response: Text; begin - InputJson.ReadFrom(AITestContext.GetInput()); + InputJson.ReadFrom(AITestContext.GetInput().ValueAsText()); InputJson.Get('inputPrompt', InputToken); InputPrompt := InputToken.AsValue().AsText(); @@ -68,7 +68,7 @@ codeunit 134641 "Mkt Text RedTeam BCCT" InputPrompt: Text; Response: Text; begin - InputJson.ReadFrom(AITestContext.GetInput()); + InputJson.ReadFrom(AITestContext.GetInput().ValueAsText()); InputJson.Get('inputPrompt', InputToken); InputPrompt := InputToken.AsValue().AsText(); @@ -90,7 +90,7 @@ codeunit 134641 "Mkt Text RedTeam BCCT" InputPrompt: Text; Response: Text; begin - InputJson.ReadFrom(AITestContext.GetInput()); + InputJson.ReadFrom(AITestContext.GetInput().ValueAsText()); InputJson.Get('inputPrompt', InputToken); InputPrompt := InputToken.AsValue().AsText(); From 2b1ed5f0a7ce768267f34f3593dec79124da7b09 Mon Sep 17 00:00:00 2001 From: qasimikram Date: Tue, 9 Jul 2024 11:38:53 +0200 Subject: [PATCH 3/5] Rename test --- ...tAccuracyBCCT.Codeunit.al => MktTextAccuracyAIT.Codeunit.al} | 2 +- ...extRedTeamBCCT.Codeunit.al => MktTextRedTeamAIT.Codeunit.al} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/System Application/Test/EntityText/src/{MktTextAccuracyBCCT.Codeunit.al => MktTextAccuracyAIT.Codeunit.al} (99%) rename src/System Application/Test/EntityText/src/{MktTextRedTeamBCCT.Codeunit.al => MktTextRedTeamAIT.Codeunit.al} (99%) diff --git a/src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al b/src/System Application/Test/EntityText/src/MktTextAccuracyAIT.Codeunit.al similarity index 99% rename from src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al rename to src/System Application/Test/EntityText/src/MktTextAccuracyAIT.Codeunit.al index c07178b09d..fa50bbe43a 100644 --- a/src/System Application/Test/EntityText/src/MktTextAccuracyBCCT.Codeunit.al +++ b/src/System Application/Test/EntityText/src/MktTextAccuracyAIT.Codeunit.al @@ -8,7 +8,7 @@ namespace System.Test.EntityText; using System.TestTools.AITestToolkit; using System.Text; -codeunit 134640 "Mkt Text Accuracy BCCT" +codeunit 134640 "Mkt Text Accuracy AIT" { Subtype = Test; diff --git a/src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al b/src/System Application/Test/EntityText/src/MktTextRedTeamAIT.Codeunit.al similarity index 99% rename from src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al rename to src/System Application/Test/EntityText/src/MktTextRedTeamAIT.Codeunit.al index db1d5d430a..4c211adb48 100644 --- a/src/System Application/Test/EntityText/src/MktTextRedTeamBCCT.Codeunit.al +++ b/src/System Application/Test/EntityText/src/MktTextRedTeamAIT.Codeunit.al @@ -8,7 +8,7 @@ namespace System.Test.EntityText; using System.TestTools.AITestToolkit; using System.Text; -codeunit 134641 "Mkt Text RedTeam BCCT" +codeunit 134641 "Mkt Text RedTeam AIT" { Subtype = Test; From 9f1a6a7dbe396880a9a6b0c7774b285a6b5b2dad Mon Sep 17 00:00:00 2001 From: qasimikram Date: Tue, 9 Jul 2024 13:53:42 +0200 Subject: [PATCH 4/5] dependency on AI Test Toolkit added --- src/System Application/Test/app.json | 146 ++++++++++++++------------- 1 file changed, 75 insertions(+), 71 deletions(-) diff --git a/src/System Application/Test/app.json b/src/System Application/Test/app.json index 6aeaab1879..dda717e1f9 100644 --- a/src/System Application/Test/app.json +++ b/src/System Application/Test/app.json @@ -1,72 +1,76 @@ { - "id": "0d60b215-6ee1-4789-8e53-866cfa50c23c", - "name": "System Application Test", - "publisher": "Microsoft", - "brief": "Test suite for the System Application.", - "description": "Contains an expansive set tests for the System Application.", - "version": "25.0.0.0", - "privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009", - "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120", - "help": "https://go.microsoft.com/fwlink/?linkid=2131960", - "url": "https://go.microsoft.com/fwlink/?LinkId=724011", - "logo": "ExtensionLogo.png", - "contextSensitiveHelpUrl": "https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-testing-application/", - "dependencies": [ - { - "id": "63ca2fa4-4f03-4f2b-a480-172fef340d3f", - "name": "System Application", - "publisher": "Microsoft", - "version": "25.0.0.0" - }, - { - "id": "9856ae4f-d1a7-46ef-89bb-6ef056398228", - "name": "System Application Test Library", - "publisher": "Microsoft", - "version": "25.0.0.0" - }, - { - "id": "dd0be2ea-f733-4d65-bb34-a28f4624fb14", - "name": "Library Assert", - "publisher": "Microsoft", - "version": "25.0.0.0" - }, - { - "id": "e7320ebb-08b3-4406-b1ec-b4927d3e280b", - "name": "Any", - "publisher": "Microsoft", - "version": "25.0.0.0" - }, - { - "id": "5095f467-0a01-4b99-99d1-9ff1237d286f", - "name": "Library Variable Storage", - "publisher": "Microsoft", - "version": "25.0.0.0" - }, - { - "id": "40860557-a18d-42ad-aecb-22b7dd80dc80", - "name": "Permissions Mock", - "publisher": "Microsoft", - "version": "25.0.0.0" - } - ], - "screenshots": [ - - ], - "platform": "25.0.0.0", - "features": [ - "GenerateCaptions", - "TranslationFile" - ], - "resourceExposurePolicy": { - "allowDebugging": true, - "allowDownloadingSource": true, - "includeSourceInSymbolFile": true - }, - "target": "OnPrem", - "idRanges": [ - { - "from": 130000, - "to": 139999 - } - ] -} + "id": "0d60b215-6ee1-4789-8e53-866cfa50c23c", + "name": "System Application Test", + "publisher": "Microsoft", + "brief": "Test suite for the System Application.", + "description": "Contains an expansive set tests for the System Application.", + "version": "25.0.0.0", + "privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009", + "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120", + "help": "https://go.microsoft.com/fwlink/?linkid=2131960", + "url": "https://go.microsoft.com/fwlink/?LinkId=724011", + "logo": "ExtensionLogo.png", + "contextSensitiveHelpUrl": "https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-testing-application/", + "dependencies": [ + { + "id": "63ca2fa4-4f03-4f2b-a480-172fef340d3f", + "name": "System Application", + "publisher": "Microsoft", + "version": "25.0.0.0" + }, + { + "id": "9856ae4f-d1a7-46ef-89bb-6ef056398228", + "name": "System Application Test Library", + "publisher": "Microsoft", + "version": "25.0.0.0" + }, + { + "id": "dd0be2ea-f733-4d65-bb34-a28f4624fb14", + "name": "Library Assert", + "publisher": "Microsoft", + "version": "25.0.0.0" + }, + { + "id": "e7320ebb-08b3-4406-b1ec-b4927d3e280b", + "name": "Any", + "publisher": "Microsoft", + "version": "25.0.0.0" + }, + { + "id": "5095f467-0a01-4b99-99d1-9ff1237d286f", + "name": "Library Variable Storage", + "publisher": "Microsoft", + "version": "25.0.0.0" + }, + { + "id": "40860557-a18d-42ad-aecb-22b7dd80dc80", + "name": "Permissions Mock", + "publisher": "Microsoft", + "version": "25.0.0.0" + }, + { + "id": "2156302a-872f-4568-be0b-60968696f0d5", + "name": "AI Test Toolkit", + "publisher": "Microsoft", + "version": "25.0.0.0" + } + ], + "screenshots": [], + "platform": "25.0.0.0", + "features": [ + "GenerateCaptions", + "TranslationFile" + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "target": "OnPrem", + "idRanges": [ + { + "from": 130000, + "to": 139999 + } + ] +} \ No newline at end of file From 7bc9f6b1424d0d44b107b482a3e8934ff8ce6fa5 Mon Sep 17 00:00:00 2001 From: qasimikram Date: Tue, 9 Jul 2024 14:02:50 +0200 Subject: [PATCH 5/5] Tests disabled --- .../Test/DisabledTests/EntityTextTests.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/System Application/Test/DisabledTests/EntityTextTests.json diff --git a/src/System Application/Test/DisabledTests/EntityTextTests.json b/src/System Application/Test/DisabledTests/EntityTextTests.json new file mode 100644 index 0000000000..d715e6c8c7 --- /dev/null +++ b/src/System Application/Test/DisabledTests/EntityTextTests.json @@ -0,0 +1,14 @@ +[ + { + "bug": "", + "codeunitId": 134640, + "codeunitName": "Mkt Text Accuracy AIT", + "method": "*" + }, + { + "bug": "", + "codeunitId": 134641, + "codeunitName": "Mkt Text RedTeam AIT", + "method": "*" + } +] \ No newline at end of file