-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AI Test Tool] Add Multi-Turn Accuracy & Export #2419
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,12 @@ codeunit 149043 "AIT Test Context Impl." | |
var | ||
AITTestSuiteMgt: Codeunit "AIT Test Suite Mgt."; | ||
GlobalTestOutputJson: Codeunit "Test Output Json"; | ||
Accuracy: Decimal; | ||
CurrentTurn: Integer; | ||
NumberOfTurns: Integer; | ||
IsMultiTurn: Boolean; | ||
AccuracySetManually: Boolean; | ||
AccuracyErr: Label 'Accuracy must be between 0.0 and 1.0.'; | ||
AnswerTok: Label 'answer', Locked = true; | ||
ContextTok: Label 'context', Locked = true; | ||
GroundTruthTok: Label 'ground_truth', Locked = true; | ||
|
@@ -146,6 +149,33 @@ codeunit 149043 "AIT Test Context Impl." | |
SetSuiteTestOutput(CurrentTestOutputJson.ToText()); | ||
end; | ||
|
||
/// <summary> | ||
/// Sets the accuracy of the test. | ||
/// </summary> | ||
/// <param name="AccuracyPct">The accuracy as a decimal between 0 and 1.</param> | ||
procedure SetAccuracy(AccuracyPct: Decimal) | ||
begin | ||
if (AccuracyPct < 0) or (AccuracyPct > 1.0) then | ||
Error(AccuracyErr); | ||
|
||
AccuracySetManually := true; | ||
Accuracy := AccuracyPct; | ||
end; | ||
|
||
/// <summary> | ||
/// Gets the accuracy of the test. | ||
/// </summary> | ||
/// <returns>True if the accuracy was set, false otherwise.</returns> | ||
procedure GetAccuracy(var AccuracyPct: Decimal): Boolean | ||
begin | ||
if AccuracySetManually then begin | ||
AccuracyPct := Accuracy; | ||
exit(true); | ||
end; | ||
|
||
exit(false); | ||
end; | ||
|
||
/// <summary> | ||
/// Sets to next turn for multiturn testing. | ||
/// </summary> | ||
|
@@ -155,7 +185,7 @@ codeunit 149043 "AIT Test Context Impl." | |
if not IsMultiTurn then | ||
exit(false); | ||
|
||
if CurrentTurn + 1 > NumberOfTurns then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change may cause regression. Have you tested against some of our existing multi-turn scenarios? Just to be 100% sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see CurrentTurn is now starts with 1. |
||
if CurrentTurn > NumberOfTurns then | ||
exit(false); | ||
|
||
CurrentTurn := CurrentTurn + 1; | ||
|
@@ -164,14 +194,23 @@ codeunit 149043 "AIT Test Context Impl." | |
end; | ||
|
||
/// <summary> | ||
/// Gets the current turn for multiturn testing. Turns start from turn 0. | ||
/// Gets the current turn for multiturn testing. Turns start from turn 1. | ||
/// </summary> | ||
/// <returns>The current turn number.</returns> | ||
procedure GetCurrentTurn(): Integer | ||
begin | ||
exit(CurrentTurn); | ||
end; | ||
|
||
/// <summary> | ||
/// Gets the total number of turns for multiturn testing. | ||
/// </summary> | ||
/// <returns>The total number of turns for the line.</returns> | ||
procedure GetNumberOfTurns(): Integer | ||
begin | ||
exit(NumberOfTurns); | ||
end; | ||
|
||
/// <summary> | ||
/// This method starts the scope of the Run Procedure scenario. | ||
/// </summary> | ||
|
@@ -205,12 +244,16 @@ codeunit 149043 "AIT Test Context Impl." | |
TestInput: Codeunit "Test Input"; | ||
TurnsInputJson: Codeunit "Test Input Json"; | ||
begin | ||
CurrentTurn := 0; | ||
AccuracySetManually := false; | ||
Accuracy := 0; | ||
CurrentTurn := 1; | ||
GlobalTestOutputJson.Initialize(); | ||
TurnsInputJson := TestInput.GetTestInput().ElementExists(TurnsTok, IsMultiTurn); | ||
|
||
if IsMultiTurn then | ||
NumberOfTurns := TurnsInputJson.GetElementCount() - 1; | ||
NumberOfTurns := TurnsInputJson.GetElementCount() | ||
else | ||
NumberOfTurns := 1; | ||
end; | ||
|
||
/// <summary> | ||
|
@@ -223,7 +266,7 @@ codeunit 149043 "AIT Test Context Impl." | |
TestInput: Codeunit "Test Input"; | ||
begin | ||
if IsMultiTurn then | ||
TestInputJson := TestInput.GetTestInput(TurnsTok).ElementAt(CurrentTurn).Element(ElementName) | ||
TestInputJson := TestInput.GetTestInput(TurnsTok).ElementAt(CurrentTurn - 1).Element(ElementName) | ||
else | ||
TestInputJson := TestInput.GetTestInput(ElementName); | ||
end; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,23 @@ page 149033 "AIT Log Entries" | |
{ | ||
StyleExpr = StatusStyleExpr; | ||
} | ||
field(Accuracy; Rec.Accuracy) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to expose these in the API as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel free to create a separate work item, we can uptake the API changes in the same work item. |
||
{ | ||
} | ||
field("No. of Turns Passed"; Rec."No. of Turns Passed") | ||
{ | ||
Visible = false; | ||
} | ||
field("No. of Turns Executed"; Rec."No. of Turns Executed") | ||
{ | ||
Visible = false; | ||
} | ||
field(TurnsText; TurnsText) | ||
{ | ||
StyleExpr = TurnsStyleExpr; | ||
Caption = 'No. of Turns Passed'; | ||
ToolTip = 'Specifies the number of turns that passed out of the total number of turns.'; | ||
} | ||
field("Orig. Status"; Rec."Original Status") | ||
{ | ||
Visible = false; | ||
|
@@ -253,6 +270,19 @@ page 149033 "AIT Log Entries" | |
Page.Run(Page::"AIT Test Data Compare", Rec); | ||
end; | ||
} | ||
action("Export Results") | ||
{ | ||
Caption = 'Export Results'; | ||
Image = Export; | ||
ToolTip = 'Exports the results.'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you provide a better tool tip. It might be confusing with the existing action of download test output. |
||
|
||
trigger OnAction() | ||
var | ||
AITTestSuiteMgt: Codeunit "AIT Test Suite Mgt."; | ||
begin | ||
AITTestSuiteMgt.ExportResults(Rec); | ||
end; | ||
} | ||
} | ||
area(Promoted) | ||
{ | ||
|
@@ -279,6 +309,9 @@ page 149033 "AIT Log Entries" | |
actionref("View Test Data_Promoted"; "View Test Data") | ||
{ | ||
} | ||
actionref("Export Results_Promoted"; "Export Results") | ||
{ | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -287,20 +320,26 @@ page 149033 "AIT Log Entries" | |
ClickToShowLbl: Label 'Show data input'; | ||
DoYouWantToDeleteQst: Label 'Do you want to delete all entries within the filter?'; | ||
InputText: Text; | ||
TurnsText: Text; | ||
OutputText: Text; | ||
ErrorMessage: Text; | ||
ErrorCallStack: Text; | ||
StatusStyleExpr: Text; | ||
TurnsStyleExpr: Text; | ||
TestRunDuration: Duration; | ||
IsFilteredToErrors: Boolean; | ||
ShowSensitiveData: Boolean; | ||
|
||
trigger OnAfterGetRecord() | ||
var | ||
AITTestSuiteMgt: Codeunit "AIT Test Suite Mgt."; | ||
begin | ||
TestRunDuration := Rec."Duration (ms)"; | ||
TurnsText := AITTestSuiteMgt.GetTurnsAsText(Rec); | ||
SetInputOutputDataFields(); | ||
SetErrorFields(); | ||
SetStatusStyleExpr(); | ||
SetTurnsStyleExpr(); | ||
end; | ||
|
||
local procedure SetStatusStyleExpr() | ||
|
@@ -315,6 +354,18 @@ page 149033 "AIT Log Entries" | |
end; | ||
end; | ||
|
||
local procedure SetTurnsStyleExpr() | ||
begin | ||
case Rec."No. of Turns Passed" of | ||
Rec."No. of Turns Executed": | ||
TurnsStyleExpr := 'Favorable'; | ||
0: | ||
TurnsStyleExpr := 'Unfavorable'; | ||
else | ||
TurnsStyleExpr := 'Ambiguous'; | ||
end; | ||
end; | ||
|
||
local procedure SetErrorFields() | ||
begin | ||
ErrorMessage := ''; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,6 +159,21 @@ table 149034 "AIT Log Entry" | |
{ | ||
Caption = 'Output Data'; | ||
} | ||
field(40; "No. of Turns Executed"; Integer) | ||
{ | ||
Caption = 'Total number of turns'; | ||
ToolTip = 'Specifies the total number of turns executed.'; | ||
} | ||
field(41; "No. of Turns Passed"; Integer) | ||
{ | ||
Caption = 'Number of turns passed'; | ||
ToolTip = 'Specifies the number of turns passed.'; | ||
} | ||
field(45; Accuracy; Decimal) | ||
{ | ||
Caption = 'Accuracy'; | ||
ToolTip = 'Specifies the accuracy of the test line.'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: consider describing how the accuracy can be calculated or what does it exactly mean. Considering we have a status field as well. |
||
} | ||
field(50; "Tokens Consumed"; Integer) | ||
{ | ||
Caption = 'Total Tokens Consumed'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// ------------------------------------------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
namespace System.TestTools.AITestToolkit; | ||
|
||
report 149030 "AIT Results" | ||
{ | ||
Caption = 'AI Test Results'; | ||
ApplicationArea = All; | ||
UsageCategory = Tasks; | ||
DefaultLayout = Excel; | ||
ExcelLayout = 'Results.xlsx'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider using a better name for the layout |
||
|
||
dataset | ||
{ | ||
dataitem(Results; "AIT Log Entry") | ||
{ | ||
|
||
RequestFilterFields = Version; | ||
RequestFilterHeading = 'AI Test Log Entries'; | ||
|
||
column(CodeunitID; Results."Codeunit ID") | ||
{ | ||
} | ||
column(Name; Results."Codeunit Name") | ||
{ | ||
} | ||
column(TestName; Results."Procedure Name") | ||
{ | ||
} | ||
column(Status; Results.Status) | ||
{ | ||
} | ||
column(Accuracy; Results.Accuracy) | ||
{ | ||
} | ||
column(TurnsExecuted; Results."No. of Turns Executed") | ||
{ | ||
} | ||
column(TurnsPassed; Results."No. of Turns Passed") | ||
{ | ||
} | ||
column(Input; Input) | ||
{ | ||
} | ||
column(Output; Output) | ||
{ | ||
} | ||
column(Error_Message; ErrorMessage) | ||
{ | ||
} | ||
column(Error; ErrorCallstack) | ||
{ | ||
} | ||
|
||
trigger OnAfterGetRecord() | ||
begin | ||
Input := Results.GetInputBlob(); | ||
Output := Results.GetOutputBlob(); | ||
ErrorMessage := Results.GetMessage(); | ||
ErrorCallstack := Results.GetErrorCallStack(); | ||
end; | ||
} | ||
} | ||
|
||
var | ||
Input: Text; | ||
Output: Text; | ||
ErrorMessage: Text; | ||
ErrorCallstack: Text; | ||
} |
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.
missing parameter doc for AccuracyPct
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.
It is not clear that this function returns accuracy only when it is being set manually.