From 3a82c5b9ee00245b9c3b4debced968b44488722b Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Mon, 15 Jan 2024 12:27:35 +0100 Subject: [PATCH 1/6] feat: export answer and notes --- .../EvaluationTable/ABTestingEvaluationTable.tsx | 8 +++++++- agenta-web/src/lib/helpers/evaluate.ts | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx b/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx index 8c4ca6fc27..777729b31a 100644 --- a/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx +++ b/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx @@ -381,7 +381,13 @@ const ABTestingEvaluationTable: React.FC = ({ Run All exportABTestingEvaluationData(evaluation, rows)} + onClick={() => + exportABTestingEvaluationData( + evaluation, + evaluationScenarios, + rows, + ) + } disabled={false} > Export results diff --git a/agenta-web/src/lib/helpers/evaluate.ts b/agenta-web/src/lib/helpers/evaluate.ts index 5311b1e7c2..b0caba4cce 100644 --- a/agenta-web/src/lib/helpers/evaluate.ts +++ b/agenta-web/src/lib/helpers/evaluate.ts @@ -1,5 +1,5 @@ import {HumanEvaluationListTableDataType} from "@/components/Evaluations/HumanEvaluationResult" -import {Evaluation, GenericObject, Variant} from "../Types" +import {Evaluation, EvaluationScenario, GenericObject, Variant} from "../Types" import {convertToCsv, downloadCsv} from "./fileManipulations" export const exportExactEvaluationData = (evaluation: Evaluation, rows: GenericObject[]) => { @@ -63,7 +63,11 @@ export const exportAICritiqueEvaluationData = (evaluation: Evaluation, rows: Gen downloadCsv(csvData, filename) } -export const exportABTestingEvaluationData = (evaluation: Evaluation, rows: GenericObject[]) => { +export const exportABTestingEvaluationData = ( + evaluation: Evaluation, + scenarios: EvaluationScenario[], + rows: GenericObject[], +) => { const exportRow = rows.map((data, ix) => { return { ["Inputs"]: @@ -78,6 +82,8 @@ export const exportABTestingEvaluationData = (evaluation: Evaluation, rows: Gene ["Vote"]: evaluation.variants.find((v: Variant) => v.variantId === data.vote)?.variantName || data.vote, + ["Expected answer"]: scenarios[ix]?.correctAnswer, + ["Additional notes"]: scenarios[ix]?.note, } }) const exportCol = Object.keys(exportRow[0]) From 6d89c0dd38d43ae4a338835b653445bf105c9c5a Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Mon, 15 Jan 2024 15:52:41 +0100 Subject: [PATCH 2/6] dynamic column input for csv --- agenta-web/src/lib/helpers/evaluate.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/agenta-web/src/lib/helpers/evaluate.ts b/agenta-web/src/lib/helpers/evaluate.ts index b0caba4cce..7c29834e13 100644 --- a/agenta-web/src/lib/helpers/evaluate.ts +++ b/agenta-web/src/lib/helpers/evaluate.ts @@ -69,10 +69,15 @@ export const exportABTestingEvaluationData = ( rows: GenericObject[], ) => { const exportRow = rows.map((data, ix) => { + const inputColumns = data.inputs.reduce( + (columns: any, input: {input_name: string; input_value: string}) => { + columns[`${input.input_name}`] = input.input_value + return columns + }, + {}, + ) return { - ["Inputs"]: - evaluation.testset.csvdata[ix]?.[evaluation.testset.testsetChatColumn] || - data.inputs[0].input_value, + ...inputColumns, [`App Variant ${evaluation.variants[0].variantName} Output 0`]: data?.columnData0 ? data?.columnData0 : data.outputs[0]?.variant_output, From 05a143647340a64c4a32044c12c92b5f44aec1cf Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Mon, 15 Jan 2024 16:18:29 +0100 Subject: [PATCH 3/6] conditional check for expected answer --- agenta-web/src/lib/helpers/evaluate.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/agenta-web/src/lib/helpers/evaluate.ts b/agenta-web/src/lib/helpers/evaluate.ts index 7c29834e13..f4d8642edb 100644 --- a/agenta-web/src/lib/helpers/evaluate.ts +++ b/agenta-web/src/lib/helpers/evaluate.ts @@ -87,7 +87,8 @@ export const exportABTestingEvaluationData = ( ["Vote"]: evaluation.variants.find((v: Variant) => v.variantId === data.vote)?.variantName || data.vote, - ["Expected answer"]: scenarios[ix]?.correctAnswer, + ["Expected answer"]: + scenarios[ix]?.correctAnswer || evaluation.testset.csvdata[ix].correct_answer, ["Additional notes"]: scenarios[ix]?.note, } }) From cf6157d760a80429e3e26807e6899f4c229bae5f Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Mon, 15 Jan 2024 16:36:38 +0100 Subject: [PATCH 4/6] added expected answer and note to csv and dynamic col inputs to single model --- .../SingleModelEvaluationTable.tsx | 8 +++++++- agenta-web/src/lib/helpers/evaluate.ts | 20 +++++++++++++++---- rabbitmq_data/.erlang.cookie | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 rabbitmq_data/.erlang.cookie diff --git a/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx b/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx index efa7f1efcd..70d12a7dc3 100644 --- a/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx +++ b/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx @@ -448,7 +448,13 @@ const SingleModelEvaluationTable: React.FC = ({ Run All exportSingleModelEvaluationData(evaluation, rows)} + onClick={() => + exportSingleModelEvaluationData( + evaluation, + evaluationScenarios, + rows, + ) + } disabled={false} > Export results diff --git a/agenta-web/src/lib/helpers/evaluate.ts b/agenta-web/src/lib/helpers/evaluate.ts index f4d8642edb..31ce851ec6 100644 --- a/agenta-web/src/lib/helpers/evaluate.ts +++ b/agenta-web/src/lib/helpers/evaluate.ts @@ -99,17 +99,29 @@ export const exportABTestingEvaluationData = ( downloadCsv(csvData, filename) } -export const exportSingleModelEvaluationData = (evaluation: Evaluation, rows: GenericObject[]) => { +export const exportSingleModelEvaluationData = ( + evaluation: Evaluation, + scenarios: EvaluationScenario[], + rows: GenericObject[], +) => { const exportRow = rows.map((data, ix) => { + const inputColumns = data.inputs.reduce( + (columns: any, input: {input_name: string; input_value: string}) => { + columns[`${input.input_name}`] = input.input_value + return columns + }, + {}, + ) const numericScore = parseInt(data.score) return { - ["Inputs"]: - evaluation.testset.csvdata[ix]?.[evaluation.testset.testsetChatColumn] || - data.inputs[0].input_value, + ...inputColumns, [`App Variant ${evaluation.variants[0].variantName} Output 0`]: data?.columnData0 ? data?.columnData0 : data.outputs[0]?.variant_output, ["Score"]: isNaN(numericScore) ? "-" : numericScore, + ["Expected answer"]: + scenarios[ix]?.correctAnswer || evaluation.testset.csvdata[ix].correct_answer, + ["Additional notes"]: scenarios[ix]?.note, } }) const exportCol = Object.keys(exportRow[0]) diff --git a/rabbitmq_data/.erlang.cookie b/rabbitmq_data/.erlang.cookie new file mode 100644 index 0000000000..f9807e6a0c --- /dev/null +++ b/rabbitmq_data/.erlang.cookie @@ -0,0 +1 @@ +IEMBREZETCGSGJBJAKVJ \ No newline at end of file From 7f1ef7baf73cefffd90093b10c4eec24777813f0 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Tue, 16 Jan 2024 01:45:17 +0100 Subject: [PATCH 5/6] removed rabbitmd_data --- rabbitmq_data/.erlang.cookie | 1 - 1 file changed, 1 deletion(-) delete mode 100644 rabbitmq_data/.erlang.cookie diff --git a/rabbitmq_data/.erlang.cookie b/rabbitmq_data/.erlang.cookie deleted file mode 100644 index f9807e6a0c..0000000000 --- a/rabbitmq_data/.erlang.cookie +++ /dev/null @@ -1 +0,0 @@ -IEMBREZETCGSGJBJAKVJ \ No newline at end of file From a7cb17590d2c957ff0c7b7f90392dbb23d9da404 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Tue, 16 Jan 2024 15:01:31 +0100 Subject: [PATCH 6/6] sync changes with chat --- agenta-web/src/lib/helpers/evaluate.ts | 32 +++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/agenta-web/src/lib/helpers/evaluate.ts b/agenta-web/src/lib/helpers/evaluate.ts index 31ce851ec6..abfac16f40 100644 --- a/agenta-web/src/lib/helpers/evaluate.ts +++ b/agenta-web/src/lib/helpers/evaluate.ts @@ -69,13 +69,15 @@ export const exportABTestingEvaluationData = ( rows: GenericObject[], ) => { const exportRow = rows.map((data, ix) => { - const inputColumns = data.inputs.reduce( - (columns: any, input: {input_name: string; input_value: string}) => { - columns[`${input.input_name}`] = input.input_value - return columns - }, - {}, - ) + const inputColumns = evaluation.testset.testsetChatColumn + ? {Input: evaluation.testset.csvdata[ix]?.[evaluation.testset.testsetChatColumn]} + : data.inputs.reduce( + (columns: any, input: {input_name: string; input_value: string}) => { + columns[`${input.input_name}`] = input.input_value + return columns + }, + {}, + ) return { ...inputColumns, [`App Variant ${evaluation.variants[0].variantName} Output 0`]: data?.columnData0 @@ -105,13 +107,15 @@ export const exportSingleModelEvaluationData = ( rows: GenericObject[], ) => { const exportRow = rows.map((data, ix) => { - const inputColumns = data.inputs.reduce( - (columns: any, input: {input_name: string; input_value: string}) => { - columns[`${input.input_name}`] = input.input_value - return columns - }, - {}, - ) + const inputColumns = evaluation.testset.testsetChatColumn + ? {Input: evaluation.testset.csvdata[ix]?.[evaluation.testset.testsetChatColumn]} + : data.inputs.reduce( + (columns: any, input: {input_name: string; input_value: string}) => { + columns[`${input.input_name}`] = input.input_value + return columns + }, + {}, + ) const numericScore = parseInt(data.score) return { ...inputColumns,