Skip to content
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

added notes and expected answer to csv export and made input column d… #1208

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,13 @@ const ABTestingEvaluationTable: React.FC<EvaluationTableProps> = ({
Run All
</Button>
<SecondaryButton
onClick={() => exportABTestingEvaluationData(evaluation, rows)}
onClick={() =>
exportABTestingEvaluationData(
evaluation,
evaluationScenarios,
rows,
)
}
disabled={false}
>
Export results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,13 @@ const SingleModelEvaluationTable: React.FC<EvaluationTableProps> = ({
Run All
</Button>
<SecondaryButton
onClick={() => exportSingleModelEvaluationData(evaluation, rows)}
onClick={() =>
exportSingleModelEvaluationData(
evaluation,
evaluationScenarios,
rows,
)
}
disabled={false}
>
Export results
Expand Down
42 changes: 33 additions & 9 deletions agenta-web/src/lib/helpers/evaluate.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
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 exportABTestingEvaluationData = (evaluation: Evaluation, rows: GenericObject[]) => {
export const exportABTestingEvaluationData = (
evaluation: Evaluation,
scenarios: EvaluationScenario[],
rows: GenericObject[],
) => {
const exportRow = rows.map((data, ix) => {
const inputColumns = data.inputs.reduce(
bekossy marked this conversation as resolved.
Show resolved Hide resolved
(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,
Expand All @@ -17,6 +26,9 @@ 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 || evaluation.testset.csvdata[ix].correct_answer,
["Additional notes"]: scenarios[ix]?.note,
}
})
const exportCol = Object.keys(exportRow[0])
Expand All @@ -26,17 +38,29 @@ export const exportABTestingEvaluationData = (evaluation: Evaluation, rows: Gene
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(
bekossy marked this conversation as resolved.
Show resolved Hide resolved
(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])
Expand Down
Loading